- mid commit

Took 8 hours 5 minutes
This commit is contained in:
2023-05-15 09:45:11 +01:00
parent 9079534e45
commit e5556cdb8d
43 changed files with 316 additions and 189 deletions

View File

@@ -122,6 +122,7 @@ dependencies {
implementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"
androidTestImplementation "androidx.test:runner:$testRunnerVersion"
androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
/ * Google play services */
implementation "com.google.android.gms:play-services-auth:20.4.1"
/ * Google firebase */

View File

@@ -14,7 +14,7 @@ class InsuranceFragment :
override fun setupView(binding: FragmentInsuranceBinding) {
super.setupView(binding)
viewsToHide(binding.submitIns, binding.uploadInsurance)
viewsToHide(binding.submit, binding.uploadInsurance)
}

View File

@@ -12,7 +12,7 @@ class LogbookFragment :
override fun setupView(binding: FragmentLogbookBinding) {
super.setupView(binding)
viewsToHide(binding.submitLb, binding.uploadLb)
viewsToHide(binding.submit, binding.uploadLb)
}
override fun setFields(data: Logbook) {

View File

@@ -11,7 +11,7 @@ class MotFragment : DataViewerFragment<MotViewModel, FragmentMotBinding, Mot>()
override fun setupView(binding: FragmentMotBinding) {
super.setupView(binding)
viewsToHide(binding.submitMot, binding.uploadmot)
viewsToHide(binding.submit, binding.uploadmot)
}
override fun setFields(data: Mot) {

View File

@@ -11,7 +11,7 @@ class VehicleProfileFragment :
override fun setupView(binding: FragmentVehicleSetupBinding) {
super.setupView(binding)
viewsToHide(binding.submitVehicle)
viewsToHide(binding.submit)
}
override fun setFields(data: VehicleProfile) {

View File

@@ -1,16 +1,32 @@
package h_mal.appttude.com.driver
import android.app.Activity
import android.app.Instrumentation
import android.content.Intent
import android.content.res.Resources
import android.net.Uri
import android.provider.MediaStore
import android.widget.DatePicker
import androidx.annotation.StringRes
import androidx.test.espresso.Espresso.onData
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.ViewInteraction
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.action.ViewActions.swipeDown
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.PickerActions
import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.Intents.intending
import androidx.test.espresso.intent.matcher.IntentMatchers
import androidx.test.espresso.intent.matcher.IntentMatchers.hasAction
import androidx.test.espresso.intent.matcher.IntentMatchers.isInternal
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.withId
import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.CoreMatchers.anything
import h_mal.appttude.com.driver.helpers.DataHelper
import h_mal.appttude.com.driver.helpers.DataHelper.addFilePaths
import org.hamcrest.CoreMatchers.*
import org.hamcrest.Matchers
import java.io.File
open class BaseTestRobot {
@@ -23,12 +39,12 @@ open class BaseTestRobot {
fun clickButton(resId: Int): ViewInteraction =
onView((withId(resId))).perform(ViewActions.click())
fun textView(resId: Int): ViewInteraction = onView(withId(resId))
fun matchView(resId: Int): ViewInteraction = onView(withId(resId))
fun matchText(viewInteraction: ViewInteraction, text: String): ViewInteraction = viewInteraction
.check(matches(ViewMatchers.withText(text)))
fun matchText(resId: Int, text: String): ViewInteraction = matchText(textView(resId), text)
fun matchText(resId: Int, text: String): ViewInteraction = matchText(matchView(resId), text)
fun clickListItem(listRes: Int, position: Int) {
onData(anything())
@@ -39,7 +55,49 @@ open class BaseTestRobot {
fun checkErrorOnTextEntry(resId: Int, errorMessage: String): ViewInteraction =
onView(withId(resId)).check(matches(checkErrorMessage(errorMessage)))
fun swipeDown(resId: Int): ViewInteraction =
onView(withId(resId)).perform(swipeDown())
fun getStringFromResource(@StringRes resId: Int): String =
Resources.getSystem().getString(resId)
fun selectDateInPicker(year: Int, month: Int, day: Int) {
onView(ViewMatchers.withClassName(Matchers.equalTo(DatePicker::class.java.name))).perform(
PickerActions.setDate(
year,
month,
day
)
)
}
fun selectSingleImageFromGallery(filePath: String, openSelector: () -> Unit) {
Intents.init()
// Build the result to return when the activity is launched.
val resultData = Intent()
resultData.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
resultData.data = Uri.fromFile(File(filePath))
val result = Instrumentation.ActivityResult(Activity.RESULT_OK, resultData)
// Set up result stubbing when an intent sent to image picker is seen.
intending(hasAction(Intent.ACTION_GET_CONTENT)).respondWith(result)
openSelector()
Intents.release()
}
fun selectMultipleImageFromGallery(filePaths: Array<String>, openSelector: () -> Unit) {
Intents.init()
openSelector()
// Build the result to return when the activity is launched.
val resultData = Intent()
val clipData = DataHelper.createClipData(filePaths[0])
val remainingFiles = filePaths.copyOfRange(1, filePaths.size-1)
clipData.addFilePaths(remainingFiles)
resultData.clipData = clipData
val result = Instrumentation.ActivityResult(Activity.RESULT_OK, resultData)
// Set up result stubbing when an intent sent to "contacts" is seen.
Intents.intending(IntentMatchers.toPackage("android.intent.action.PICK")).respondWith(result)
Intents.release()
}
}

View File

@@ -30,6 +30,7 @@ open class BaseUiTest<T : BaseActivity<*,*>>(
mActivityScenarioRule.onActivity {
mIdlingResource = it.getIdlingResource()!!
IdlingRegistry.getInstance().register(mIdlingResource)
afterLaunch()
}
}
@@ -57,4 +58,5 @@ open class BaseUiTest<T : BaseActivity<*,*>>(
}
open fun beforeLaunch() {}
open fun afterLaunch() {}
}

View File

@@ -1,21 +1,27 @@
package h_mal.appttude.com.driver
import androidx.test.espresso.intent.rule.IntentsRule
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.database.FirebaseDatabase
import com.google.firebase.storage.FirebaseStorage
import h_mal.appttude.com.driver.base.BaseActivity
import h_mal.appttude.com.driver.data.FirebaseAuthSource
import h_mal.appttude.com.driver.utils.GenericsHelper.getGenericClassAt
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.tasks.await
import org.junit.After
import org.junit.BeforeClass
import org.junit.Rule
open class FirebaseTest<T : BaseActivity<*,*>>(
open class FirebaseTest<T : BaseActivity<*, *>>(
activity: Class<T>,
private val registered: Boolean = false,
private val signedIn: Boolean = false
) : BaseUiTest<T>(activity) {
// @get:Rule
// val intentsRule = IntentsRule()
private val firebaseAuthSource by lazy { FirebaseAuthSource() }
private var email: String? = null

View File

@@ -1,6 +1,30 @@
package h_mal.appttude.com.driver
class FormRobot: BaseTestRobot() {
import android.net.Uri
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.matcher.ViewMatchers.withId
// fun selectImage
open class FormRobot : BaseTestRobot() {
fun submit() = clickButton(R.id.submit)
fun setDate(datePickerLaunchViewId: Int, year: Int, monthOfYear: Int, dayOfMonth: Int) {
onView(withId(datePickerLaunchViewId)).perform(click())
selectDateInPicker(year, monthOfYear, dayOfMonth)
// click ok in date picker
onView(withId(android.R.id.button1)).perform(click())
}
fun selectSingleImage(imagePickerLauncherViewId: Int, filePath: String) {
selectSingleImageFromGallery(filePath) {
onView(withId(imagePickerLauncherViewId)).perform(click())
}
// click ok in date picker
}
fun selectMultipleImage(imagePickerLauncherViewId: Int, filePaths: Array<String>) {
selectMultipleImageFromGallery(filePaths) {
onView(withId(imagePickerLauncherViewId)).perform(click())
}
}
}

View File

@@ -0,0 +1,20 @@
package h_mal.appttude.com.driver.helpers
import android.os.Environment
import java.io.File
/**
* File paths for images on device
*/
private const val BASE = "/Camera/images/"
const val PROFILE_PIC = "${BASE}driver_profile_pic.jpg"
const val INSURANCE = "${BASE}driver_insurance.jpg"
const val PRIVATE_HIRE = "${BASE}driver_license_private_hire.jpg"
const val PRIVATE_HIRE_CAR = "${BASE}driver_license_private_hire_car.jpg"
const val LOGBOOK = "${BASE}driver_logbook.jpg"
const val MOT = "${BASE}driver_mot.jpg"
const val LICENSE = "${BASE}driver_license_driver.jpg"
fun getImagePath(imageConst: String): String {
return File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), imageConst).absolutePath
}

View File

@@ -0,0 +1,24 @@
package h_mal.appttude.com.driver.helpers
import android.content.ClipData
import android.content.ClipData.Item
import android.content.ClipDescription
import android.net.Uri
import java.io.File
object DataHelper {
fun createClipItem(filePath: String) = Item(
Uri.fromFile(File(filePath)
))
fun createClipData(item: Item, mimeType: String = "text/uri-list") = ClipData(null, arrayOf(mimeType), item)
fun createClipData(filePath: String) = createClipData(createClipItem(filePath))
fun createClipData(uri: Uri) = createClipData(Item(uri))
fun ClipData.addFilePaths(filePaths: Array<String>) {
filePaths.forEach { addItem(createClipItem(it)) }
}
}

View File

@@ -8,17 +8,17 @@ class RegisterRobot : BaseTestRobot() {
fun setName(name: String) = fillEditText(R.id.name_register, name)
fun setEmail(email: String) = fillEditText(R.id.email_register, email)
fun setEmail(email: String) = fillEditText(R.id.email, email)
fun setPassword(pass: String) = fillEditText(R.id.password_top, pass)
fun setPasswordConfirm(pass: String) = fillEditText(R.id.password_bottom, pass)
fun clickLogin() = clickButton(R.id.email_sign_up)
fun clickLogin() = clickButton(R.id.submit)
fun checkNameError(err: String) = checkErrorOnTextEntry(R.id.name_register, err)
fun checkEmailError(err: String) = checkErrorOnTextEntry(R.id.email_register, err)
fun checkEmailError(err: String) = checkErrorOnTextEntry(R.id.email, err)
fun checkPasswordError(err: String) = checkErrorOnTextEntry(R.id.password_top, err)

View File

@@ -1,18 +1,17 @@
package h_mal.appttude.com.driver.robots
import h_mal.appttude.com.driver.BaseTestRobot
import h_mal.appttude.com.driver.FormRobot
import h_mal.appttude.com.driver.R
fun delete(func: DeleteRobot.() -> Unit) = DeleteRobot().apply { func() }
class DeleteRobot : BaseTestRobot() {
class DeleteRobot : FormRobot() {
fun enterEmail(email: String) = fillEditText(R.id.email_update, email)
fun enterPassword(password: String) = fillEditText(R.id.password_top, password)
fun submitDelete() = clickButton(R.id.submission_button_label)
fun submitForm(email: String, password: String) {
enterEmail(email)
enterPassword(password)
submitDelete()
submit()
}
}

View File

@@ -1,21 +1,21 @@
package h_mal.appttude.com.driver.robots
import h_mal.appttude.com.driver.BaseTestRobot
import h_mal.appttude.com.driver.FormRobot
import h_mal.appttude.com.driver.R
import h_mal.appttude.com.driver.helpers.LICENSE
import h_mal.appttude.com.driver.helpers.getImagePath
fun driversLicense(func: DriversLicenseRobot.() -> Unit) = DriversLicenseRobot().apply { func() }
class DriversLicenseRobot : BaseTestRobot() {
class DriversLicenseRobot : FormRobot() {
fun enterLicenseNumber(text: String) = fillEditText(R.id.lic_no, text)
fun enterLicenseExpiry(text: String) = fillEditText(R.id.lic_expiry, text)
fun selectImage() = clickButton(R.id.search_image)
fun clickSubmit() = clickButton(R.id.submit)
fun enterLicenseExpiry(year: Int, monthOfYear: Int, dayOfMonth: Int) = setDate(R.id.lic_expiry, year, monthOfYear, dayOfMonth)
fun selectImage() = selectSingleImage(R.id.search_image, getImagePath(LICENSE))
fun submitForm(licenseNumber: String, licenseExpiry: String) {
fun submitForm(licenseNumber: String, year: Int, monthOfYear: Int, dayOfMonth: Int) {
selectImage()
// TODO: select image in gallery
enterLicenseNumber(licenseNumber)
enterLicenseExpiry(licenseExpiry)
clickSubmit()
enterLicenseExpiry(year, monthOfYear, dayOfMonth)
submit()
}
}

View File

@@ -1,21 +1,26 @@
package h_mal.appttude.com.driver.robots
import h_mal.appttude.com.driver.BaseTestRobot
import android.text.InputType
import h_mal.appttude.com.driver.FormRobot
import h_mal.appttude.com.driver.R
fun driversProfile(func: DriversProfileRobot.() -> Unit) = DriversProfileRobot().apply { func() }
class DriversProfileRobot : BaseTestRobot() {
class DriversProfileRobot : FormRobot() {
fun enterName(name: String) = fillEditText(R.id.names_input, name)
fun enterAddress(address: String) = fillEditText(R.id.address_input, address)
fun enterPostcode(postcode: String) = fillEditText(R.id.postcode_input, postcode)
fun enterDateOfBirth(dob: String) = fillEditText(R.id.dob_input, dob)
fun enterNINumber(niNumber: String) = fillEditText(R.id.ni_number, niNumber)
fun enterDateFirstAvailable(year: Int, monthOfYear: Int, dayOfMonth: Int) = setDate(R.id.date_first, year, monthOfYear, dayOfMonth)
fun enterLicenseNumber(text: String) = fillEditText(R.id.lic_no, text)
fun enterLicenseExpiry(text: String) = fillEditText(R.id.lic_expiry, text)
fun selectImage() = clickButton(R.id.add_photo)
fun clickSubmit() = clickButton(R.id.submit_driver)
fun submitForm(licenseNumber: String, licenseExpiry: String) {
fun submitForm(name: String, address: String, postcode: String, dob: String, niNumber: String, year: Int, monthOfYear: Int, dayOfMonth: Int) {
selectImage()
// TODO: select image in gallery
enterLicenseNumber(licenseNumber)
enterLicenseExpiry(licenseExpiry)
clickSubmit()
enterName(name)
enterAddress(address)
submit()
}
}

View File

@@ -27,4 +27,5 @@ class HomeRobot : BaseTestRobot() {
fun openDriverProfile() = clickButton(R.id.driver)
fun openVehicleProfile() = clickButton(R.id.car)
fun requestProfile() = clickButton(R.id.request_driver_button)
}

View File

@@ -1,22 +1,19 @@
@file:JvmName("UpdateEmailRobotKt")
package h_mal.appttude.com.driver.robots
import h_mal.appttude.com.driver.BaseTestRobot
import h_mal.appttude.com.driver.FormRobot
import h_mal.appttude.com.driver.R
fun updateEmail(func: UpdateEmailRobot.() -> Unit) = UpdateEmailRobot().apply { func() }
class UpdateEmailRobot : BaseTestRobot() {
class UpdateEmailRobot : FormRobot() {
fun enterEmail(email: String) = fillEditText(R.id.email_update, email)
fun enterPassword(password: String) = fillEditText(R.id.password_top, password)
fun enterNewEmail(email: String) = fillEditText(R.id.new_email, email)
fun submitDelete() = clickButton(R.id.submission_button_label)
fun submitForm(email: String, password: String, newEmail: String) {
enterEmail(email)
enterPassword(password)
enterNewEmail(newEmail)
submitDelete()
submit()
}
}

View File

@@ -1,20 +1,20 @@
package h_mal.appttude.com.driver.robots
import h_mal.appttude.com.driver.BaseTestRobot
import h_mal.appttude.com.driver.FormRobot
import h_mal.appttude.com.driver.R
fun updatePassword(func: UpdatePasswordRobot.() -> Unit) = UpdatePasswordRobot().apply { func() }
class UpdatePasswordRobot : BaseTestRobot() {
class UpdatePasswordRobot : FormRobot() {
fun enterEmail(email: String) = fillEditText(R.id.email_update, email)
fun enterPassword(password: String) = fillEditText(R.id.password_top, password)
fun enterNewPassword(email: String) = fillEditText(R.id.password_bottom, email)
fun submitDelete() = clickButton(R.id.email_sign_up)
fun submitDelete() = clickButton(R.id.submit)
fun submitForm(email: String, password: String, newPassword: String) {
enterEmail(email)
enterPassword(password)
enterNewPassword(newPassword)
submitDelete()
submit()
}
}

View File

@@ -1,19 +1,18 @@
package h_mal.appttude.com.driver.robots
import h_mal.appttude.com.driver.BaseTestRobot
import h_mal.appttude.com.driver.FormRobot
import h_mal.appttude.com.driver.R
import h_mal.appttude.com.driver.helpers.PROFILE_PIC
fun updateProfile(func: UpdateProfileRobot.() -> Unit) = UpdateProfileRobot().apply { func() }
class UpdateProfileRobot : BaseTestRobot() {
class UpdateProfileRobot : FormRobot() {
fun enterName(name: String) = fillEditText(R.id.update_name, name)
fun selectImage() = clickButton(R.id.profile_img)
fun submitProfileUpdate() = clickButton(R.id.submit_update_profile)
// fun selectImage() = selectSingleImage(R.id.profile_img, PROFILE_PIC)
fun submitForm(name: String) {
selectImage()
// TODO: select image in gallery
// selectImage()
enterName(name)
submitProfileUpdate()
submit()
}
}

View File

@@ -1,8 +1,5 @@
package h_mal.appttude.com.driver.robots
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.contrib.DrawerActions
import androidx.test.espresso.matcher.ViewMatchers.withId
import h_mal.appttude.com.driver.BaseTestRobot
import h_mal.appttude.com.driver.R

View File

@@ -0,0 +1,41 @@
package h_mal.appttude.com.driver.tests.newUser
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.rule.GrantPermissionRule
import h_mal.appttude.com.driver.FirebaseTest
import h_mal.appttude.com.driver.R
import h_mal.appttude.com.driver.robots.*
import h_mal.appttude.com.driver.ui.MainActivity
import h_mal.appttude.com.driver.ui.user.LoginActivity
import org.junit.*
import org.junit.runner.RunWith
@LargeTest
@RunWith(AndroidJUnit4::class)
class SubmitNewDataActivityTest :
FirebaseTest<MainActivity>(MainActivity::class.java, registered = true, signedIn = true) {
@get:Rule var permissionRule = GrantPermissionRule.grant(android.Manifest.permission.READ_EXTERNAL_STORAGE)
@Test
fun verifyUserRegistration_validUsernameAndPassword_loggedIn() {
home {
waitFor(2500)
checkTitleExists(getResourceString(R.string.welcome_title))
requestProfile()
openDriverProfile()
}
driverScreen {
driverLicense()
}
driversLicense {
submitForm("SAMPLE8456310LTU", 2022, 10, 2)
}
waitFor(5000)
}
}

View File

@@ -37,7 +37,7 @@ class DriverProfileFragment :
}
}
addPhoto.setOnClickListener { openGalleryWithPermissionRequest() }
submitDriver.setOnClickListener { submit() }
submit.setOnClickListener { submit() }
}
override fun submit() {

View File

@@ -34,7 +34,7 @@ class InsuranceFragment :
}
}
uploadInsurance.setOnClickListener { openGalleryWithPermissionRequest() }
submitIns.setOnClickListener { submit() }
submit.setOnClickListener { submit() }
}
}

View File

@@ -17,7 +17,7 @@ class LogbookFragment :
override fun setupView(binding: FragmentLogbookBinding) = binding.run {
v5cNo.setTextOnChange { model.v5cnumber = it }
uploadLb.setOnClickListener { openGalleryWithPermissionRequest() }
submitLb.setOnClickListener { submit() }
submit.setOnClickListener { submit() }
}
override fun submit() {

View File

@@ -24,7 +24,7 @@ class MotFragment : DataSubmissionBaseFragment<MotViewModel, FragmentMotBinding,
}
uploadmot.setOnClickListener { openGalleryWithPermissionRequest() }
submitMot.setOnClickListener {
submit.setOnClickListener {
validateEditTexts(motExpiry).isTrue {
viewModel.setDataInDatabase(model, picUri)
}

View File

@@ -30,7 +30,7 @@ class VehicleProfileFragment : DataSubmissionBaseFragment
}
seizedCheckbox.setOnCheckedChangeListener { _, res -> model.isSeized = res }
submitVehicle.setOnClickListener {
submit.setOnClickListener {
validateEditTexts(
reg,
make,

View File

@@ -18,15 +18,15 @@ import org.kodein.di.generic.singleton
class DriverApplication : Application(), KodeinAware {
override fun onCreate() {
super.onCreate()
val localHost = "10.0.2.2"
FirebaseAuth.getInstance().useEmulator(localHost, 9099)
FirebaseDatabase.getInstance().useEmulator(localHost, 9000)
FirebaseStorage.getInstance().useEmulator(localHost, 9199)
}
// override fun onCreate() {
// super.onCreate()
//
// val localHost = "10.0.2.2"
//
// FirebaseAuth.getInstance().useEmulator(localHost, 9099)
// FirebaseDatabase.getInstance().useEmulator(localHost, 9000)
// FirebaseStorage.getInstance().useEmulator(localHost, 9199)
// }
// Kodein aware to initialise the classes used for DI
override val kodein = Kodein.lazy {

View File

@@ -20,6 +20,7 @@ import h_mal.appttude.com.driver.utils.PermissionsUtils
import org.kodein.di.KodeinAware
import org.kodein.di.android.x.kodein
import org.kodein.di.generic.instance
import java.io.File
abstract class BaseFragment<V : BaseViewModel, VB : ViewBinding> : Fragment(), KodeinAware {
@@ -151,10 +152,10 @@ abstract class BaseFragment<V : BaseViewModel, VB : ViewBinding> : Fragment(), K
private fun getResultsContract(): ActivityResultContract<Boolean, Any?> {
return object : ActivityResultContract<Boolean, Any?>() {
override fun createIntent(context: Context, input: Boolean): Intent {
return Intent(Intent.ACTION_PICK).apply {
type = "image/*"
putExtra(Intent.EXTRA_ALLOW_MULTIPLE, input)
}
return Intent(Intent.ACTION_GET_CONTENT)
.addCategory(Intent.CATEGORY_OPENABLE)
.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, input)
.setType("image/*")
}
override fun parseResult(resultCode: Int, intent: Intent?): Any? {

View File

@@ -12,7 +12,7 @@ class DeleteProfileFragment :
override fun setupView(binding: FragmentDeleteProfileBinding) = binding.run {
passwordTop.setEnterPressedListener { deleteUser() }
submissionButtonLabel.setOnClickListener { deleteUser() }
submit.setOnClickListener { deleteUser() }
}
private fun deleteUser() = applyBinding {

View File

@@ -12,7 +12,7 @@ class UpdateEmailFragment : BaseFragment<UpdateUserViewModel, FragmentUpdateEmai
override fun setupView(binding: FragmentUpdateEmailBinding) = binding.run {
newEmail.setEnterPressedListener { registerUser() }
submissionButtonLabel.setOnClickListener { registerUser() }
submit.setOnClickListener { registerUser() }
}
private fun registerUser() {

View File

@@ -13,7 +13,7 @@ class UpdatePasswordFragment : BaseFragment<UpdateUserViewModel, FragmentUpdateP
override fun setupView(binding: FragmentUpdatePasswordBinding) {
applyBinding {
emailUpdate.setEnterPressedListener { registerUser() }
emailSignUp.setOnClickListener { registerUser() }
submit.setOnClickListener { registerUser() }
}
}

View File

@@ -41,7 +41,7 @@ class UpdateProfileFragment : BaseFragment<UpdateUserViewModel, FragmentUpdatePr
}
}
submitUpdateProfile.setOnClickListener { submitProfileUpdate() }
submit.setOnClickListener { submitProfileUpdate() }
}
private fun submitProfileUpdate() {

View File

@@ -13,13 +13,13 @@ class RegisterFragment :
override fun setupView(binding: FragmentRegisterBinding) = binding.run {
passwordBottom.setEnterPressedListener { registerUser() }
emailSignUp.setOnClickListener { registerUser() }
submit.setOnClickListener { registerUser() }
}
private fun registerUser() {
applyBinding {
val nameString = nameRegister.validatePasswordEditText() ?: return@applyBinding
val emailText = emailRegister.validateEmailEditText() ?: return@applyBinding
val emailText = email.validateEmailEditText() ?: return@applyBinding
val passwordText = passwordTop.validatePasswordEditText() ?: return@applyBinding
val passwordTextBottom =
passwordBottom.validatePasswordEditText() ?: return@applyBinding

View File

@@ -22,12 +22,12 @@
style="@style/subheader"
android:layout_marginBottom="24dp"
android:text="@string/delete_profile_subtitle"
app:layout_constraintBottom_toTopOf="@id/til_old_email"
app:layout_constraintBottom_toTopOf="@id/til_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_old_email"
android:id="@+id/til_name"
style="@style/text_input_layout"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
@@ -47,7 +47,7 @@
style="@style/text_input_layout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/til_old_email">
app:layout_constraintTop_toBottomOf="@+id/til_name">
<EditText
android:id="@+id/password_top"
@@ -58,7 +58,7 @@
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/submission_button_label"
android:id="@+id/submit"
style="@style/TextButton.WithIcon"
android:text="@string/submit"
app:layout_constraintBottom_toBottomOf="parent"

View File

@@ -132,7 +132,7 @@
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/submit_driver"
android:id="@+id/submit"
style="@style/TextButton"
android:text="@string/submit" />
</LinearLayout>

View File

@@ -67,7 +67,7 @@
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/submit_ins"
android:id="@+id/submit"
style="@style/TextButton.WithIcon"
android:text="@string/submit"
app:layout_constraintBottom_toBottomOf="parent"

View File

@@ -55,7 +55,7 @@
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/submit_lb"
android:id="@+id/submit"
style="@style/TextButton.WithIcon"
android:text="@string/submit"
app:layout_constraintTop_toTopOf="parent"

View File

@@ -54,7 +54,7 @@
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/submit_mot"
android:id="@+id/submit"
style="@style/TextButton.WithIcon"
android:text="@string/submit"
app:layout_constraintBottom_toBottomOf="parent"

View File

@@ -3,75 +3,71 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
style="@style/constraint_container"
style="@style/parent_constraint_layout"
android:background="#73000000"
tools:context="ui.user.ForgotPasswordFragment">
<TextView
android:id="@+id/login_title_tv"
style="@style/title_text"
android:layout_width="0dp"
<com.google.android.material.button.MaterialButton
android:id="@+id/submit"
style="@style/TextButton.WithIcon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="96dp"
android:layout_marginEnd="24dp"
android:text="@string/register_label"
android:textColor="#ffffff"
android:text="@string/submit"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toBottomOf="@id/til_new_password"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.8" />
<TextView
android:id="@+id/login_title_tv"
style="@style/headerStyle"
android:layout_marginBottom="12dp"
android:text="@string/register_label"
app:layout_constraintBottom_toTopOf="@id/login_subtitle_tv"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/login_subtitle_tv"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="24dp"
style="@style/subheader"
android:layout_marginBottom="24dp"
android:text="@string/register_subtitle"
android:textColor="#ffffff"
app:layout_constraintBottom_toTopOf="@id/til_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/login_title_tv" />
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_old_email"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="24dp"
android:background="#99000000"
android:textColorHint="@android:color/white"
android:id="@+id/til_name"
style="@style/text_input_layout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/login_subtitle_tv">
app:layout_constraintBottom_toTopOf="@id/til_email">
<EditText
android:id="@+id/name_register"
style="@style/EditTextStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="@string/promt_name"
android:inputType="textPersonName"
android:autofillHints="name" />
android:autofillHints="name"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_email"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="24dp"
android:background="#99000000"
android:textColorHint="@android:color/white"
style="@style/text_input_layout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/til_old_email">
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/til_name">
<EditText
android:id="@+id/email_register"
android:id="@+id/email"
style="@style/EditTextStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -81,74 +77,31 @@
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_password_top"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="24dp"
android:background="#99000000"
android:textColorHint="@android:color/white"
android:id="@+id/til_new_password"
style="@style/text_input_layout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/til_email">
<EditText
android:id="@+id/password_top"
style="@style/EditTextStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="@string/prompt_password"
android:inputType="textPassword"
android:autofillHints="password" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_password_bottom"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="24dp"
android:background="#99000000"
android:textColorHint="@android:color/white"
android:id="@+id/til_new_password_again"
style="@style/text_input_layout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/til_password_top">
app:layout_constraintTop_toBottomOf="@+id/til_new_password">
<EditText
android:id="@+id/password_bottom"
style="@style/EditTextStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="@string/prompt_password"
android:inputType="textPassword"
android:autofillHints="password" />
</com.google.android.material.textfield.TextInputLayout>
<androidx.cardview.widget.CardView
android:id="@+id/email_sign_up"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginStart="24dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="64dp"
android:backgroundTint="@color/colour_one"
android:enabled="false"
app:cardCornerRadius="24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/til_password_bottom">
<TextView
android:id="@+id/submission_button_label"
style="@style/button_inner_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/submit"
android:textColor="@android:color/white" />
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -23,14 +23,14 @@
android:text="@string/update_email_subtitle"
style="@style/subheader"
android:layout_marginBottom="24dp"
app:layout_constraintBottom_toTopOf="@id/til_old_email"
app:layout_constraintBottom_toTopOf="@id/til_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_old_email"
android:id="@+id/til_name"
style="@style/text_input_layout"
android:layout_marginTop="48dp"
app:layout_constraintEnd_toEndOf="parent"
@@ -79,7 +79,7 @@
<com.google.android.material.button.MaterialButton
style="@style/TextButton.WithIcon"
android:text="@string/submit"
android:id="@+id/submission_button_label"
android:id="@+id/submit"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_bias="0.8"

View File

@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
style="@style/parent_constraint_layout"
tools:context="ui.user.ForgotPasswordFragment">
tools:context="ui.update.UpdatePasswordFragment">
<TextView
android:id="@+id/login_title_tv"
@@ -22,14 +22,14 @@
style="@style/subheader"
android:layout_marginBottom="24dp"
android:text="@string/update_password_subtitle"
app:layout_constraintBottom_toTopOf="@id/til_old_email"
app:layout_constraintBottom_toTopOf="@id/til_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_old_email"
android:id="@+id/til_name"
style="@style/text_input_layout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@@ -50,7 +50,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/til_old_email">
app:layout_constraintTop_toBottomOf="@+id/til_name">
<EditText
android:id="@+id/password_top"
@@ -76,7 +76,7 @@
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/email_sign_up"
android:id="@+id/submit"
style="@style/TextButton.WithIcon"
android:text="@string/submit"
app:layout_constraintTop_toTopOf="parent"

View File

@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
style="@style/parent_constraint_layout"
tools:context=".ui.user.ForgotPasswordFragment">
tools:context=".ui.update.UpdateProfileFragment">
<TextView
android:id="@+id/login_title_tv"
@@ -67,7 +67,7 @@
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/submit_update_profile"
android:id="@+id/submit"
style="@style/TextButton.WithIcon"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@@ -134,9 +134,8 @@
android:padding="12dp"
android:textSize="18sp" />
<com.google.android.material.button.MaterialButton
android:id="@+id/submit_vehicle"
android:id="@+id/submit"
style="@style/TextButton.WithIcon"
android:text="@string/submit"
android:layout_marginBottom="48dp"