diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index ac6b0ae..23a89bb 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -15,6 +15,7 @@ diff --git a/.idea/misc.xml b/.idea/misc.xml index 7bfef59..d5d35ec 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 99a1ca7..7883d41 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,33 +10,48 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> - + - + + + + - + - - - + + + \ No newline at end of file diff --git a/app/src/main/java/com/apusart/api/repositories/UserRepository.kt b/app/src/main/java/com/apusart/api/repositories/UserRepository.kt index c8ebe5b..21f284c 100644 --- a/app/src/main/java/com/apusart/api/repositories/UserRepository.kt +++ b/app/src/main/java/com/apusart/api/repositories/UserRepository.kt @@ -69,4 +69,14 @@ class UserRepository(private val context: Context) { val file = userService.getReference(path) return Resource.success(file.downloadUrl.await()) } + +// fun updateEmail(email: String) : Boolean { +// val currUser = Firebase.auth.currentUser +// var retValue = false +// currUser!!.updateEmail(email).addOnCompleteListener { task -> +// retValue = task.isSuccessful +// Log.d("ChangeEmailTest", "Email change: $retValue") +// } +// return retValue +// } } \ No newline at end of file diff --git a/app/src/main/java/com/apusart/evently_android/logged/profile/ProfileFragment.kt b/app/src/main/java/com/apusart/evently_android/logged/profile/ProfileFragment.kt index 17997a6..07179c4 100644 --- a/app/src/main/java/com/apusart/evently_android/logged/profile/ProfileFragment.kt +++ b/app/src/main/java/com/apusart/evently_android/logged/profile/ProfileFragment.kt @@ -59,6 +59,9 @@ class ProfileFragment: Fragment(R.layout.profile_fragment) { dialog.cancel() } + profile_page_settings_button.setOnClickListener { + startActivity(Intent(context, ProfileSettingsActivity::class.java)) + } profile_page_logout_button.setOnClickListener { alertDialog.show() diff --git a/app/src/main/java/com/apusart/evently_android/logged/profile/ProfileSettingsActivity.kt b/app/src/main/java/com/apusart/evently_android/logged/profile/ProfileSettingsActivity.kt new file mode 100644 index 0000000..2e5b2a4 --- /dev/null +++ b/app/src/main/java/com/apusart/evently_android/logged/profile/ProfileSettingsActivity.kt @@ -0,0 +1,12 @@ +package com.apusart.evently_android.logged.profile + +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import com.apusart.evently_android.R + +class ProfileSettingsActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_profile_settings) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/apusart/evently_android/logged/profile/ProfileSettingsFragment.kt b/app/src/main/java/com/apusart/evently_android/logged/profile/ProfileSettingsFragment.kt new file mode 100644 index 0000000..7d23ec9 --- /dev/null +++ b/app/src/main/java/com/apusart/evently_android/logged/profile/ProfileSettingsFragment.kt @@ -0,0 +1,45 @@ +package com.apusart.evently_android.logged.profile + +import android.os.Bundle +import android.text.InputType +import androidx.preference.EditTextPreference +import androidx.preference.Preference +import androidx.preference.PreferenceFragmentCompat +import com.apusart.api.repositories.UserRepository +import com.apusart.evently_android.R +import com.google.firebase.auth.ktx.auth +import com.google.firebase.ktx.Firebase + +class ProfileSettingsFragment : PreferenceFragmentCompat() { + + //private val userRepository = context?.let { UserRepository(it) } + + override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { + setPreferencesFromResource(R.xml.profile_settings, rootKey) + + + val userEmailPreference: EditTextPreference? = findPreference("profile_user_email") + + val firebaseEmail = Firebase.auth.currentUser?.email + userEmailPreference?.text = firebaseEmail + + userEmailPreference?.summaryProvider = Preference.SummaryProvider { preference -> + val email = preference.text + var retValue = false + if (email != firebaseEmail) { +// retValue = userRepository?.updateEmail(email) ?: false + val currUser = Firebase.auth.currentUser + currUser!!.updateEmail(email).addOnCompleteListener { task -> + retValue = task.isSuccessful + } + } + if(retValue) email + else firebaseEmail + } + userEmailPreference?.setOnBindEditTextListener { editText -> + editText.inputType = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS + } + + //Dodac to samo co wyzej dla innych parametrow usera + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_profile_settings.xml b/app/src/main/res/layout/activity_profile_settings.xml new file mode 100644 index 0000000..2679bae --- /dev/null +++ b/app/src/main/res/layout/activity_profile_settings.xml @@ -0,0 +1,30 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/profile_settings.xml b/app/src/main/res/xml/profile_settings.xml new file mode 100644 index 0000000..f68a81f --- /dev/null +++ b/app/src/main/res/xml/profile_settings.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a4ebf09..4b78cfa 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Nov 26 22:02:27 CET 2020 +#Sun Dec 13 17:23:30 CET 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip