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

유저 인증 관련 클래스 기능 구현 & 리팩토링 #43

Merged
merged 32 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
62aeae6
:sparkles: Separate HomeActivity and AuthActivity
sukchan-0811 Nov 12, 2023
7d38490
:sparkles: Implement SessionManager
sukchan-0811 Nov 12, 2023
431c4ad
:bug: Fix compilation error
89645321 Nov 12, 2023
240ffb7
:sparkles: Implement ConnectException, loading
89645321 Nov 12, 2023
fe4c356
:fire: Remove auth top app bar ui
sukchan-0811 Nov 12, 2023
0bafd4c
:sparkles: Implement logout and withdraw feature
89645321 Nov 12, 2023
41397ca
:recycle: Refactor string resources
sukchan-0811 Nov 12, 2023
c3a8b01
:recycle: Refactor auth related classes
sukchan-0811 Nov 12, 2023
101570b
:twisted_rightwards_arrows: Merge main into refactor/auth
sukchan-0811 Nov 12, 2023
cef1ff2
:twisted_rightwards_arrows: Merge branch 'main' of https://github.com…
yjeong-k Nov 12, 2023
b91d2b5
:bug: Fix compilation error in test classes
sukchan-0811 Nov 12, 2023
dd4634f
:lipstick: update pw-related strings
yjeong-k Nov 12, 2023
dd94a21
:white_check_mark: Update auth-related tests
sukchan-0811 Nov 12, 2023
ff3f213
:twisted_rightwards_arrows: Merge feat/logout into refactor/auth
sukchan-0811 Nov 12, 2023
46ebd5f
:sparkles: Implement user-related data classes
sukchan-0811 Nov 12, 2023
18c7e44
:recycle: Refactor session manager & implement guest mode
sukchan-0811 Nov 13, 2023
90499bf
:sparkles: Implement guest mode in settings
sukchan-0811 Nov 13, 2023
7aa6623
:sparkles: Implement get my info & refactor session manager
sukchan-0811 Nov 14, 2023
1494fc6
:fix: Call get my info when login is successful
sukchan-0811 Nov 15, 2023
3806a38
:sparkles: Save user info successfully & display in account settings
sukchan-0811 Nov 15, 2023
fc2b70f
:bug: Fix doubly-called navHomeActivity() problem
sukchan-0811 Nov 15, 2023
de17e45
:lipstick: Enhance signup screen UI: nickname and password are immedi…
sukchan-0811 Nov 15, 2023
b0e9268
:sparkles: Add progress indicator in email verification screen
sukchan-0811 Nov 15, 2023
1a13722
:art: Remove unused imports in email verification screen
sukchan-0811 Nov 15, 2023
dd012d7
:lipstick: Disable send code button if email error in email verificat…
sukchan-0811 Nov 15, 2023
b57fa98
:twisted_rightwards_arrows: Merge main into refactor/auth-clean-ver
sukchan-0811 Nov 15, 2023
52d3fea
:bug: Set proper variable in validatePasswordCheck()
yjeong-k Nov 16, 2023
e1d4fc7
:recycle: Change response format of get-user-profile API (backend)
yjeong-k Nov 16, 2023
8fa09e9
:bug: Modify test to reflect changes in get-user-profile API response
yjeong-k Nov 16, 2023
5980c30
Update frontend/app/src/main/java/com/example/speechbuddy/viewmodel/S…
89645321 Nov 16, 2023
4d01a48
Update frontend/app/src/main/java/com/example/speechbuddy/viewmodel/S…
89645321 Nov 16, 2023
53ee7d1
Update frontend/app/src/main/java/com/example/speechbuddy/ui/models/A…
89645321 Nov 16, 2023
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
7 changes: 6 additions & 1 deletion frontend/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ dependencies {
// Gson
implementation("com.google.code.gson:gson:2.9.0")

// DataStore
val dataStoreVersion = "1.0.0-alpha06"
implementation("androidx.datastore:datastore-preferences:$dataStoreVersion")
implementation("androidx.datastore:datastore-preferences-core:$dataStoreVersion")

// Room
val roomVersion = "2.6.0"
implementation("androidx.room:room-ktx:$roomVersion")
Expand All @@ -130,7 +135,7 @@ dependencies {
implementation("com.google.dagger:hilt-android:$hiltVersion")
kapt("com.google.dagger:hilt-compiler:$hiltVersion")

implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
implementation("androidx.hilt:hilt-navigation-compose:1.1.0")

// MockK
val mockkVersion = "1.13.8"
Expand Down
5 changes: 3 additions & 2 deletions frontend/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".MainApplication"
android:name=".BaseApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
Expand All @@ -16,8 +16,9 @@
android:theme="@style/Theme.SpeechBuddy"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity android:name=".HomeActivity" />
<activity
android:name=".MainActivity"
android:name=".AuthActivity"
android:exported="true"
android:theme="@style/Theme.SpeechBuddy">
<intent-filter>
Expand Down
50 changes: 50 additions & 0 deletions frontend/app/src/main/java/com/example/speechbuddy/AuthActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.example.speechbuddy

import android.content.Intent
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.core.view.WindowCompat
import com.example.speechbuddy.compose.SpeechBuddyAuth
import com.example.speechbuddy.ui.SpeechBuddyTheme
import com.example.speechbuddy.viewmodel.LoginViewModel
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class AuthActivity : BaseActivity() {

private val loginViewModel: LoginViewModel by viewModels()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

// Displaying edge-to-edge
WindowCompat.setDecorFitsSystemWindows(window, false)

subscribeObservers()
checkPreviousAuthUser()

setContent {
SpeechBuddyTheme {
SpeechBuddyAuth()
}
}
}

private fun subscribeObservers() {
sessionManager.isAuthorized.observe(this) { isAuthorized ->
if (isAuthorized) navHomeActivity()
}
}

private fun navHomeActivity() {
val intent = Intent(this, HomeActivity::class.java)
startActivity(intent)
finish()
}

private fun checkPreviousAuthUser() {
loginViewModel.checkPreviousUser()
}

}
12 changes: 12 additions & 0 deletions frontend/app/src/main/java/com/example/speechbuddy/BaseActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.example.speechbuddy

import androidx.appcompat.app.AppCompatActivity
import com.example.speechbuddy.domain.SessionManager
import javax.inject.Inject

abstract class BaseActivity : AppCompatActivity() {

@Inject
lateinit var sessionManager: SessionManager

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.speechbuddy

import android.app.Application
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class BaseApplication : Application()
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
package com.example.speechbuddy

import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.core.view.WindowCompat
import com.example.speechbuddy.MainApplication.Companion.token_prefs
import com.example.speechbuddy.compose.SpeechBuddyApp
import com.example.speechbuddy.domain.utils.TokenSharedPreferences
import com.example.speechbuddy.compose.SpeechBuddyHome
import com.example.speechbuddy.ui.SpeechBuddyTheme
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
class HomeActivity : BaseActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
token_prefs = TokenSharedPreferences(applicationContext)
super.onCreate(savedInstanceState)

// Displaying edge-to-edge
WindowCompat.setDecorFitsSystemWindows(window, false)

setContent {
SpeechBuddyTheme {
SpeechBuddyApp()
SpeechBuddyHome()
}
}

subscribeObservers()
}

private fun subscribeObservers() {
sessionManager.isAuthorized.observe(this) { isAuthorized ->
if (!isAuthorized) navAuthActivity()
}
}

private fun navAuthActivity() {
val intent = Intent(this, AuthActivity::class.java)
startActivity(intent)
finish()
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,33 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.example.speechbuddy.compose.emailverification.EmailVerificationScreen
import com.example.speechbuddy.compose.home.HomeScreen
import com.example.speechbuddy.compose.landing.LandingScreen
import com.example.speechbuddy.compose.login.LoginScreen
import com.example.speechbuddy.compose.resetpassword.ResetPasswordScreen
import com.example.speechbuddy.compose.signup.SignupScreen

@Composable
fun SpeechBuddyApp() {
fun SpeechBuddyAuth() {
val navController = rememberNavController()
SpeechBuddyNavHost(
SpeechBuddyAuthNavHost(
navController = navController
)
}

@Composable
fun SpeechBuddyNavHost(
fun SpeechBuddyAuthNavHost(
navController: NavHostController
) {
// val activity = (LocalContext.current as Activity)
NavHost(navController = navController, startDestination = "landing") {
composable("landing") {
LandingScreen(
onGuestClick = {
navController.navigate("home")
},
onLoginClick = {
navController.navigate("login")
}
)
}
composable("login") {
LoginScreen(
onBackClick = {
navController.navigateUp()
},
onResetPasswordClick = {
navController.navigate("email_verification/reset_password")
},
Expand All @@ -53,31 +45,24 @@ fun SpeechBuddyNavHost(
val source = backStackEntry.arguments?.getString("source")
EmailVerificationScreen(
source = source,
onBackClick = {
navController.navigateUp()
},
navController = navController,
navigateCallback = { navController.navigate(it) }
)
}
composable("signup/{emailInput}") { backStackEntry ->
val emailInput = backStackEntry.arguments?.getString("emailInput")
composable("signup/{email}") { backStackEntry ->
val email = backStackEntry.arguments?.getString("email")
SignupScreen(
onBackClick = {
navController.navigateUp()
},
email = emailInput ?: ""
email = email ?: "",
navigateToLogin = {
navController.navigate("login")
}
)
}
composable("reset_password") {
ResetPasswordScreen(
onBackClick = {
navController.navigateUp()
},
navController = navController
navigateToLogin = {
navController.navigate("login")
}
)
}
composable("home") {
HomeScreen()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.example.speechbuddy.compose.home
package com.example.speechbuddy.compose

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
Expand Down Expand Up @@ -36,7 +38,7 @@ data class BottomNavItem(

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun HomeScreen() {
fun SpeechBuddyHome() {
val navController = rememberNavController()
val navItems = listOf(
BottomNavItem(
Expand All @@ -51,7 +53,7 @@ fun HomeScreen() {
),
BottomNavItem(
"symbol_creation",
R.string.symbol_creation,
R.string.create_new_symbol,
R.drawable.outline_add_a_photo_24
),
BottomNavItem(
Expand All @@ -62,6 +64,7 @@ fun HomeScreen() {
)

Scaffold(
modifier = Modifier.padding(bottom = 48.dp), // System Bar Padding
bottomBar = {
BottomNavigationBar(
items = navItems,
Expand All @@ -72,7 +75,7 @@ fun HomeScreen() {
)
}
) { paddingValues ->
HomeScreenNavHost(
SpeechBuddyHomeNavHost(
navController = navController,
bottomPaddingValues = paddingValues
)
Expand All @@ -88,8 +91,9 @@ private fun BottomNavigationBar(
val backStackEntry = navController.currentBackStackEntryAsState()

NavigationBar(
modifier = Modifier.height(64.dp),
containerColor = MaterialTheme.colorScheme.secondaryContainer,
windowInsets = WindowInsets(top = 20.dp)
windowInsets = WindowInsets(top = 16.dp)
) {
items.forEach { item ->
val selected = item.route == backStackEntry.value?.destination?.route
Expand All @@ -102,10 +106,10 @@ private fun BottomNavigationBar(
contentDescription = stringResource(id = item.nameResId)
)
},
modifier = Modifier.size(40.dp),
modifier = Modifier.size(32.dp),
colors = NavigationBarItemDefaults.colors(
selectedIconColor = MaterialTheme.colorScheme.onPrimaryContainer,
unselectedIconColor = MaterialTheme.colorScheme.outline
selectedIconColor = MaterialTheme.colorScheme.onSecondaryContainer,
unselectedIconColor = MaterialTheme.colorScheme.onSecondaryContainer.copy(alpha = .5f)
),
interactionSource = NoRippleInteractionSource()
)
Expand All @@ -114,7 +118,7 @@ private fun BottomNavigationBar(
}

@Composable
private fun HomeScreenNavHost(
private fun SpeechBuddyHomeNavHost(
navController: NavHostController,
bottomPaddingValues: PaddingValues
) {
Expand Down
Loading