diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 987ee47..ce234d7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -7,7 +7,9 @@ + { override fun onResponse(call: Call, response: Response) { @@ -61,7 +57,7 @@ class MyProfileFragment : Fragment() { override fun onFailure(call: Call, t: Throwable) { requireContext().makeToastMessage("서버 실패") } - }) + })*/ } private fun clickLogOut() { @@ -69,14 +65,12 @@ class MyProfileFragment : Fragment() { val builder = AlertDialog.Builder(requireContext()) builder.setTitle("Go SOPT").setMessage("로그아웃 하시겠나요?") .setPositiveButton("네") { _, _ -> - MySharedPreferences.clearUser(requireContext()) + MyApplication.mySharedPreferences.clearUser() val intent = Intent(activity, LoginActivity::class.java) startActivity(intent) requireActivity().finish() - }.setNegativeButton("아니요", null).setCancelable(true) builder.show() - } } -} \ No newline at end of file +} diff --git a/app/src/main/java/org/android/go/sopt/util/MySharedPreferences.kt b/app/src/main/java/org/android/go/sopt/util/MySharedPreferences.kt new file mode 100644 index 0000000..5d8e85e --- /dev/null +++ b/app/src/main/java/org/android/go/sopt/util/MySharedPreferences.kt @@ -0,0 +1,56 @@ +package org.android.go.sopt.util + +import android.content.Context +import android.content.SharedPreferences + +class MySharedPreferences(context: Context) { + private val MY_ACCOUNT: String = "account" + private val prefs: SharedPreferences = + context.getSharedPreferences(MY_ACCOUNT, Context.MODE_PRIVATE) + + fun setUserId(input: String) { + val editor: SharedPreferences.Editor = prefs.edit() + editor.putString("MY_ID", input) + editor.commit() + } + + fun getUserId(): String { + return prefs.getString("MY_ID", "").toString() + } + + fun setUserPass(input: String) { + val editor: SharedPreferences.Editor = prefs.edit() + editor.putString("MY_PASS", input) + editor.commit() + } + + fun getUserPass(): String { + return prefs.getString("MY_PASS", "").toString() + } + + fun setUserName(input: String) { + val editor: SharedPreferences.Editor = prefs.edit() + editor.putString("MY_NAME", input) + editor.commit() + } + + fun getUserName(): String { + return prefs.getString("MY_NAME", "").toString() + } + + fun setUserSpec(input: String) { + val editor: SharedPreferences.Editor = prefs.edit() + editor.putString("MY_SPEC", input) + editor.commit() + } + + fun getUserSpec(): String { + return prefs.getString("MY_SPEC", "").toString() + } + + fun clearUser() { + val editor: SharedPreferences.Editor = prefs.edit() + editor.clear() + editor.commit() + } +}