Skip to content

Fixes #99 : profile thumbnail removed, with minor UI updates and fixes #103

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

Merged
merged 1 commit into from
Jun 20, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ data class AuthData(
var fullname: String,
var email: String,
var password: String,
var thumbnail: String?,
var confirmationCode: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.github.code.gambit.databinding.ActivityMainBinding
import com.github.code.gambit.helper.file.FileUploadState
import com.github.code.gambit.ui.OnItemClickListener
import com.github.code.gambit.ui.fragment.BottomNavController
import com.github.code.gambit.ui.fragment.auth.AuthFragment
import com.github.code.gambit.ui.fragment.home.main.HomeFragment
import com.github.code.gambit.utility.SystemManager
import com.github.code.gambit.utility.extention.bottomNavHide
Expand Down Expand Up @@ -212,6 +213,12 @@ class MainActivity : AppCompatActivity(), BottomNavController {

override fun onBackPressed() {
if (!userManager.isAuthenticated()) {
val fragment =
supportFragmentManager.findFragmentById(R.id.nav_host_fragment_container)?.childFragmentManager?.fragments?.first()
if (fragment is AuthFragment && fragment.currentPage != 0) {
fragment.setPage(0)
return
}
super.onBackPressed()
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AuthFragment : Fragment(R.layout.fragment_auth) {
private lateinit var _binding: FragmentAuthBinding
private val binding get() = _binding

private val currentPage get() = binding.fragmentContainer.currentItem
val currentPage get() = binding.fragmentContainer.currentItem

private val viewModel: AuthViewModel by viewModels()

Expand Down Expand Up @@ -171,4 +171,10 @@ class AuthFragment : Fragment(R.layout.fragment_auth) {
private fun enableInteraction() {
binding.buttonSubmit.isEnabled = true
}

fun setPage(page: Int) {
if (page == 0 || page == 1) {
binding.tabLayout.getTabAt(page)?.select()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ constructor(
}

private suspend fun resetForgotPassword(userEmail: String, newPassword: String, confirmationCode: String) {
when (val res = authRepository.resetForgotPassword(AuthData("", userEmail, newPassword, null, confirmationCode))) {
when (val res = authRepository.resetForgotPassword(AuthData("", userEmail, newPassword, confirmationCode))) {
is ServiceResult.Error -> {
if (res.exception.cause is CodeMismatchException) {
postValue(AuthState.CodeMissMatch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class LoginFragment : Fragment(R.layout.fragment_login) {
if (error) {
return null
}
return AuthData("", username, password, null, null)
return AuthData("", username, password, null)
}

// validates the input fields
Expand All @@ -122,6 +122,6 @@ class LoginFragment : Fragment(R.layout.fragment_login) {
binding.root.snackbar("Validation error!!")
return null
}
return AuthData("", username, password, null, null)
return AuthData("", username, password, null)
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
package com.github.code.gambit.ui.fragment.auth

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.provider.MediaStore
import android.view.View
import androidx.activity.result.ActivityResultLauncher
import androidx.fragment.app.Fragment
import com.github.code.gambit.R
import com.github.code.gambit.databinding.FragmentSignUpBinding
import com.github.code.gambit.helper.auth.AuthData
import com.github.code.gambit.utility.SystemManager
import com.github.code.gambit.utility.extention.snackbar
import dagger.hilt.android.AndroidEntryPoint
import timber.log.Timber
import javax.inject.Inject

@AndroidEntryPoint
Expand All @@ -30,31 +25,9 @@ class SignUpFragment : Fragment(R.layout.fragment_sign_up) {
@Inject
lateinit var systemManager: SystemManager

lateinit var launcher: ActivityResultLauncher<Intent>
var profileImage: Uri? = null

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
_binding = FragmentSignUpBinding.bind(view)

binding.dpContainer.setOnClickListener {
systemManager.launchActivity(launcher, Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI))
}
}

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

private fun registerCallback() {
launcher = systemManager.requestImage(this) {
if (it != null) {
binding.profileImage.setImageURI(it)
Timber.i(it.toString())
profileImage = it
}
}
}

// validates the input fields
Expand Down Expand Up @@ -106,6 +79,6 @@ class SignUpFragment : Fragment(R.layout.fragment_sign_up) {
binding.root.snackbar("Validation error!!")
return null
}
return AuthData(fullName, userEmail, password, profileImage.toString(), null)
return AuthData(fullName, userEmail, password, null)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fun AuthSignUpOptions.Builder<*>.defaultBuilder(authData: AuthData): AuthSignUpO
mutableListOf
(
AuthUserAttribute(AuthUserAttributeKey.email(), authData.email),
AuthUserAttribute(AuthUserAttributeKey.custom(AppConstant.AUTH_ATTRIBUTE_CUSTOM_PROFILE), authData.thumbnail),
AuthUserAttribute(AuthUserAttributeKey.custom(AppConstant.AUTH_ATTRIBUTE_CUSTOM_PROFILE), ""),
AuthUserAttribute(AuthUserAttributeKey.name(), authData.fullname)
)
).build()
Expand Down
Binary file removed app/src/main/res/drawable-hdpi/ic_fb.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-hdpi/ic_gp.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-hdpi/ic_next.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-ldpi/ic_fb.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-ldpi/ic_gp.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-ldpi/ic_next.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-mdpi/ic_fb.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-mdpi/ic_gp.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-mdpi/ic_next.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-night-hdpi/ic_fb.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-night-hdpi/ic_gp.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-night-ldpi/ic_fb.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-night-ldpi/ic_gp.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-night-mdpi/ic_fb.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-night-mdpi/ic_gp.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-night-xhdpi/ic_fb.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-night-xhdpi/ic_gp.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-night-xxhdpi/ic_fb.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-night-xxhdpi/ic_gp.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-night-xxxhdpi/ic_fb.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-night-xxxhdpi/ic_gp.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-xhdpi/ic_fb.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-xhdpi/ic_gp.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-xhdpi/ic_next.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-xxhdpi/ic_fb.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-xxhdpi/ic_gp.png
Diff not rendered.
Binary file removed app/src/main/res/drawable-xxhdpi/ic_next.png
Diff not rendered.
Binary file removed app/src/main/res/drawable-xxxhdpi/ic_fb.png
Diff not rendered.
Binary file removed app/src/main/res/drawable-xxxhdpi/ic_gp.png
Diff not rendered.
Binary file removed app/src/main/res/drawable-xxxhdpi/ic_next.png
Diff not rendered.
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_next.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M10,6L8.59,7.41 13.17,12l-4.58,4.59L10,18l6,-6z"/>
</vector>
3 changes: 1 addition & 2 deletions app/src/main/res/layout/fragment_auth.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@
app:layout_anchorGravity="top|end"
android:backgroundTint="@color/login_signup_button_color"
app:icon="@drawable/ic_next"
app:iconTint="@color/raw_white"
app:iconGravity="textEnd"
app:cornerRadius="12dp"
app:iconSize="16dp"
app:iconSize="22dp"
android:layout_marginEnd="32dp"/>


Expand Down
30 changes: 1 addition & 29 deletions app/src/main/res/layout/fragment_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,34 +63,6 @@
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>

<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:weightSum="3">

<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:background="@android:color/transparent"
android:contentDescription="@string/facebook_authentication"
android:src="@drawable/ic_fb" />

<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_weight="1"
android:background="@android:color/transparent"
android:contentDescription="@string/google_authentication"
android:src="@drawable/ic_gp" />

</LinearLayout>

</LinearLayout>

<LinearLayout
Expand All @@ -100,10 +72,10 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout2"
app:layout_constraintVertical_bias="0.3"
android:layout_marginStart="16dp"
android:layout_marginBottom="32dp">


<TextView
android:id="@+id/forgot_password_text"
android:layout_width="match_parent"
Expand Down
61 changes: 5 additions & 56 deletions app/src/main/res/layout/fragment_sign_up.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,22 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:paddingTop="64dp"
android:paddingBottom="64dp"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<androidx.cardview.widget.CardView
android:id="@+id/profile_upload_image_container"
android:layout_width="64dp"
android:layout_height="64dp"
app:cardCornerRadius="32dp">
<ImageView
android:id="@+id/profile_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/profile_image"
android:scaleType="centerCrop"
android:src="@drawable/ic_default_dp" />
</androidx.cardview.widget.CardView>

<!--com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/upload_dp_fab"
style="@style/Widget.App.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/upload_a_profile_picture_optional"
android:src="@drawable/iclink" -->

<TextView
android:id="@+id/upload_dp_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="32dp"
android:text="@string/upload_a_profile_picture_optional"
android:textColor="@color/black" />
android:text="@string/create_new_account"
android:textColor="@color/black"
android:textSize="24sp"/>
</LinearLayout>


<com.google.android.material.textfield.TextInputLayout
android:id="@+id/full_name_input"
style="@style/input_theme"
Expand Down Expand Up @@ -121,35 +100,5 @@
android:layout_height="match_parent"
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>


<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:visibility="gone"
android:weightSum="3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/password_input">

<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:background="@android:color/transparent"
android:contentDescription="@string/facebook_authentication"
android:src="@drawable/ic_fb" />

<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_weight="1"
android:background="@android:color/transparent"
android:contentDescription="@string/google_authentication"
android:src="@drawable/ic_gp" />

</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<string name="forgot_password">Forgot Password?</string>
<string name="full_name">Full Name</string>
<string name="confirm_password">Confirm Password</string>
<string name="upload_a_profile_picture_optional">Upload a profile picture [Optional]</string>
<string name="user_email">User Email</string>
<string name="verification_code">Verification Code</string>
<string name="please_type_the_verification_code_send_to">Please type the verification code send to</string>
Expand Down Expand Up @@ -91,4 +90,5 @@
<string name="submit">Submit</string>
<string name="no_change">No change</string>
<string name="delete">Delete</string>
<string name="create_new_account">Create a new account</string>
</resources>