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

E3 #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

E3 #3

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
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 24 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,48 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>
<activity android:name=".logged.profile.ProfileSettingsActivity"></activity>

<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />

<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<activity android:name=".guest.initial_activity.InitialActivity" android:noHistory="true">
<activity
android:name=".guest.initial_activity.InitialActivity"
android:noHistory="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".guest.login_activity.LoginActivity" android:theme="@style/LoginTheme" android:noHistory="true"/>
<activity android:name=".guest.register_activity.RegisterActivity" android:theme="@style/LoginTheme" android:noHistory="true"/>
<activity android:name=".logged.main.MainLoggedActivity" android:theme="@style/LoggedTheme"/>
<activity
android:name=".guest.login_activity.LoginActivity"
android:noHistory="true"
android:theme="@style/LoginTheme" />
<activity
android:name=".guest.register_activity.RegisterActivity"
android:noHistory="true"
android:theme="@style/LoginTheme" />
<activity
android:name=".logged.main.MainLoggedActivity"
android:theme="@style/LoggedTheme" />
</application>

</manifest>
10 changes: 10 additions & 0 deletions app/src/main/java/com/apusart/api/repositories/UserRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -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<EditTextPreference> { 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
}
}
30 changes: 30 additions & 0 deletions app/src/main/res/layout/activity_profile_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".logged.profile.ProfileSettingsActivity">

<TextView
android:id="@+id/profile_settings_page_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="Settings"
android:textAppearance="@style/HeadlineRoboto24Pt"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<fragment
android:id="@+id/profile_settings_page_fragment"
android:name="com.apusart.evently_android.logged.profile.ProfileSettingsFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/profile_settings_page_title" />

</androidx.constraintlayout.widget.ConstraintLayout>
31 changes: 31 additions & 0 deletions app/src/main/res/xml/profile_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

<PreferenceCategory
android:key="user_settings"
android:title="User Settings">

<EditTextPreference
android:key="profile_user_name"
android:title="Change user name"
android:summary="Michał Raszczuk" />

<EditTextPreference
android:key="profile_user_email"
android:title="Change email"
android:summary="[email protected]" />

</PreferenceCategory>

<PreferenceCategory
android:key="app_info"
android:title="App Settings" >

<Preference
android:key="app_version"
android:title="Application Version"
android:summary="1.0.0" />

</PreferenceCategory>

</PreferenceScreen>
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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