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

Seminar7 #6

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
6 changes: 5 additions & 1 deletion 29th_first_semina/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ android {

dependencies {

implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
implementation "com.google.code.gson:gson:2.8.6"
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
Expand All @@ -50,5 +53,6 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation "androidx.fragment:fragment-ktx:1.3.6"

implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
}
12 changes: 7 additions & 5 deletions 29th_first_semina/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.a29th_first_semina">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.29th_first_semina">
<activity android:name=".SampleActivity" >
android:theme="@style/Theme.29th_first_semina"
android:usesCleartextTraffic="true">
<activity android:name=".ui.view.setting.SettingActivity"></activity>
<activity android:name=".ui.view.onboarding.OnboardingActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.view.sigin.SignUpActivity" />
<activity android:name=".ui.view.sigin.view.SignUpActivity" />
<activity
android:name=".ui.view.home.HomeActivity"
android:exported="false">
Expand All @@ -28,7 +30,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.view.sigin.SignInActivity">
<activity android:name=".ui.view.sigin.view.SignInActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import com.example.a29th_first_semina.R
import com.example.a29th_first_semina.databinding.FragmentProfileBinding
import com.example.a29th_first_semina.ui.view.follwer.FollowerFragment
import com.example.a29th_first_semina.ui.view.repository.RepositoryFragment
import com.example.a29th_first_semina.ui.view.setting.SettingActivity
import com.example.a29th_first_semina.util.IntentUtil.moveActivity


class ProfileFragment : Fragment() {
Expand All @@ -28,6 +30,7 @@ class ProfileFragment : Fragment() {
)
initImage()
initTransactionEvent()
clickBtnSetting()
return binding.root
}

Expand Down Expand Up @@ -72,4 +75,11 @@ class ProfileFragment : Fragment() {
}


private fun clickBtnSetting() {
binding.btnSetting.setOnClickListener {
moveActivity(context,SettingActivity::class.java)
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.example.a29th_first_semina.ui.view.CameraFragment
import com.example.a29th_first_semina.ui.view.ProfileFragment
import com.example.a29th_first_semina.ui.view.follwer.FollowerFragment
import com.example.a29th_first_semina.ui.view.repository.RepositoryFragment
import com.example.a29th_first_semina.util.ToastUtil.makeToast

class HomeActivity : AppCompatActivity() {
private lateinit var binding: ActivityHomeBinding
Expand All @@ -19,7 +20,7 @@ class HomeActivity : AppCompatActivity() {
setContentView(binding.root)

initButtomNavigation()
Toast.makeText(this, "김송현님 환영합니다", Toast.LENGTH_SHORT).show()
makeToast("김송현님 환영합니다")
}

private fun initButtomNavigation(){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.example.a29th_first_semina.ui.view.onboarding

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.navigation.findNavController
import com.example.a29th_first_semina.R
import com.example.a29th_first_semina.databinding.ActivityOnboardingBinding

class OnboardingActivity : AppCompatActivity() {
private lateinit var binding : ActivityOnboardingBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

binding = ActivityOnboardingBinding.inflate(layoutInflater)
setContentView(binding.root)


}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.example.a29th_first_semina.ui.view.onboarding

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.fragment.findNavController
import com.example.a29th_first_semina.R
import com.example.a29th_first_semina.databinding.FragmentOnboarding1Binding


class OnboardingFragment1 : Fragment() {
private var _binding : FragmentOnboarding1Binding ?= null
private val binding get() = _binding ?: error("뷰참조 실패얌")


override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentOnboarding1Binding.inflate(
inflater,
container,
false
)

binding.btnNext.setOnClickListener {
findNavController().navigate(R.id.action_onboardingFragment1_to_onboardingFragment2)
}
return binding.root
}

override fun onDestroy() {
super.onDestroy()
_binding = null
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.example.a29th_first_semina.ui.view.onboarding

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.fragment.findNavController
import com.example.a29th_first_semina.R
import com.example.a29th_first_semina.databinding.FragmentOnboarding2Binding


class OnboardingFragment2 : Fragment() {
private var _binding : FragmentOnboarding2Binding ?= null
private val binding get() = _binding ?: error("뷰참조 실패")


override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentOnboarding2Binding.inflate(
inflater,
container,
false
)
binding.btnNext.setOnClickListener {
findNavController().navigate(R.id.action_onboardingFragment2_to_onbordingFragment3)
}
return binding.root
}

override fun onDestroy() {
super.onDestroy()
_binding = null
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.example.a29th_first_semina.ui.view.onboarding

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.example.a29th_first_semina.databinding.FragmentOnbording3Binding
import com.example.a29th_first_semina.ui.view.sigin.view.SignInActivity
import com.example.a29th_first_semina.util.IntentUtil

class OnbordingFragment3 : Fragment() {
private var _binding : FragmentOnbording3Binding ?= null
private val binding get() = _binding ?: error("뷰참조실패")


override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentOnbording3Binding.inflate(
inflater,
container,
false
)

binding.btnNext.setOnClickListener {
IntentUtil.moveActivity(context, SignInActivity::class.java)
requireActivity().finish()
}
return binding.root
}

override fun onDestroy() {
super.onDestroy()
_binding = null
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.example.a29th_first_semina.ui.view.setting

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import com.example.a29th_first_semina.R
import com.example.a29th_first_semina.databinding.ActivitySettingBinding
import com.example.a29th_first_semina.ui.view.sigin.SheredPreference.SophubUserAuthStorage
import com.example.a29th_first_semina.ui.view.sigin.view.SignInActivity
import com.example.a29th_first_semina.util.IntentUtil

class SettingActivity : AppCompatActivity() {
private lateinit var binding : ActivitySettingBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivitySettingBinding.inflate(layoutInflater)


binding.btnBack.setOnClickListener {
finish()
}

binding.tvLogout.setOnClickListener {
SophubUserAuthStorage.clearAuthStorage(this)
IntentUtil.moveActivity(this, SignInActivity::class.java)
Log.d("자동 로그아웃","해제")

}


setContentView(binding.root)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.example.a29th_first_semina.ui.view.sigin.SheredPreference

import android.content.Context

object SophubUserAuthStorage {

private const val STORAGE_KEY = "user_auth"
private const val USER_ID_KEY = "user_id"
private const val USER_PWD_KEY = "user_pwd"

fun getUserId(context: Context) : String {
val sharedPreferences = context.getSharedPreferences(
"${context.packageName}.$STORAGE_KEY",
Context.MODE_PRIVATE
)
return sharedPreferences.getString(USER_ID_KEY,"") ?: ""
}

fun getUserPwd(context: Context) : String {
val sharedPreferences = context.getSharedPreferences(
"${context.packageName}.$STORAGE_KEY",
Context.MODE_PRIVATE
)
return sharedPreferences.getString(USER_PWD_KEY,"") ?: ""
}

fun saveUserId(context: Context, id : String) {
val sharedPreferences = context.getSharedPreferences(
"${context.packageName}.$STORAGE_KEY",
Context.MODE_PRIVATE
)
sharedPreferences.edit()
.putString(USER_ID_KEY,id)
.apply()
}

fun saveUserPwd(context: Context, pwd : String){
val sharedPreferences = context.getSharedPreferences(
"${context.packageName}.$STORAGE_KEY",
Context.MODE_PRIVATE
)
sharedPreferences.edit()
.putString(USER_PWD_KEY,pwd)
.apply()
}

fun removeUserId(context: Context){
val sharedPreferences = context.getSharedPreferences(
"${context.packageName}.$STORAGE_KEY",
Context.MODE_PRIVATE
)
sharedPreferences.edit()
.remove(USER_ID_KEY)
.apply()
}

fun removeUserPwe(context: Context){
val sharedPreferences = context.getSharedPreferences(
"${context.packageName}.$STORAGE_KEY",
Context.MODE_PRIVATE
)
sharedPreferences.edit()
.remove(USER_PWD_KEY)
.apply()
}


fun clearAuthStorage(context: Context){
val sharedPreferences = context.getSharedPreferences(
"${context.packageName}.$STORAGE_KEY",
Context.MODE_PRIVATE
)

sharedPreferences.edit()
.clear()
.apply()
}

}
Loading