mirror of
https://github.com/hmalik144/Driver.git
synced 2026-01-31 02:41:46 +00:00
Circleci project setup (#7)
This commit is contained in:
58
.circleci/config.yml
Normal file
58
.circleci/config.yml
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
# Use the latest 2.1 version of CircleCI pipeline process engine.
|
||||||
|
# See: https://circleci.com/docs/2.0/configuration-reference
|
||||||
|
# For a detailed guide to building and testing on Android, read the docs:
|
||||||
|
# https://circleci.com/docs/2.0/language-android/ for more details.
|
||||||
|
version: 2.1
|
||||||
|
|
||||||
|
# Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects.
|
||||||
|
# See: https://circleci.com/docs/2.0/orb-intro/
|
||||||
|
orbs:
|
||||||
|
android: circleci/android@1.0.3
|
||||||
|
|
||||||
|
# Define a job to be invoked later in a workflow.
|
||||||
|
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
|
||||||
|
jobs:
|
||||||
|
# Below is the definition of your job to build and test your app, you can rename and customize it as you want.
|
||||||
|
build-and-test:
|
||||||
|
# These next lines define the Android machine image executor.
|
||||||
|
# See: https://circleci.com/docs/2.0/executor-types/
|
||||||
|
executor:
|
||||||
|
name: android/android-machine
|
||||||
|
|
||||||
|
# Add steps to the job
|
||||||
|
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
|
||||||
|
steps:
|
||||||
|
# Checkout the code as the first step.
|
||||||
|
- checkout
|
||||||
|
# Setup files for build.
|
||||||
|
- run:
|
||||||
|
name: Setup variables for build
|
||||||
|
command: |
|
||||||
|
echo "$GOOGLE_SERVICES_KEY" > "app/google-services.json"
|
||||||
|
# echo "$RELEASE_KEYSTORE_BASE64" | base64 --decode > "android/app/release_keystore.jks"
|
||||||
|
- run:
|
||||||
|
name: Grant execute permission for gradlew
|
||||||
|
command: |
|
||||||
|
chmod +x gradlew
|
||||||
|
# The next step will run the unit tests
|
||||||
|
- android/run-tests:
|
||||||
|
test-command: ./gradlew testDriverDebugUnitTest --continue
|
||||||
|
|
||||||
|
# Then start the emulator and run the Instrumentation tests!
|
||||||
|
# - android/start-emulator-and-run-tests:
|
||||||
|
# test-command: ./gradlew connectedDebugAndroidTest
|
||||||
|
# system-image: system-images;android-25;google_apis;x86
|
||||||
|
|
||||||
|
# And finally run the release build
|
||||||
|
# - run:
|
||||||
|
# name: Assemble release build
|
||||||
|
# command: |
|
||||||
|
# ./gradlew assembleDriverRelease
|
||||||
|
|
||||||
|
# Invoke jobs via workflows
|
||||||
|
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
|
||||||
|
workflows:
|
||||||
|
sample: # This is the name of the workflow, feel free to change it to better match your workflow.
|
||||||
|
# Inside the workflow, you define the jobs you want to run.
|
||||||
|
jobs:
|
||||||
|
- build-and-test
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -7,6 +7,8 @@
|
|||||||
/.idea/modules.xml
|
/.idea/modules.xml
|
||||||
/.idea/workspace.xml
|
/.idea/workspace.xml
|
||||||
/.idea/navEditor.xml
|
/.idea/navEditor.xml
|
||||||
|
/.idea/misc.xml
|
||||||
|
/.idea/assetWizardSettings.xml
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/build
|
/build
|
||||||
/captures
|
/captures
|
||||||
|
|||||||
16
.idea/codeStyles/Project.xml
generated
16
.idea/codeStyles/Project.xml
generated
@@ -1,22 +1,6 @@
|
|||||||
<component name="ProjectCodeStyleConfiguration">
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
<code_scheme name="Project" version="173">
|
<code_scheme name="Project" version="173">
|
||||||
<JetCodeStyleSettings>
|
<JetCodeStyleSettings>
|
||||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
|
||||||
<value>
|
|
||||||
<package name="java.util" alias="false" withSubpackages="false" />
|
|
||||||
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
|
||||||
<package name="io.ktor" alias="false" withSubpackages="true" />
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
<option name="PACKAGES_IMPORT_LAYOUT">
|
|
||||||
<value>
|
|
||||||
<package name="" alias="false" withSubpackages="true" />
|
|
||||||
<package name="java" alias="false" withSubpackages="true" />
|
|
||||||
<package name="javax" alias="false" withSubpackages="true" />
|
|
||||||
<package name="kotlin" alias="false" withSubpackages="true" />
|
|
||||||
<package name="" alias="true" withSubpackages="true" />
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
</JetCodeStyleSettings>
|
</JetCodeStyleSettings>
|
||||||
<codeStyleSettings language="XML">
|
<codeStyleSettings language="XML">
|
||||||
|
|||||||
6
.idea/compiler.xml
generated
Normal file
6
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="17" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
7
.idea/dictionaries/h_mal.xml
generated
Normal file
7
.idea/dictionaries/h_mal.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<component name="ProjectDictionaryState">
|
||||||
|
<dictionary name="h_mal">
|
||||||
|
<words>
|
||||||
|
<w>viewmodel</w>
|
||||||
|
</words>
|
||||||
|
</dictionary>
|
||||||
|
</component>
|
||||||
4
.idea/gradle.xml
generated
4
.idea/gradle.xml
generated
@@ -4,16 +4,16 @@
|
|||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="testRunner" value="PLATFORM" />
|
<option name="testRunner" value="GRADLE" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleJvm" value="Android Studio java home" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
<option value="$PROJECT_DIR$/app" />
|
<option value="$PROJECT_DIR$/app" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
<option name="resolveModulePerSourceSet" value="false" />
|
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="IllegalIdentifier" enabled="false" level="ERROR" enabled_by_default="false" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
12
.idea/runConfigurations.xml
generated
12
.idea/runConfigurations.xml
generated
@@ -1,12 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="RunConfigurationProducerService">
|
|
||||||
<option name="ignoredProducers">
|
|
||||||
<set>
|
|
||||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
|
||||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
|
||||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
@@ -13,61 +13,99 @@ repositories {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def relStorePassword = System.getenv("RELEASE_STORE_PASSWORD")
|
||||||
|
def relKeyPassword = System.getenv("RELEASE_KEY_PASSWORD")
|
||||||
|
def relKeyAlias = System.getenv("RELEASE_KEY_ALIAS")
|
||||||
|
def relStoreFile = System.getenv("RELEASE_KEYSTORE")
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 31
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "h_mal.appttude.com.driver"
|
applicationId "h_mal.appttude.com"
|
||||||
minSdkVersion 24
|
minSdkVersion 24
|
||||||
targetSdkVersion 28
|
targetSdkVersion 31
|
||||||
versionCode 6
|
versionCode 6
|
||||||
versionName "1.6"
|
versionName "1.6"
|
||||||
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
|
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signingConfigs {
|
||||||
|
release {
|
||||||
|
storePassword relStorePassword
|
||||||
|
keyPassword relKeyPassword
|
||||||
|
keyAlias relKeyAlias
|
||||||
|
// storeFile file(relStoreFile)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled false
|
// signingConfig signingConfigs.release
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileOptions {
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
|
||||||
}
|
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = "1.8"
|
jvmTarget = "1.8"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flavorDimensions "Default"
|
||||||
|
productFlavors {
|
||||||
|
driver {
|
||||||
|
applicationIdSuffix ".driver"
|
||||||
|
versionCode 6
|
||||||
|
versionName "1.0.5"
|
||||||
|
}
|
||||||
|
admin {
|
||||||
|
applicationIdSuffix ".driverAdmin"
|
||||||
|
versionCode 4
|
||||||
|
versionName "0.0.5"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sourceSets {
|
||||||
|
driver {
|
||||||
|
manifest {
|
||||||
|
srcFile 'src/driver/AndroidManifest.xml'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
admin {
|
||||||
|
manifest {
|
||||||
|
srcFile 'src/driver_admin/AndroidManifest.xml'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
implementation "androidx.appcompat:appcompat:1.0.0"
|
implementation "androidx.appcompat:appcompat:1.4.2"
|
||||||
implementation "com.google.android.material:material:1.0.0"
|
implementation "com.google.android.material:material:1.6.0"
|
||||||
implementation "androidx.cardview:cardview:1.0.0"
|
implementation "androidx.cardview:cardview:1.0.0"
|
||||||
implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
||||||
implementation "androidx.exifinterface:exifinterface:1.0.0"
|
implementation "androidx.exifinterface:exifinterface:1.3.6"
|
||||||
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
|
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
|
||||||
implementation "androidx.fragment:fragment-ktx:1.2.5"
|
implementation "androidx.fragment:fragment-ktx:1.4.0"
|
||||||
implementation "androidx.activity:activity-ktx:1.2.0"
|
implementation "androidx.activity:activity-ktx:1.4.0"
|
||||||
implementation "androidx.recyclerview:recyclerview:1.1.0"
|
implementation "androidx.recyclerview:recyclerview:1.2.1"
|
||||||
implementation "androidx.navigation:navigation-fragment-ktx:2.3.3"
|
implementation "androidx.navigation:navigation-fragment-ktx:2.5.3"
|
||||||
implementation "androidx.navigation:navigation-ui-ktx:2.3.3"
|
implementation "androidx.navigation:navigation-ui-ktx:2.5.3"
|
||||||
implementation "androidx.drawerlayout:drawerlayout:1.1.1"
|
implementation "androidx.drawerlayout:drawerlayout:1.1.1"
|
||||||
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
|
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
|
||||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0"
|
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
|
||||||
implementation 'androidx.viewpager:viewpager:1.0.0'
|
implementation 'androidx.viewpager:viewpager:1.0.0'
|
||||||
testImplementation "junit:junit:4.12"
|
testImplementation "junit:junit:4.13.2"
|
||||||
androidTestImplementation "androidx.test.ext:junit:1.1.1"
|
androidTestImplementation "androidx.test.ext:junit:1.1.5"
|
||||||
androidTestImplementation "androidx.test.espresso:espresso-core:3.1.0"
|
androidTestImplementation "androidx.test.espresso:espresso-core:3.5.1"
|
||||||
androidTestImplementation "androidx.test:rules:1.1.1"
|
androidTestImplementation "androidx.test:rules:1.5.0"
|
||||||
|
implementation 'androidx.test.espresso:espresso-idling-resource:3.5.1'
|
||||||
|
|
||||||
implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
||||||
// Google play services
|
// Google play services
|
||||||
implementation "com.google.android.gms:play-services-auth:15.0.1"
|
implementation "com.google.android.gms:play-services-auth:20.4.1"
|
||||||
// Google firebase
|
// Google firebase
|
||||||
def firebaseVer = "16.0.1"
|
def firebaseVer = "20.1.0"
|
||||||
implementation "com.google.firebase:firebase-core:$firebaseVer"
|
implementation "com.google.firebase:firebase-core:$firebaseVer"
|
||||||
implementation "com.google.firebase:firebase-auth:$firebaseVer"
|
implementation "com.google.firebase:firebase-auth:21.0.0"
|
||||||
implementation "com.google.firebase:firebase-storage:$firebaseVer"
|
implementation "com.google.firebase:firebase-storage:$firebaseVer"
|
||||||
implementation "com.google.firebase:firebase-database:$firebaseVer"
|
implementation "com.google.firebase:firebase-database:$firebaseVer"
|
||||||
// Photoviewer
|
// Photoviewer
|
||||||
@@ -75,9 +113,9 @@ dependencies {
|
|||||||
/* Picasso photo loader */
|
/* Picasso photo loader */
|
||||||
implementation "com.squareup.picasso:picasso:2.71828"
|
implementation "com.squareup.picasso:picasso:2.71828"
|
||||||
/* Gson */
|
/* Gson */
|
||||||
implementation "com.google.code.gson:gson:2.3.1"
|
implementation "com.google.code.gson:gson:2.8.9"
|
||||||
/* coroutines support for firebase operations */
|
/* coroutines support for firebase operations */
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.1.1"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.1"
|
||||||
|
|
||||||
// Circle Image View
|
// Circle Image View
|
||||||
implementation "com.mikhaellopez:circularimageview:4.2.0"
|
implementation "com.mikhaellopez:circularimageview:4.2.0"
|
||||||
@@ -89,4 +127,8 @@ dependencies {
|
|||||||
|
|
||||||
/* Image Carousal */
|
/* Image Carousal */
|
||||||
implementation 'com.synnapps:carouselview:0.1.5'
|
implementation 'com.synnapps:carouselview:0.1.5'
|
||||||
|
|
||||||
|
/ * Glide */
|
||||||
|
implementation 'com.github.bumptech.glide:glide:4.12.0'
|
||||||
|
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package h_mal.appttude.com.driver.Objects
|
package h_mal.appttude.com.objects
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
package h_mal.appttude.com.driver.Objects
|
package h_mal.appttude.com.objects
|
||||||
|
|
||||||
import h_mal.appttude.com.driver.model.DriversLicenseObject
|
import h_mal.appttude.com.model.*
|
||||||
import h_mal.appttude.com.driver.model.MotObject
|
|
||||||
import h_mal.appttude.com.driver.model.PrivateHireObject
|
|
||||||
import h_mal.appttude.com.driver.model.VehicleProfileObject
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class ArchiveObject {
|
class ArchiveObject {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package h_mal.appttude.com.driver.Objects
|
package h_mal.appttude.com.objects
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package h_mal.appttude.com.driver.Objects
|
package h_mal.appttude.com.objects
|
||||||
|
|
||||||
import h_mal.appttude.com.driver.Objects.WholeObject.DriverProfile
|
import h_mal.appttude.com.objects.wholeObject.DriverProfile
|
||||||
import h_mal.appttude.com.driver.Objects.WholeObject.VehicleProfile
|
import h_mal.appttude.com.objects.wholeObject.VehicleProfile
|
||||||
|
|
||||||
|
|
||||||
class WholeDriverObject {
|
class WholeDriverObject {
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package h_mal.appttude.com.driver.Objects.WholeObject
|
package h_mal.appttude.com.objects.wholeObject
|
||||||
|
|
||||||
import h_mal.appttude.com.driver.model.DriverProfileObject
|
import h_mal.appttude.com.model.DriverProfileObject
|
||||||
import h_mal.appttude.com.driver.model.DriversLicenseObject
|
import h_mal.appttude.com.model.DriversLicenseObject
|
||||||
import h_mal.appttude.com.driver.model.PrivateHireObject
|
import h_mal.appttude.com.model.PrivateHireObject
|
||||||
|
|
||||||
|
|
||||||
class DriverProfile {
|
class DriverProfile {
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package h_mal.appttude.com.driver.Objects.WholeObject
|
package h_mal.appttude.com.objects.wholeObject
|
||||||
|
|
||||||
import android.os.Parcel
|
import android.os.Parcel
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import h_mal.appttude.com.driver.Objects.WholeDriverObject
|
import h_mal.appttude.com.objects.WholeDriverObject
|
||||||
|
|
||||||
|
|
||||||
class MappedObject : Parcelable {
|
class MappedObject : Parcelable {
|
||||||
@@ -28,6 +28,7 @@ class MappedObject : Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@JvmField
|
||||||
val CREATOR: Parcelable.Creator<MappedObject?> = object : Parcelable.Creator<MappedObject?> {
|
val CREATOR: Parcelable.Creator<MappedObject?> = object : Parcelable.Creator<MappedObject?> {
|
||||||
override fun createFromParcel(`in`: Parcel): MappedObject? {
|
override fun createFromParcel(`in`: Parcel): MappedObject? {
|
||||||
return MappedObject(`in`)
|
return MappedObject(`in`)
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package h_mal.appttude.com.driver.Objects.WholeObject
|
package h_mal.appttude.com.objects.wholeObject
|
||||||
|
|
||||||
import h_mal.appttude.com.driver.Objects.InsuranceObject
|
import h_mal.appttude.com.model.InsuranceObject
|
||||||
import h_mal.appttude.com.driver.Objects.LogbookObject
|
import h_mal.appttude.com.model.LogbookObject
|
||||||
import h_mal.appttude.com.driver.Objects.PrivateHireVehicleObject
|
import h_mal.appttude.com.model.PrivateHireVehicleObject
|
||||||
import h_mal.appttude.com.driver.model.MotObject
|
import h_mal.appttude.com.model.MotObject
|
||||||
import h_mal.appttude.com.driver.model.VehicleProfileObject
|
import h_mal.appttude.com.model.VehicleProfileObject
|
||||||
|
|
||||||
|
|
||||||
class VehicleProfile {
|
class VehicleProfile {
|
||||||
@@ -1,37 +1,20 @@
|
|||||||
package h_mal.appttude.com.driver.SuperUser
|
package h_mal.appttude.com.ui
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
|
||||||
import android.util.DisplayMetrics
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.ImageView
|
import h_mal.appttude.com.objects.wholeObject.MappedObject
|
||||||
import android.widget.TextView
|
import h_mal.appttude.com.R
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import h_mal.appttude.com.driver.Global.FirebaseClass
|
|
||||||
import h_mal.appttude.com.driver.Global.SetApprovalDialog
|
|
||||||
import h_mal.appttude.com.driver.ui.driver.MainActivity
|
|
||||||
import h_mal.appttude.com.driver.Objects.ArchiveObject
|
|
||||||
import h_mal.appttude.com.driver.Objects.WholeObject.MappedObject
|
|
||||||
import h_mal.appttude.com.driver.R
|
|
||||||
import h_mal.appttude.com.driver.ui.driver.vehicleprofile.InsuranceFragment
|
|
||||||
import h_mal.appttude.com.driver.ui.driver.driverprofile.DriverLicenseFragment
|
|
||||||
import h_mal.appttude.com.driver.ui.driver.driverprofile.DriverProfileFragment
|
|
||||||
import h_mal.appttude.com.driver.ui.driver.driverprofile.PrivateHireLicenseFragment
|
|
||||||
import h_mal.appttude.com.driver.ui.driver.vehicleprofile.LogbookFragment
|
|
||||||
import h_mal.appttude.com.driver.ui.driver.vehicleprofile.MotFragment
|
|
||||||
import h_mal.appttude.com.driver.ui.driver.vehicleprofile.PrivateHireVehicleFragment
|
|
||||||
import h_mal.appttude.com.driver.ui.driver.vehicleprofile.VehicleProfileFragment
|
|
||||||
|
|
||||||
|
|
||||||
class ApprovalListAdapter(
|
class ApprovalListAdapter(
|
||||||
val activity: Activity,
|
private val activity: Activity,
|
||||||
objects: Array<MappedObject>
|
objects: Array<MappedObject?>
|
||||||
): ArrayAdapter<MappedObject?>(activity, 0, objects) {
|
): ArrayAdapter<MappedObject?>(activity, 0, objects) {
|
||||||
|
|
||||||
var mappedObject: MappedObject = objects[0]
|
var mappedObject: MappedObject? = objects[0]
|
||||||
|
|
||||||
var names: Array<String> = arrayOf(
|
var names: Array<String> = arrayOf(
|
||||||
"Driver Profile",
|
"Driver Profile",
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package h_mal.appttude.com.driver.SuperUser
|
package h_mal.appttude.com.ui
|
||||||
|
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package h_mal.appttude.com.driver.SuperUser
|
package h_mal.appttude.com.ui
|
||||||
|
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
@@ -12,16 +12,15 @@ import com.google.firebase.database.DataSnapshot
|
|||||||
import com.google.firebase.database.DatabaseError
|
import com.google.firebase.database.DatabaseError
|
||||||
import com.google.firebase.database.DatabaseReference
|
import com.google.firebase.database.DatabaseReference
|
||||||
import com.google.firebase.database.ValueEventListener
|
import com.google.firebase.database.ValueEventListener
|
||||||
import h_mal.appttude.com.driver.ui.driver.MainActivity
|
import h_mal.appttude.com.objects.WholeDriverObject
|
||||||
import h_mal.appttude.com.driver.Objects.WholeDriverObject
|
import h_mal.appttude.com.objects.wholeObject.MappedObject
|
||||||
import h_mal.appttude.com.driver.Objects.WholeObject.MappedObject
|
import h_mal.appttude.com.R
|
||||||
import h_mal.appttude.com.driver.R
|
import kotlinx.android.synthetic.admin.fragment_home_super_user.*
|
||||||
import kotlinx.android.synthetic.main.fragment_home_super_user.*
|
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
class homeSuperUserFragment : Fragment() {
|
class HomeSuperUserFragment : Fragment() {
|
||||||
var users: DatabaseReference? = null
|
var users: DatabaseReference? = null
|
||||||
var mappedObjectList: MutableList<MappedObject>? = null
|
var mappedObjectList: MutableList<MappedObject>? = null
|
||||||
private var sharedPreferences: SharedPreferences? = null
|
private var sharedPreferences: SharedPreferences? = null
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
package h_mal.appttude.com.driver.ui.driver
|
package h_mal.appttude.com.ui
|
||||||
|
|
||||||
|
|
||||||
import android.Manifest
|
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.graphics.drawable.Drawable
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.ImageView
|
|
||||||
import androidx.core.view.GravityCompat
|
import androidx.core.view.GravityCompat
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
@@ -16,18 +13,11 @@ import androidx.navigation.ui.setupActionBarWithNavController
|
|||||||
import androidx.navigation.ui.setupWithNavController
|
import androidx.navigation.ui.setupWithNavController
|
||||||
import com.google.android.material.navigation.NavigationView
|
import com.google.android.material.navigation.NavigationView
|
||||||
import com.google.firebase.auth.FirebaseUser
|
import com.google.firebase.auth.FirebaseUser
|
||||||
import com.squareup.picasso.Picasso.LoadedFrom
|
import h_mal.appttude.com.R
|
||||||
import com.squareup.picasso.Target
|
import h_mal.appttude.com.base.BaseActivity
|
||||||
import h_mal.appttude.com.driver.Global.ApprovalsClass
|
import h_mal.appttude.com.dialogs.ExitDialog.displayExitDialog
|
||||||
import h_mal.appttude.com.driver.Global.ArchiveClass
|
import h_mal.appttude.com.utils.setGlideImage
|
||||||
import h_mal.appttude.com.driver.Global.ImageViewClass
|
import h_mal.appttude.com.viewmodels.MainViewModel
|
||||||
import h_mal.appttude.com.driver.R
|
|
||||||
import h_mal.appttude.com.driver.base.BaseActivity
|
|
||||||
import h_mal.appttude.com.driver.dialogs.ExitDialog.displayExitDialog
|
|
||||||
import h_mal.appttude.com.driver.ui.user.LoginActivity
|
|
||||||
import h_mal.appttude.com.driver.utils.ActivityIntentBuilder.createIntent
|
|
||||||
import h_mal.appttude.com.driver.utils.setPicassoImage
|
|
||||||
import h_mal.appttude.com.driver.viewmodels.MainViewModel
|
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
import kotlinx.android.synthetic.main.app_bar_main.*
|
import kotlinx.android.synthetic.main.app_bar_main.*
|
||||||
import kotlinx.android.synthetic.main.nav_header_main.view.*
|
import kotlinx.android.synthetic.main.nav_header_main.view.*
|
||||||
@@ -47,6 +37,7 @@ class MainActivity : BaseActivity<MainViewModel>(),
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
setSupportActionBar(toolbar)
|
setSupportActionBar(toolbar)
|
||||||
|
supportActionBar?.setDisplayShowTitleEnabled(false)
|
||||||
navController = findNavController(R.id.container)
|
navController = findNavController(R.id.container)
|
||||||
|
|
||||||
appBarConfiguration = AppBarConfiguration(navController.graph, drawer_layout)
|
appBarConfiguration = AppBarConfiguration(navController.graph, drawer_layout)
|
||||||
@@ -70,7 +61,7 @@ class MainActivity : BaseActivity<MainViewModel>(),
|
|||||||
drawer_layout.closeDrawer(GravityCompat.START)
|
drawer_layout.closeDrawer(GravityCompat.START)
|
||||||
} else {
|
} else {
|
||||||
val navHostFragment = supportFragmentManager.findFragmentById(R.id.container)
|
val navHostFragment = supportFragmentManager.findFragmentById(R.id.container)
|
||||||
navHostFragment?.childFragmentManager?.backStackEntryCount?.takeIf { it > 1 }?.let {
|
navHostFragment?.childFragmentManager?.backStackEntryCount?.takeIf { it >= 1 }?.let {
|
||||||
return super.onBackPressed()
|
return super.onBackPressed()
|
||||||
}
|
}
|
||||||
displayExitDialog()
|
displayExitDialog()
|
||||||
@@ -90,14 +81,12 @@ class MainActivity : BaseActivity<MainViewModel>(),
|
|||||||
val header: View = nav_view.getHeaderView(0)
|
val header: View = nav_view.getHeaderView(0)
|
||||||
header.driver_email.text = user.email
|
header.driver_email.text = user.email
|
||||||
header.driver_name.text = user.displayName
|
header.driver_name.text = user.displayName
|
||||||
header.profileImage.setPicassoImage(user.photoUrl)
|
header.profileImage.setGlideImage(user.photoUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupLogoutInDrawer(){
|
private fun setupLogoutInDrawer(){
|
||||||
logout.setOnClickListener {
|
logout.setOnClickListener {
|
||||||
getViewModel().logOut()
|
getViewModel().logOut()
|
||||||
startActivity(createIntent<LoginActivity>())
|
|
||||||
finish()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package h_mal.appttude.com.driver.SuperUser
|
package h_mal.appttude.com.ui
|
||||||
|
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@@ -12,10 +12,9 @@ import android.widget.LinearLayout
|
|||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.squareup.picasso.Picasso
|
import com.squareup.picasso.Picasso
|
||||||
import h_mal.appttude.com.driver.ui.driver.MainActivity
|
import h_mal.appttude.com.objects.UserObject
|
||||||
import h_mal.appttude.com.driver.Objects.UserObject
|
import h_mal.appttude.com.objects.wholeObject.MappedObject
|
||||||
import h_mal.appttude.com.driver.Objects.WholeObject.MappedObject
|
import h_mal.appttude.com.R
|
||||||
import h_mal.appttude.com.driver.R
|
|
||||||
|
|
||||||
|
|
||||||
class RecyclerViewAdapter constructor(var context: Context?, var objects: List<MappedObject>?) :
|
class RecyclerViewAdapter constructor(var context: Context?, var objects: List<MappedObject>?) :
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package h_mal.appttude.com.driver.SuperUser
|
package h_mal.appttude.com.ui
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
@@ -7,8 +7,8 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.GridView
|
import android.widget.GridView
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import h_mal.appttude.com.driver.Objects.WholeObject.MappedObject
|
import h_mal.appttude.com.objects.wholeObject.MappedObject
|
||||||
import h_mal.appttude.com.driver.R
|
import h_mal.appttude.com.R
|
||||||
|
|
||||||
|
|
||||||
class UserMainFragment : Fragment() {
|
class UserMainFragment : Fragment() {
|
||||||
@@ -20,8 +20,8 @@ class UserMainFragment : Fragment() {
|
|||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
val view: View = inflater.inflate(R.layout.fragment_user_main, container, false)
|
val view: View = inflater.inflate(R.layout.fragment_user_main, container, false)
|
||||||
Log.i("UserMain", "onCreateView: height = " + view.height)
|
Log.i("UserMain", "onCreateView: height = " + view.height)
|
||||||
val mappedObject: MappedObject = requireArguments().getParcelable<MappedObject>("mapped")
|
val mappedObject: MappedObject? = requireArguments().getParcelable<MappedObject>("mapped")
|
||||||
activity?.title = mappedObject.wholeDriverObject?.user_details?.profileName
|
activity?.title = mappedObject?.wholeDriverObject?.user_details?.profileName
|
||||||
|
|
||||||
val listView: GridView = view.findViewById(R.id.approvals_list)
|
val listView: GridView = view.findViewById(R.id.approvals_list)
|
||||||
listView.adapter = ApprovalListAdapter(requireActivity(), arrayOf(mappedObject))
|
listView.adapter = ApprovalListAdapter(requireActivity(), arrayOf(mappedObject))
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:src="@drawable/ic_archive_black_24dp"
|
android:src="@drawable/ic_archive_black_24dp"
|
||||||
android:tint="@color/colour_three" />
|
app:tint="@color/colour_three" />
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
@@ -3,8 +3,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".SuperUser.homeSuperUserFragment">
|
tools:context=".ui.HomeSuperUserFragment">
|
||||||
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/recycler_view"
|
android:id="@+id/recycler_view"
|
||||||
17
app/src/admin/res/layout/fragment_user_main.xml
Normal file
17
app/src/admin/res/layout/fragment_user_main.xml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".ui.UserMainFragment">
|
||||||
|
|
||||||
|
<GridView
|
||||||
|
android:id="@+id/approvals_list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:numColumns="2"
|
||||||
|
android:rowCount="4"
|
||||||
|
android:stretchMode="columnWidth"
|
||||||
|
tools:listitem="@layout/approval_list_grid_item"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
75
app/src/admin/res/layout/list_item_layout.xml
Normal file
75
app/src/admin/res/layout/list_item_layout.xml
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
<?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="wrap_content"
|
||||||
|
android:background="@color/colour_nine">
|
||||||
|
|
||||||
|
<com.mikhaellopez.circularimageview.CircularImageView
|
||||||
|
android:id="@+id/driverPic"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_marginLeft="24dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:layout_marginBottom="24dp"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
app:civ_border_width="3dp"
|
||||||
|
app:civ_shadow_radius="1dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:src="@drawable/choice_img_round" />
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/approval_iv"
|
||||||
|
android:layout_width="10dp"
|
||||||
|
android:layout_height="10dp"
|
||||||
|
android:layout_marginRight="3dp"
|
||||||
|
android:layout_marginTop="3dp"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/driverPic"
|
||||||
|
app:layout_constraintRight_toRightOf="@id/driverPic"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
tools:src="@android:drawable/presence_online" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/driver_no"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="24dp"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/driverPic"
|
||||||
|
tools:text="T22" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginLeft="24dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/driverPic"
|
||||||
|
app:layout_constraintLeft_toRightOf="@id/driverPic"
|
||||||
|
app:layout_constraintRight_toLeftOf="@id/driver_no"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/driverPic">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/username_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:text="Haider Malik" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/emailaddress_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="11sp"
|
||||||
|
tools:text="h.malik144.au@gmail.com" />
|
||||||
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
40
app/src/androidTest/java/h_mal/appttude/com/BaseTestRobot.kt
Normal file
40
app/src/androidTest/java/h_mal/appttude/com/BaseTestRobot.kt
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package h_mal.appttude.com
|
||||||
|
|
||||||
|
import android.content.res.Resources
|
||||||
|
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.assertion.ViewAssertions
|
||||||
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||||
|
import org.hamcrest.CoreMatchers.*
|
||||||
|
|
||||||
|
open class BaseTestRobot {
|
||||||
|
|
||||||
|
fun fillEditText(resId: Int, text: String): ViewInteraction =
|
||||||
|
onView(withId(resId)).perform(ViewActions.replaceText(text), ViewActions.closeSoftKeyboard())
|
||||||
|
|
||||||
|
fun clickButton(resId: Int): ViewInteraction = onView((withId(resId))).perform(ViewActions.click())
|
||||||
|
|
||||||
|
fun textView(resId: Int): ViewInteraction = onView(withId(resId))
|
||||||
|
|
||||||
|
fun matchText(viewInteraction: ViewInteraction, text: String): ViewInteraction = viewInteraction
|
||||||
|
.check(ViewAssertions.matches(ViewMatchers.withText(text)))
|
||||||
|
|
||||||
|
fun matchText(resId: Int, text: String): ViewInteraction = matchText(textView(resId), text)
|
||||||
|
|
||||||
|
fun clickListItem(listRes: Int, position: Int) {
|
||||||
|
onData(anything())
|
||||||
|
.inAdapterView(allOf(withId(listRes)))
|
||||||
|
.atPosition(position).perform(ViewActions.click())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun checkErrorOnTextEntry(resId: Int, errorMessage: String): ViewInteraction =
|
||||||
|
onView(withId(resId)).check(matches(checkErrorMessage(errorMessage)))
|
||||||
|
|
||||||
|
fun getStringFromResource(@StringRes resId: Int): String = Resources.getSystem().getString(resId)
|
||||||
|
|
||||||
|
}
|
||||||
38
app/src/androidTest/java/h_mal/appttude/com/BaseUiTest.kt
Normal file
38
app/src/androidTest/java/h_mal/appttude/com/BaseUiTest.kt
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package h_mal.appttude.com
|
||||||
|
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.test.espresso.IdlingRegistry
|
||||||
|
import androidx.test.rule.ActivityTestRule
|
||||||
|
import h_mal.appttude.com.espresso.IdlingResourceClass
|
||||||
|
import org.junit.AfterClass
|
||||||
|
import org.junit.BeforeClass
|
||||||
|
import org.junit.Ignore
|
||||||
|
import org.junit.Rule
|
||||||
|
|
||||||
|
abstract class BaseUiTest<T : AppCompatActivity> {
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
abstract fun getApplicationClass(): Class<T>
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
var mActivityTestRule = ActivityTestRule(getApplicationClass())
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@BeforeClass
|
||||||
|
@JvmStatic
|
||||||
|
fun setUp() {
|
||||||
|
IdlingRegistry.getInstance().register(IdlingResourceClass.countingIdlingResource)
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
@JvmStatic
|
||||||
|
fun tearDown() {
|
||||||
|
IdlingRegistry.getInstance().unregister(IdlingResourceClass.countingIdlingResource)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getResourceString(@StringRes stringRes: Int): String {
|
||||||
|
return mActivityTestRule.activity.getString(stringRes)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package h_mal.appttude.com
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.EditText
|
||||||
|
import com.google.android.material.textfield.TextInputLayout
|
||||||
|
import org.hamcrest.Description
|
||||||
|
import org.hamcrest.Matcher
|
||||||
|
import org.hamcrest.TypeSafeMatcher
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Matcher for testing error of TextInputLayout
|
||||||
|
*/
|
||||||
|
fun checkErrorMessage(expectedErrorText: String): Matcher<View?>? {
|
||||||
|
return object : TypeSafeMatcher<View?>() {
|
||||||
|
override fun matchesSafely(view: View?): Boolean {
|
||||||
|
if (view is EditText) {
|
||||||
|
return view.error.toString() == expectedErrorText
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view !is TextInputLayout) return false
|
||||||
|
|
||||||
|
val error = view.error ?: return false
|
||||||
|
return expectedErrorText == error.toString()
|
||||||
|
}
|
||||||
|
override fun describeTo(d: Description?) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.support.test.InstrumentationRegistry;
|
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instrumented test, which will execute on an Android device.
|
|
||||||
*
|
|
||||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
|
||||||
*/
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class ExampleInstrumentedTest {
|
|
||||||
@Test
|
|
||||||
public void useAppContext() {
|
|
||||||
// Context of the app under test.
|
|
||||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
|
||||||
|
|
||||||
assertEquals("h_mal.appttude.com.driver", appContext.getPackageName());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver;
|
|
||||||
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import androidx.test.rule.ActivityTestRule;
|
|
||||||
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import h_mal.appttude.com.driver.ui.driver.HomeFragment;
|
|
||||||
import h_mal.appttude.com.driver.ui.driver.MainActivity;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
|
|
||||||
public class MainActivityTest {
|
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ActivityTestRule<MainActivity> activityActivityTestRule = new ActivityTestRule<MainActivity>(MainActivity.class);
|
|
||||||
|
|
||||||
|
|
||||||
private MainActivity mainActivity = null;
|
|
||||||
private HomeFragment hdf;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
mainActivity = activityActivityTestRule.getActivity();
|
|
||||||
|
|
||||||
hdf = new HomeFragment();
|
|
||||||
mainActivity.getSupportFragmentManager().beginTransaction().replace(R.id.container, hdf).commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testViews(){
|
|
||||||
View view = hdf.getView().findViewById(R.id.driver);
|
|
||||||
|
|
||||||
assertNotNull(view);
|
|
||||||
|
|
||||||
// Bundle bundle = new Bundle();
|
|
||||||
// bundle.putInt("selectedListItem", 0);
|
|
||||||
// FragmentFactory factory = new FragmentFactory();
|
|
||||||
// homeDriverFragment hdf = new homeDriverFragment();
|
|
||||||
//
|
|
||||||
// launchInContainer(hdf.getClass(), bundle, factory);
|
|
||||||
// Espresso.onView(ViewMatchers.withId(2131231038)).check(ViewAssertions.matches(ViewMatchers.withText("Hello World!")));
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void TearDown() throws Exception{
|
|
||||||
mainActivity = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.base
|
|
||||||
|
|
||||||
import org.junit.Assert.*
|
|
||||||
|
|
||||||
class BaseActivityTest{
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,199 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.user;
|
|
||||||
|
|
||||||
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.ViewParent;
|
|
||||||
|
|
||||||
import androidx.test.espresso.ViewInteraction;
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
import androidx.test.filters.LargeTest;
|
|
||||||
import androidx.test.rule.ActivityTestRule;
|
|
||||||
|
|
||||||
import org.hamcrest.Description;
|
|
||||||
import org.hamcrest.Matcher;
|
|
||||||
import org.hamcrest.TypeSafeMatcher;
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import h_mal.appttude.com.driver.R;
|
|
||||||
import h_mal.appttude.com.driver.ui.user.LoginActivity;
|
|
||||||
|
|
||||||
import static androidx.test.espresso.Espresso.onView;
|
|
||||||
import static androidx.test.espresso.action.ViewActions.*;
|
|
||||||
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
|
||||||
import static androidx.test.espresso.matcher.ViewMatchers.*;
|
|
||||||
import static org.hamcrest.Matchers.allOf;
|
|
||||||
import static org.hamcrest.Matchers.is;
|
|
||||||
|
|
||||||
@LargeTest
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class EspressoTestTwo {
|
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ActivityTestRule<LoginActivity> mActivityTestRule = new ActivityTestRule<>(LoginActivity.class);
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void espressoTestTwo() {
|
|
||||||
// Added a sleep statement to match the app's execution delay.
|
|
||||||
// The recommended way to handle such scenarios is to use Espresso idling resources:
|
|
||||||
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
|
|
||||||
try {
|
|
||||||
Thread.sleep(7000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewInteraction appCompatEditText = onView(
|
|
||||||
allOf(withId(R.id.email),
|
|
||||||
childAtPosition(
|
|
||||||
childAtPosition(
|
|
||||||
withId(R.id.fields_holder),
|
|
||||||
0),
|
|
||||||
0),
|
|
||||||
isDisplayed()));
|
|
||||||
appCompatEditText.perform(replaceText("h.malik144.au@gmail.com"), closeSoftKeyboard());
|
|
||||||
|
|
||||||
ViewInteraction appCompatEditText2 = onView(
|
|
||||||
allOf(withId(R.id.password),
|
|
||||||
childAtPosition(
|
|
||||||
childAtPosition(
|
|
||||||
withId(R.id.fields_holder),
|
|
||||||
1),
|
|
||||||
0),
|
|
||||||
isDisplayed()));
|
|
||||||
appCompatEditText2.perform(replaceText("crack167"), closeSoftKeyboard());
|
|
||||||
|
|
||||||
ViewInteraction appCompatEditText3 = onView(
|
|
||||||
allOf(withId(R.id.password), withText("crack167"),
|
|
||||||
childAtPosition(
|
|
||||||
childAtPosition(
|
|
||||||
withId(R.id.fields_holder),
|
|
||||||
1),
|
|
||||||
0),
|
|
||||||
isDisplayed()));
|
|
||||||
appCompatEditText3.perform(pressImeActionButton());
|
|
||||||
|
|
||||||
// Added a sleep statement to match the app's execution delay.
|
|
||||||
// The recommended way to handle such scenarios is to use Espresso idling resources:
|
|
||||||
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
|
|
||||||
try {
|
|
||||||
Thread.sleep(7000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewInteraction button = onView(
|
|
||||||
allOf(withId(R.id.driver),
|
|
||||||
childAtPosition(
|
|
||||||
childAtPosition(
|
|
||||||
withId(R.id.container),
|
|
||||||
0),
|
|
||||||
0),
|
|
||||||
isDisplayed()));
|
|
||||||
button.check(matches(isDisplayed()));
|
|
||||||
|
|
||||||
// Added a sleep statement to match the app's execution delay.
|
|
||||||
// The recommended way to handle such scenarios is to use Espresso idling resources:
|
|
||||||
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
|
|
||||||
try {
|
|
||||||
Thread.sleep(7000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewInteraction appCompatImageButton = onView(
|
|
||||||
allOf(withContentDescription("Open navigation drawer"),
|
|
||||||
childAtPosition(
|
|
||||||
allOf(withId(R.id.toolbar),
|
|
||||||
childAtPosition(
|
|
||||||
withClassName(is("android.support.design.widget.AppBarLayout")),
|
|
||||||
0)),
|
|
||||||
1),
|
|
||||||
isDisplayed()));
|
|
||||||
appCompatImageButton.perform(click());
|
|
||||||
|
|
||||||
ViewInteraction cardView = onView(
|
|
||||||
allOf(withId(R.id.car),
|
|
||||||
childAtPosition(
|
|
||||||
childAtPosition(
|
|
||||||
withId(R.id.container),
|
|
||||||
1),
|
|
||||||
1),
|
|
||||||
isDisplayed()));
|
|
||||||
cardView.perform(click());
|
|
||||||
|
|
||||||
ViewInteraction cardView2 = onView(
|
|
||||||
allOf(withId(R.id.vehicle_prof),
|
|
||||||
childAtPosition(
|
|
||||||
childAtPosition(
|
|
||||||
withId(R.id.container),
|
|
||||||
1),
|
|
||||||
0),
|
|
||||||
isDisplayed()));
|
|
||||||
cardView2.perform(click());
|
|
||||||
|
|
||||||
pressBack();
|
|
||||||
|
|
||||||
ViewInteraction appCompatButton = onView(
|
|
||||||
allOf(withId(R.id.driver), withText("Driver Profile"),
|
|
||||||
childAtPosition(
|
|
||||||
childAtPosition(
|
|
||||||
withId(R.id.container),
|
|
||||||
1),
|
|
||||||
0),
|
|
||||||
isDisplayed()));
|
|
||||||
appCompatButton.perform(click());
|
|
||||||
|
|
||||||
ViewInteraction cardView3 = onView(
|
|
||||||
allOf(withId(R.id.driver_prof),
|
|
||||||
childAtPosition(
|
|
||||||
childAtPosition(
|
|
||||||
withId(R.id.container),
|
|
||||||
1),
|
|
||||||
0),
|
|
||||||
isDisplayed()));
|
|
||||||
cardView3.perform(click());
|
|
||||||
|
|
||||||
pressBack();
|
|
||||||
|
|
||||||
ViewInteraction cardView4 = onView(
|
|
||||||
allOf(withId(R.id.private_hire),
|
|
||||||
childAtPosition(
|
|
||||||
childAtPosition(
|
|
||||||
withId(R.id.container),
|
|
||||||
1),
|
|
||||||
1),
|
|
||||||
isDisplayed()));
|
|
||||||
cardView4.perform(click());
|
|
||||||
|
|
||||||
ViewInteraction appCompatButton2 = onView(
|
|
||||||
allOf(withId(android.R.id.button1), withText("View/Edit"),
|
|
||||||
childAtPosition(
|
|
||||||
childAtPosition(
|
|
||||||
withClassName(is("android.widget.ScrollView")),
|
|
||||||
0),
|
|
||||||
3)));
|
|
||||||
appCompatButton2.perform(scrollTo(), click());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Matcher<View> childAtPosition(
|
|
||||||
final Matcher<View> parentMatcher, final int position) {
|
|
||||||
|
|
||||||
return new TypeSafeMatcher<View>() {
|
|
||||||
@Override
|
|
||||||
public void describeTo(Description description) {
|
|
||||||
description.appendText("Child at position " + position + " in parent ");
|
|
||||||
parentMatcher.describeTo(description);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matchesSafely(View view) {
|
|
||||||
ViewParent parent = view.getParent();
|
|
||||||
return parent instanceof ViewGroup && parentMatcher.matches(parent)
|
|
||||||
&& view.equals(((ViewGroup) parent).getChildAt(position));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.user;
|
|
||||||
|
|
||||||
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.ViewParent;
|
|
||||||
|
|
||||||
import androidx.test.espresso.ViewInteraction;
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
import androidx.test.filters.LargeTest;
|
|
||||||
import androidx.test.rule.ActivityTestRule;
|
|
||||||
|
|
||||||
import org.hamcrest.Description;
|
|
||||||
import org.hamcrest.Matcher;
|
|
||||||
import org.hamcrest.TypeSafeMatcher;
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import h_mal.appttude.com.driver.R;
|
|
||||||
import h_mal.appttude.com.driver.ui.user.LoginActivity;
|
|
||||||
|
|
||||||
import static androidx.test.espresso.Espresso.onView;
|
|
||||||
import static androidx.test.espresso.action.ViewActions.*;
|
|
||||||
import static androidx.test.espresso.matcher.ViewMatchers.*;
|
|
||||||
import static org.hamcrest.Matchers.allOf;
|
|
||||||
import static org.hamcrest.Matchers.is;
|
|
||||||
|
|
||||||
@LargeTest
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class LoginActivityTest {
|
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ActivityTestRule<LoginActivity> mActivityTestRule = new ActivityTestRule<>(LoginActivity.class);
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void loginActivityTest() {
|
|
||||||
// Added a sleep statement to match the app's execution delay.
|
|
||||||
// The recommended way to handle such scenarios is to use Espresso idling resources:
|
|
||||||
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
|
|
||||||
try {
|
|
||||||
Thread.sleep(7000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewInteraction appCompatEditText = onView(
|
|
||||||
allOf(withId(R.id.email),
|
|
||||||
childAtPosition(
|
|
||||||
childAtPosition(
|
|
||||||
withId(R.id.fields_holder),
|
|
||||||
0),
|
|
||||||
0),
|
|
||||||
isDisplayed()));
|
|
||||||
appCompatEditText.perform(replaceText("h.malik144.au@gmail.com"), closeSoftKeyboard());
|
|
||||||
|
|
||||||
// Added a sleep statement to match the app's execution delay.
|
|
||||||
// The recommended way to handle such scenarios is to use Espresso idling resources:
|
|
||||||
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
|
|
||||||
try {
|
|
||||||
Thread.sleep(7000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewInteraction appCompatEditText2 = onView(
|
|
||||||
allOf(withId(R.id.password),
|
|
||||||
childAtPosition(
|
|
||||||
childAtPosition(
|
|
||||||
withId(R.id.fields_holder),
|
|
||||||
1),
|
|
||||||
0),
|
|
||||||
isDisplayed()));
|
|
||||||
appCompatEditText2.perform(replaceText("crack167"), closeSoftKeyboard());
|
|
||||||
|
|
||||||
// ViewInteraction appCompatButton = onView(
|
|
||||||
// allOf(withId(R.id.email_sign_in_button), withText("Sign in"),
|
|
||||||
// childAtPosition(
|
|
||||||
// allOf(withId(R.id.email_login_form),
|
|
||||||
// childAtPosition(
|
|
||||||
// withClassName(is("android.widget.RelativeLayout")),
|
|
||||||
// 0)),
|
|
||||||
// 1),
|
|
||||||
// isDisplayed()));
|
|
||||||
// appCompatButton.perform(click());
|
|
||||||
|
|
||||||
// Added a sleep statement to match the app's execution delay.
|
|
||||||
// The recommended way to handle such scenarios is to use Espresso idling resources:
|
|
||||||
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
|
|
||||||
try {
|
|
||||||
Thread.sleep(7000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ViewInteraction textView = onView(
|
|
||||||
// allOf(withText("Choice Minicabs"),
|
|
||||||
// childAtPosition(
|
|
||||||
// allOf(withId(R.id.toolbar),
|
|
||||||
// childAtPosition(
|
|
||||||
// IsInstanceOf.<View>instanceOf(android.widget.LinearLayout.class),
|
|
||||||
// 0)),
|
|
||||||
// 1),
|
|
||||||
// isDisplayed()));
|
|
||||||
// textView.check(matches(isDisplayed()));
|
|
||||||
|
|
||||||
// Added a sleep statement to match the app's execution delay.
|
|
||||||
// The recommended way to handle such scenarios is to use Espresso idling resources:
|
|
||||||
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
|
|
||||||
try {
|
|
||||||
Thread.sleep(7000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewInteraction appCompatButton2 = onView(
|
|
||||||
allOf(withId(R.id.driver), withText("Driver Profile"),
|
|
||||||
childAtPosition(
|
|
||||||
childAtPosition(
|
|
||||||
withId(R.id.container),
|
|
||||||
1),
|
|
||||||
0),
|
|
||||||
isDisplayed()));
|
|
||||||
appCompatButton2.perform(click());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Matcher<View> childAtPosition(
|
|
||||||
final Matcher<View> parentMatcher, final int position) {
|
|
||||||
|
|
||||||
return new TypeSafeMatcher<View>() {
|
|
||||||
@Override
|
|
||||||
public void describeTo(Description description) {
|
|
||||||
description.appendText("Child at position " + position + " in parent ");
|
|
||||||
parentMatcher.describeTo(description);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matchesSafely(View view) {
|
|
||||||
ViewParent parent = view.getParent();
|
|
||||||
return parent instanceof ViewGroup && parentMatcher.matches(parent)
|
|
||||||
&& view.equals(((ViewGroup) parent).getChildAt(position));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package h_mal.appttude.com.robots
|
||||||
|
|
||||||
|
import h_mal.appttude.com.BaseTestRobot
|
||||||
|
import h_mal.appttude.com.R
|
||||||
|
|
||||||
|
fun home(func: HomeRobot.() -> Unit) = HomeRobot().apply { func() }
|
||||||
|
class HomeRobot: BaseTestRobot() {
|
||||||
|
|
||||||
|
fun checkTitleExists(title: String) = matchText(R.id.prova_title_tv, title)
|
||||||
|
|
||||||
|
fun clickLogin() = clickButton(R.id.email_sign_in_button)
|
||||||
|
|
||||||
|
fun clickRegister() = clickButton(R.id.register_button)
|
||||||
|
|
||||||
|
fun clickForgotPassword() = clickButton(R.id.forgot)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package h_mal.appttude.com.robots
|
||||||
|
|
||||||
|
import h_mal.appttude.com.BaseTestRobot
|
||||||
|
import h_mal.appttude.com.R
|
||||||
|
|
||||||
|
|
||||||
|
fun login(func: LoginRobot.() -> Unit) = LoginRobot().apply { func() }
|
||||||
|
class LoginRobot: BaseTestRobot() {
|
||||||
|
|
||||||
|
fun setEmail(email: String) = fillEditText(R.id.email, email);
|
||||||
|
|
||||||
|
fun setPassword(pass: String) = fillEditText(R.id.password, pass)
|
||||||
|
|
||||||
|
fun clickLogin() = clickButton(R.id.email_sign_in_button)
|
||||||
|
|
||||||
|
fun clickRegister() = clickButton(R.id.register_button)
|
||||||
|
|
||||||
|
fun clickForgotPassword() = clickButton(R.id.forgot)
|
||||||
|
|
||||||
|
fun checkEmailError(err: String) = checkErrorOnTextEntry(R.id.email, err)
|
||||||
|
|
||||||
|
fun checkPasswordError(err: String) = checkErrorOnTextEntry(R.id.password, err)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package h_mal.appttude.com.robots
|
||||||
|
|
||||||
|
import h_mal.appttude.com.BaseTestRobot
|
||||||
|
import h_mal.appttude.com.R
|
||||||
|
|
||||||
|
fun register(func: RegisterRobot.() -> Unit) = RegisterRobot().apply { func() }
|
||||||
|
class RegisterRobot: BaseTestRobot() {
|
||||||
|
|
||||||
|
fun setName(name: String) = fillEditText(R.id.name_register, name)
|
||||||
|
|
||||||
|
fun setEmail(email: String) = fillEditText(R.id.email_register, 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 checkNameError(err: String) = checkErrorOnTextEntry(R.id.name_register, err)
|
||||||
|
|
||||||
|
fun checkEmailError(err: String) = checkErrorOnTextEntry(R.id.email_register, err)
|
||||||
|
|
||||||
|
fun checkPasswordError(err: String) = checkErrorOnTextEntry(R.id.password_top, err)
|
||||||
|
|
||||||
|
fun checkPasswordConfirmError(err: String) = checkErrorOnTextEntry(R.id.password_bottom, err)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package h_mal.appttude.com.tests
|
||||||
|
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import androidx.test.filters.LargeTest
|
||||||
|
import androidx.test.rule.ActivityTestRule
|
||||||
|
import com.google.firebase.auth.FirebaseAuth
|
||||||
|
import h_mal.appttude.com.BaseUiTest
|
||||||
|
import h_mal.appttude.com.R
|
||||||
|
import h_mal.appttude.com.robots.home
|
||||||
|
import h_mal.appttude.com.ui.user.LoginActivity
|
||||||
|
import h_mal.appttude.com.robots.login
|
||||||
|
import h_mal.appttude.com.robots.register
|
||||||
|
import org.junit.*
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
|
||||||
|
@LargeTest
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class LoginActivityTest: BaseUiTest<LoginActivity>() {
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
override fun getApplicationClass() = LoginActivity::class.java
|
||||||
|
|
||||||
|
@After
|
||||||
|
fun afterTest(){
|
||||||
|
FirebaseAuth.getInstance().signOut()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun verifyUserLogin_validUsernameAndPassword_loggedIn() {
|
||||||
|
login {
|
||||||
|
setEmail("test-user@testuserdriver.com")
|
||||||
|
setPassword("Password1234")
|
||||||
|
clickLogin()
|
||||||
|
}
|
||||||
|
home {
|
||||||
|
checkTitleExists(getResourceString(R.string.welcome_title))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
37
app/src/driver/AndroidManifest.xml
Normal file
37
app/src/driver/AndroidManifest.xml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<application android:icon="@mipmap/ic_launcher"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round">
|
||||||
|
<activity
|
||||||
|
android:name="h_mal.appttude.com.ui.user.LoginActivity"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar.User"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name="h_mal.appttude.com.ui.MainActivity"
|
||||||
|
android:configChanges="orientation|screenSize"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar" />
|
||||||
|
<activity
|
||||||
|
android:name="h_mal.appttude.com.ui.update.UpdateActivity"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar.Update" />
|
||||||
|
<provider
|
||||||
|
android:name="androidx.core.content.FileProvider"
|
||||||
|
android:authorities="h_mal.appttude.com.driver"
|
||||||
|
android:exported="false"
|
||||||
|
android:grantUriPermissions="true">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
|
android:resource="@xml/file_paths" />
|
||||||
|
</provider>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
||||||
@@ -1,19 +1,16 @@
|
|||||||
package h_mal.appttude.com.driver.ui.driver
|
package h_mal.appttude.com.ui
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import h_mal.appttude.com.driver.R
|
import androidx.fragment.app.Fragment
|
||||||
import h_mal.appttude.com.driver.base.BaseFragment
|
import h_mal.appttude.com.R
|
||||||
import h_mal.appttude.com.driver.utils.navigateTo
|
import h_mal.appttude.com.base.BaseFragment
|
||||||
import h_mal.appttude.com.driver.viewmodels.DriverLicenseViewModel
|
import h_mal.appttude.com.utils.navigateTo
|
||||||
|
import h_mal.appttude.com.viewmodels.DriverLicenseViewModel
|
||||||
|
|
||||||
import kotlinx.android.synthetic.main.fragment_driver_overall.*
|
import kotlinx.android.synthetic.main.fragment_driver_overall.*
|
||||||
|
|
||||||
class DriverOverallFragment : BaseFragment<DriverLicenseViewModel>() {
|
class DriverOverallFragment : Fragment(R.layout.fragment_driver_overall) {
|
||||||
|
|
||||||
private val viewmodel: DriverLicenseViewModel by getFragmentViewModel()
|
|
||||||
override fun getViewModel(): DriverLicenseViewModel = viewmodel
|
|
||||||
override fun getLayoutId(): Int = R.layout.fragment_driver_overall
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
61
app/src/driver/java/h_mal/appttude/com/ui/HomeFragment.kt
Normal file
61
app/src/driver/java/h_mal/appttude/com/ui/HomeFragment.kt
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
package h_mal.appttude.com.ui
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import h_mal.appttude.com.R
|
||||||
|
import h_mal.appttude.com.base.DataSubmissionBaseFragment
|
||||||
|
import h_mal.appttude.com.data.DRIVER
|
||||||
|
import h_mal.appttude.com.utils.hide
|
||||||
|
import h_mal.appttude.com.utils.navigateTo
|
||||||
|
import h_mal.appttude.com.utils.show
|
||||||
|
import h_mal.appttude.com.viewmodels.RoleViewModel
|
||||||
|
import kotlinx.android.synthetic.main.driver_profile_request.*
|
||||||
|
|
||||||
|
import kotlinx.android.synthetic.main.fragment_home_driver.*
|
||||||
|
import kotlinx.android.synthetic.main.home_buttons_container.*
|
||||||
|
import kotlinx.android.synthetic.main.home_buttons_container.driver
|
||||||
|
|
||||||
|
|
||||||
|
class HomeFragment : DataSubmissionBaseFragment<RoleViewModel, String>(R.layout.fragment_home_driver) {
|
||||||
|
|
||||||
|
private val viewmodel: RoleViewModel by getFragmentViewModel()
|
||||||
|
override fun getViewModel(): RoleViewModel = viewmodel
|
||||||
|
override var model = String()
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
viewmodel.getDataFromDatabase()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSuccess(data: Any?) {
|
||||||
|
super.onSuccess(data)
|
||||||
|
if (data == DRIVER){
|
||||||
|
loadDriver()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
loadNonDriver()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun loadNonDriver(){
|
||||||
|
home_buttons_container.hide()
|
||||||
|
profile_request_container.show()
|
||||||
|
|
||||||
|
request_driver_button.setOnClickListener {
|
||||||
|
viewmodel.setDataInDatabase(DRIVER)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun loadDriver(){
|
||||||
|
home_buttons_container.show()
|
||||||
|
profile_request_container.hide()
|
||||||
|
|
||||||
|
driver.setOnClickListener {
|
||||||
|
view?.navigateTo(R.id.to_driverOverallFragment)
|
||||||
|
}
|
||||||
|
car.setOnClickListener {
|
||||||
|
view?.navigateTo(R.id.to_vehicleOverallFragment)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
101
app/src/driver/java/h_mal/appttude/com/ui/MainActivity.kt
Normal file
101
app/src/driver/java/h_mal/appttude/com/ui/MainActivity.kt
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
package h_mal.appttude.com.ui
|
||||||
|
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.MenuItem
|
||||||
|
import android.view.View
|
||||||
|
import androidx.core.view.GravityCompat
|
||||||
|
import androidx.navigation.NavController
|
||||||
|
import androidx.navigation.findNavController
|
||||||
|
import androidx.navigation.ui.AppBarConfiguration
|
||||||
|
import androidx.navigation.ui.navigateUp
|
||||||
|
import androidx.navigation.ui.setupActionBarWithNavController
|
||||||
|
import androidx.navigation.ui.setupWithNavController
|
||||||
|
import com.google.android.material.navigation.NavigationView
|
||||||
|
import com.google.firebase.auth.FirebaseUser
|
||||||
|
import h_mal.appttude.com.R
|
||||||
|
import h_mal.appttude.com.base.BaseActivity
|
||||||
|
import h_mal.appttude.com.dialogs.ExitDialog.displayExitDialog
|
||||||
|
import h_mal.appttude.com.utils.setGlideImage
|
||||||
|
import h_mal.appttude.com.viewmodels.MainViewModel
|
||||||
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
|
import kotlinx.android.synthetic.main.app_bar_main.*
|
||||||
|
import kotlinx.android.synthetic.main.nav_header_main.view.*
|
||||||
|
|
||||||
|
|
||||||
|
class MainActivity : BaseActivity<MainViewModel>(),
|
||||||
|
NavigationView.OnNavigationItemSelectedListener {
|
||||||
|
|
||||||
|
private val vm by createLazyViewModel<MainViewModel>()
|
||||||
|
override fun getViewModel(): MainViewModel = vm
|
||||||
|
override val layoutId: Int = R.layout.activity_main
|
||||||
|
|
||||||
|
lateinit var navController: NavController
|
||||||
|
lateinit var appBarConfiguration: AppBarConfiguration
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
setSupportActionBar(toolbar)
|
||||||
|
supportActionBar?.setDisplayShowTitleEnabled(false)
|
||||||
|
navController = findNavController(R.id.container)
|
||||||
|
|
||||||
|
appBarConfiguration = AppBarConfiguration(navController.graph, drawer_layout)
|
||||||
|
nav_view.setupWithNavController(navController)
|
||||||
|
setupActionBarWithNavController(navController, appBarConfiguration)
|
||||||
|
|
||||||
|
getViewModel().getUserDetails()
|
||||||
|
setupLogoutInDrawer()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSupportNavigateUp(): Boolean {
|
||||||
|
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setTitle(title: CharSequence) {
|
||||||
|
toolbar.title = title
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed() {
|
||||||
|
if (drawer_layout.isDrawerOpen(GravityCompat.START)) {
|
||||||
|
drawer_layout.closeDrawer(GravityCompat.START)
|
||||||
|
} else {
|
||||||
|
val navHostFragment = supportFragmentManager.findFragmentById(R.id.container)
|
||||||
|
navHostFragment?.childFragmentManager?.backStackEntryCount?.takeIf { it >= 1 }?.let {
|
||||||
|
return super.onBackPressed()
|
||||||
|
}
|
||||||
|
displayExitDialog()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSuccess(data: Any?) {
|
||||||
|
super.onSuccess(data)
|
||||||
|
when(data){
|
||||||
|
is FirebaseUser -> {
|
||||||
|
setupDrawer(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupDrawer(user: FirebaseUser) {
|
||||||
|
val header: View = nav_view.getHeaderView(0)
|
||||||
|
header.driver_email.text = user.email
|
||||||
|
header.driver_name.text = user.displayName
|
||||||
|
header.profileImage.setGlideImage(user.photoUrl)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupLogoutInDrawer(){
|
||||||
|
logout.setOnClickListener {
|
||||||
|
getViewModel().logOut()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNavigationItemSelected(item: MenuItem): Boolean {
|
||||||
|
// Handle navigation view item clicks here.
|
||||||
|
when (item.itemId) {
|
||||||
|
R.id.nav_user_settings -> { }
|
||||||
|
}
|
||||||
|
drawer_layout.closeDrawer(GravityCompat.START)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +1,16 @@
|
|||||||
package h_mal.appttude.com.driver.ui.driver
|
package h_mal.appttude.com.ui
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import h_mal.appttude.com.driver.R
|
import androidx.fragment.app.Fragment
|
||||||
import h_mal.appttude.com.driver.base.BaseFragment
|
import h_mal.appttude.com.R
|
||||||
import h_mal.appttude.com.driver.utils.navigateTo
|
import h_mal.appttude.com.base.BaseFragment
|
||||||
import h_mal.appttude.com.driver.viewmodels.DriverLicenseViewModel
|
import h_mal.appttude.com.utils.navigateTo
|
||||||
|
import h_mal.appttude.com.viewmodels.DriverLicenseViewModel
|
||||||
import kotlinx.android.synthetic.main.fragment_vehicle_overall.*
|
import kotlinx.android.synthetic.main.fragment_vehicle_overall.*
|
||||||
|
|
||||||
|
|
||||||
class VehicleOverallFragment : BaseFragment<DriverLicenseViewModel>() {
|
class VehicleOverallFragment : Fragment(R.layout.fragment_vehicle_overall) {
|
||||||
|
|
||||||
private val viewmodel: DriverLicenseViewModel by getFragmentViewModel()
|
|
||||||
override fun getViewModel(): DriverLicenseViewModel = viewmodel
|
|
||||||
override fun getLayoutId(): Int = R.layout.fragment_vehicle_overall
|
|
||||||
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
20
app/src/driver/java/h_mal/appttude/com/ui/WelcomeFragment.kt
Normal file
20
app/src/driver/java/h_mal/appttude/com/ui/WelcomeFragment.kt
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package h_mal.appttude.com.ui
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.view.View
|
||||||
|
import h_mal.appttude.com.R
|
||||||
|
import h_mal.appttude.com.utils.navigateTo
|
||||||
|
import kotlinx.android.synthetic.driver.fragment_welcome.*
|
||||||
|
|
||||||
|
|
||||||
|
class WelcomeFragment : Fragment(R.layout.fragment_welcome) {
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
email_sign_in_button.setOnClickListener {
|
||||||
|
view.navigateTo(R.id.to_driverOverallFragment)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package h_mal.appttude.com.ui.driverprofile
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import h_mal.appttude.com.R
|
||||||
|
import h_mal.appttude.com.base.DataSubmissionBaseFragment
|
||||||
|
import h_mal.appttude.com.dialogs.DateDialog
|
||||||
|
import h_mal.appttude.com.model.DriversLicenseObject
|
||||||
|
import h_mal.appttude.com.utils.setGlideImage
|
||||||
|
import h_mal.appttude.com.viewmodels.DriverLicenseViewModel
|
||||||
|
import kotlinx.android.synthetic.main.fragment_driver_license.*
|
||||||
|
|
||||||
|
class DriverLicenseFragment :
|
||||||
|
DataSubmissionBaseFragment<DriverLicenseViewModel, DriversLicenseObject>(R.layout.fragment_driver_license) {
|
||||||
|
|
||||||
|
private val viewmodel: DriverLicenseViewModel by getFragmentViewModel()
|
||||||
|
override fun getViewModel(): DriverLicenseViewModel = viewmodel
|
||||||
|
override var model = DriversLicenseObject()
|
||||||
|
|
||||||
|
private var imageUri: Uri? = null
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
lic_expiry.apply {
|
||||||
|
setTextOnChange { model.licenseExpiry = it }
|
||||||
|
setOnClickListener {
|
||||||
|
DateDialog(this) { date ->
|
||||||
|
model.licenseExpiry = date
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lic_no.setTextOnChange { model.licenseNumber = it }
|
||||||
|
|
||||||
|
search_image.setOnClickListener { openGalleryWithPermissionRequest() }
|
||||||
|
submit.setOnClickListener { submit() }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun submit() {
|
||||||
|
validateEditTexts(lic_expiry, lic_no).takeIf { !it }?.let { return }
|
||||||
|
|
||||||
|
viewmodel.setDataInDatabase(model, imageUri)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setFields(data: DriversLicenseObject) {
|
||||||
|
super.setFields(data)
|
||||||
|
driversli_img.setGlideImage(data.licenseImageString)
|
||||||
|
lic_no.setText(data.licenseNumber)
|
||||||
|
lic_expiry.setText(data.licenseExpiry)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onImageGalleryResult(imageUri: Uri?) {
|
||||||
|
super.onImageGalleryResult(imageUri)
|
||||||
|
this.imageUri = imageUri
|
||||||
|
driversli_img.setGlideImage(imageUri)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,24 +1,24 @@
|
|||||||
package h_mal.appttude.com.driver.ui.driver.driverprofile
|
package h_mal.appttude.com.ui.driverprofile
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import h_mal.appttude.com.driver.Global.DateDialog
|
import h_mal.appttude.com.dialogs.DateDialog
|
||||||
import h_mal.appttude.com.driver.R
|
import h_mal.appttude.com.R
|
||||||
import h_mal.appttude.com.driver.base.DataSubmissionBaseFragment
|
import h_mal.appttude.com.base.DataSubmissionBaseFragment
|
||||||
import h_mal.appttude.com.driver.model.DriverProfileObject
|
import h_mal.appttude.com.model.DriverProfileObject
|
||||||
import h_mal.appttude.com.driver.utils.setPicassoImage
|
import h_mal.appttude.com.utils.setGlideImage
|
||||||
import h_mal.appttude.com.driver.viewmodels.DriverProfileViewModel
|
import h_mal.appttude.com.viewmodels.DriverProfileViewModel
|
||||||
import kotlinx.android.synthetic.main.fragment_driver_profile.*
|
import kotlinx.android.synthetic.main.fragment_driver_profile.*
|
||||||
|
|
||||||
|
|
||||||
class DriverProfileFragment: DataSubmissionBaseFragment<DriverProfileViewModel, DriverProfileObject>() {
|
class DriverProfileFragment: DataSubmissionBaseFragment
|
||||||
|
<DriverProfileViewModel, DriverProfileObject>(R.layout.fragment_driver_profile) {
|
||||||
|
|
||||||
var localUri: Uri? = null
|
var localUri: Uri? = null
|
||||||
|
|
||||||
private val viewmodel by getFragmentViewModel<DriverProfileViewModel>()
|
private val viewmodel by getFragmentViewModel<DriverProfileViewModel>()
|
||||||
override fun getViewModel(): DriverProfileViewModel = viewmodel
|
override fun getViewModel(): DriverProfileViewModel = viewmodel
|
||||||
override fun getLayoutId(): Int = R.layout.fragment_driver_profile
|
|
||||||
override var model = DriverProfileObject()
|
override var model = DriverProfileObject()
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
@@ -30,17 +30,21 @@ class DriverProfileFragment: DataSubmissionBaseFragment<DriverProfileViewModel,
|
|||||||
dob_input.apply {
|
dob_input.apply {
|
||||||
setTextOnChange{ model.dob = it }
|
setTextOnChange{ model.dob = it }
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
DateDialog(this)
|
DateDialog(this){ date ->
|
||||||
|
model.dob = date
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ni_number.setTextOnChange{ model.ni = it }
|
ni_number.setTextOnChange{ model.ni = it }
|
||||||
date_first.apply {
|
date_first.apply {
|
||||||
setTextOnChange{ model.dateFirst = it }
|
setTextOnChange{ model.dateFirst = it }
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
DateDialog(this)
|
DateDialog(this){ date ->
|
||||||
|
model.dateFirst = date
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_driver_pic.setOnClickListener { openGalleryWithPermissionRequest() }
|
add_photo.setOnClickListener { openGalleryWithPermissionRequest() }
|
||||||
submit_driver.setOnClickListener{ submit() }
|
submit_driver.setOnClickListener{ submit() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +59,7 @@ class DriverProfileFragment: DataSubmissionBaseFragment<DriverProfileViewModel,
|
|||||||
|
|
||||||
override fun setFields(data: DriverProfileObject) {
|
override fun setFields(data: DriverProfileObject) {
|
||||||
super.setFields(data)
|
super.setFields(data)
|
||||||
driver_pic.setPicassoImage(data.driverPic)
|
driver_pic.setGlideImage(data.driverPic)
|
||||||
names_input.setText(data.forenames)
|
names_input.setText(data.forenames)
|
||||||
address_input.setText(data.address)
|
address_input.setText(data.address)
|
||||||
postcode_input.setText(data.postcode)
|
postcode_input.setText(data.postcode)
|
||||||
@@ -67,7 +71,7 @@ class DriverProfileFragment: DataSubmissionBaseFragment<DriverProfileViewModel,
|
|||||||
override fun onImageGalleryResult(imageUri: Uri?) {
|
override fun onImageGalleryResult(imageUri: Uri?) {
|
||||||
super.onImageGalleryResult(imageUri)
|
super.onImageGalleryResult(imageUri)
|
||||||
localUri = imageUri
|
localUri = imageUri
|
||||||
driver_pic.setPicassoImage(imageUri)
|
driver_pic.setGlideImage(imageUri)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,23 +1,23 @@
|
|||||||
package h_mal.appttude.com.driver.ui.driver.driverprofile
|
package h_mal.appttude.com.ui.driverprofile
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import h_mal.appttude.com.driver.Global.DateDialog
|
import h_mal.appttude.com.dialogs.DateDialog
|
||||||
import h_mal.appttude.com.driver.R
|
import h_mal.appttude.com.R
|
||||||
import h_mal.appttude.com.driver.base.DataSubmissionBaseFragment
|
import h_mal.appttude.com.base.DataSubmissionBaseFragment
|
||||||
import h_mal.appttude.com.driver.model.PrivateHireObject
|
import h_mal.appttude.com.model.PrivateHireObject
|
||||||
import h_mal.appttude.com.driver.utils.setPicassoImage
|
import h_mal.appttude.com.utils.setGlideImage
|
||||||
import h_mal.appttude.com.driver.viewmodels.PrivateHireLicenseViewModel
|
import h_mal.appttude.com.viewmodels.PrivateHireLicenseViewModel
|
||||||
import kotlinx.android.synthetic.main.fragment_private_hire_license.*
|
import kotlinx.android.synthetic.main.fragment_private_hire_license.*
|
||||||
|
|
||||||
|
|
||||||
class PrivateHireLicenseFragment : DataSubmissionBaseFragment<PrivateHireLicenseViewModel, PrivateHireObject>() {
|
class PrivateHireLicenseFragment : DataSubmissionBaseFragment
|
||||||
|
<PrivateHireLicenseViewModel, PrivateHireObject>(R.layout.fragment_private_hire_license) {
|
||||||
|
|
||||||
val viewmodel by getFragmentViewModel<PrivateHireLicenseViewModel>()
|
val viewmodel by getFragmentViewModel<PrivateHireLicenseViewModel>()
|
||||||
override fun getViewModel(): PrivateHireLicenseViewModel = viewmodel
|
override fun getViewModel(): PrivateHireLicenseViewModel = viewmodel
|
||||||
override var model = PrivateHireObject()
|
override var model = PrivateHireObject()
|
||||||
override fun getLayoutId(): Int = R.layout.fragment_private_hire_license
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
@@ -26,7 +26,9 @@ class PrivateHireLicenseFragment : DataSubmissionBaseFragment<PrivateHireLicense
|
|||||||
ph_expiry.apply {
|
ph_expiry.apply {
|
||||||
setTextOnChange{ model.phExpiry = it }
|
setTextOnChange{ model.phExpiry = it }
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
DateDialog(this)
|
DateDialog(this){ date ->
|
||||||
|
model.phExpiry = date
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,14 +44,14 @@ class PrivateHireLicenseFragment : DataSubmissionBaseFragment<PrivateHireLicense
|
|||||||
|
|
||||||
override fun setFields(data: PrivateHireObject) {
|
override fun setFields(data: PrivateHireObject) {
|
||||||
super.setFields(data)
|
super.setFields(data)
|
||||||
imageView2.setPicassoImage(data.phImageString)
|
imageView2.setGlideImage(data.phImageString)
|
||||||
ph_no.setText(data.phNumber)
|
ph_no.setText(data.phNumber)
|
||||||
ph_expiry.setText(data.phExpiry)
|
ph_expiry.setText(data.phExpiry)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onImageGalleryResult(imageUri: Uri?) {
|
override fun onImageGalleryResult(imageUri: Uri?) {
|
||||||
super.onImageGalleryResult(imageUri)
|
super.onImageGalleryResult(imageUri)
|
||||||
imageView2.setPicassoImage(imageUri)
|
imageView2.setGlideImage(imageUri)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,25 +1,24 @@
|
|||||||
package h_mal.appttude.com.driver.ui.driver.vehicleprofile
|
package h_mal.appttude.com.ui.vehicleprofile
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import h_mal.appttude.com.driver.Global.DateDialog
|
import h_mal.appttude.com.R
|
||||||
import h_mal.appttude.com.driver.Objects.InsuranceObject
|
import h_mal.appttude.com.base.DataSubmissionBaseFragment
|
||||||
import h_mal.appttude.com.driver.R
|
import h_mal.appttude.com.dialogs.DateDialog
|
||||||
import h_mal.appttude.com.driver.base.DataSubmissionBaseFragment
|
import h_mal.appttude.com.model.InsuranceObject
|
||||||
import h_mal.appttude.com.driver.utils.setPicassoImage
|
import h_mal.appttude.com.utils.setGlideImage
|
||||||
import h_mal.appttude.com.driver.viewmodels.InsuranceViewModel
|
import h_mal.appttude.com.viewmodels.InsuranceViewModel
|
||||||
import kotlinx.android.synthetic.main.fragment_insurance.*
|
import kotlinx.android.synthetic.main.fragment_insurance.*
|
||||||
|
|
||||||
|
|
||||||
class InsuranceFragment : DataSubmissionBaseFragment<InsuranceViewModel, InsuranceObject>() {
|
class InsuranceFragment : DataSubmissionBaseFragment<InsuranceViewModel, InsuranceObject>(R.layout.fragment_insurance) {
|
||||||
|
|
||||||
private var selectedImages: List<Uri>? = listOf()
|
private var selectedImages: List<Uri>? = listOf()
|
||||||
|
|
||||||
private val viewmodel: InsuranceViewModel by getFragmentViewModel()
|
private val viewmodel: InsuranceViewModel by getFragmentViewModel()
|
||||||
override fun getViewModel(): InsuranceViewModel = viewmodel
|
override fun getViewModel(): InsuranceViewModel = viewmodel
|
||||||
override fun getLayoutId(): Int = R.layout.fragment_insurance
|
|
||||||
override var model = InsuranceObject()
|
override var model = InsuranceObject()
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
@@ -28,8 +27,11 @@ class InsuranceFragment : DataSubmissionBaseFragment<InsuranceViewModel, Insuran
|
|||||||
|
|
||||||
insurer.setTextOnChange { model.insurerName = it }
|
insurer.setTextOnChange { model.insurerName = it }
|
||||||
insurance_exp.apply {
|
insurance_exp.apply {
|
||||||
setOnClickListener { DateDialog(this) }
|
setOnClickListener {
|
||||||
setTextOnChange { model.expiryDate = it }
|
DateDialog(this) { date ->
|
||||||
|
model.expiryDate = date
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadInsurance.setOnClickListener { openGalleryWithPermissionRequest() }
|
uploadInsurance.setOnClickListener { openGalleryWithPermissionRequest() }
|
||||||
@@ -40,8 +42,10 @@ class InsuranceFragment : DataSubmissionBaseFragment<InsuranceViewModel, Insuran
|
|||||||
carouselView.setImageClickListener(null)
|
carouselView.setImageClickListener(null)
|
||||||
carouselView.setImageListener { i: Int, imageView: ImageView ->
|
carouselView.setImageListener { i: Int, imageView: ImageView ->
|
||||||
when (list[i]) {
|
when (list[i]) {
|
||||||
is Uri -> { imageView.setPicassoImage(list[i] as Uri) }
|
is Uri -> {
|
||||||
is String -> imageView.setPicassoImage(list[i] as String)
|
imageView.setGlideImage(list[i] as Uri)
|
||||||
|
}
|
||||||
|
is String -> imageView.setGlideImage(list[i] as String)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
carouselView.pageCount = list.size
|
carouselView.pageCount = list.size
|
||||||
@@ -1,22 +1,21 @@
|
|||||||
package h_mal.appttude.com.driver.ui.driver.vehicleprofile
|
package h_mal.appttude.com.ui.vehicleprofile
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import h_mal.appttude.com.driver.Objects.LogbookObject
|
import h_mal.appttude.com.model.LogbookObject
|
||||||
import h_mal.appttude.com.driver.R
|
import h_mal.appttude.com.R
|
||||||
import h_mal.appttude.com.driver.base.DataSubmissionBaseFragment
|
import h_mal.appttude.com.base.DataSubmissionBaseFragment
|
||||||
import h_mal.appttude.com.driver.utils.setPicassoImage
|
import h_mal.appttude.com.utils.setGlideImage
|
||||||
import h_mal.appttude.com.driver.viewmodels.LogbookViewModel
|
import h_mal.appttude.com.viewmodels.LogbookViewModel
|
||||||
import kotlinx.android.synthetic.main.fragment_logbook.*
|
import kotlinx.android.synthetic.main.fragment_logbook.*
|
||||||
|
|
||||||
|
|
||||||
class LogbookFragment : DataSubmissionBaseFragment<LogbookViewModel, LogbookObject>() {
|
class LogbookFragment : DataSubmissionBaseFragment<LogbookViewModel, LogbookObject>(R.layout.fragment_logbook) {
|
||||||
|
|
||||||
private val viewmodel by getFragmentViewModel<LogbookViewModel>()
|
private val viewmodel by getFragmentViewModel<LogbookViewModel>()
|
||||||
override fun getViewModel(): LogbookViewModel = viewmodel
|
override fun getViewModel(): LogbookViewModel = viewmodel
|
||||||
override var model = LogbookObject()
|
override var model = LogbookObject()
|
||||||
override fun getLayoutId(): Int = R.layout.fragment_logbook
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
@@ -38,7 +37,7 @@ class LogbookFragment : DataSubmissionBaseFragment<LogbookViewModel, LogbookObje
|
|||||||
override fun setFields(data: LogbookObject) {
|
override fun setFields(data: LogbookObject) {
|
||||||
super.setFields(data)
|
super.setFields(data)
|
||||||
|
|
||||||
log_book_img.setPicassoImage(data.photoString)
|
log_book_img.setGlideImage(data.photoString)
|
||||||
v5c_no.setText(data.v5cnumber)
|
v5c_no.setText(data.v5cnumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,6 +45,6 @@ class LogbookFragment : DataSubmissionBaseFragment<LogbookViewModel, LogbookObje
|
|||||||
super.onImageGalleryResult(imageUri)
|
super.onImageGalleryResult(imageUri)
|
||||||
|
|
||||||
picUri = imageUri
|
picUri = imageUri
|
||||||
log_book_img.setPicassoImage(picUri)
|
log_book_img.setGlideImage(picUri)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,32 +1,32 @@
|
|||||||
package h_mal.appttude.com.driver.ui.driver.vehicleprofile
|
package h_mal.appttude.com.ui.vehicleprofile
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
|
||||||
import h_mal.appttude.com.driver.Global.DateDialog
|
import h_mal.appttude.com.dialogs.DateDialog
|
||||||
import h_mal.appttude.com.driver.R
|
import h_mal.appttude.com.R
|
||||||
import h_mal.appttude.com.driver.base.DataSubmissionBaseFragment
|
import h_mal.appttude.com.base.DataSubmissionBaseFragment
|
||||||
import h_mal.appttude.com.driver.model.MotObject
|
import h_mal.appttude.com.model.MotObject
|
||||||
import h_mal.appttude.com.driver.utils.setPicassoImage
|
import h_mal.appttude.com.utils.setGlideImage
|
||||||
import h_mal.appttude.com.driver.viewmodels.MotViewModel
|
import h_mal.appttude.com.viewmodels.MotViewModel
|
||||||
import kotlinx.android.synthetic.main.fragment_mot.*
|
import kotlinx.android.synthetic.main.fragment_mot.*
|
||||||
|
|
||||||
|
|
||||||
class MotFragment: DataSubmissionBaseFragment<MotViewModel, MotObject>(){
|
class MotFragment: DataSubmissionBaseFragment<MotViewModel, MotObject>(R.layout.fragment_mot){
|
||||||
|
|
||||||
private val viewmodel by getFragmentViewModel<MotViewModel>()
|
private val viewmodel by getFragmentViewModel<MotViewModel>()
|
||||||
override fun getViewModel(): MotViewModel = viewmodel
|
override fun getViewModel(): MotViewModel = viewmodel
|
||||||
override var model = MotObject()
|
override var model = MotObject()
|
||||||
override fun getLayoutId(): Int = R.layout.fragment_mot
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
mot_expiry.apply {
|
mot_expiry.apply {
|
||||||
setTextOnChange{ model.motExpiry = it }
|
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
DateDialog(this)
|
DateDialog(this){ date ->
|
||||||
|
model.motExpiry = date
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,12 +42,12 @@ class MotFragment: DataSubmissionBaseFragment<MotViewModel, MotObject>(){
|
|||||||
|
|
||||||
override fun setFields(data: MotObject) {
|
override fun setFields(data: MotObject) {
|
||||||
super.setFields(data)
|
super.setFields(data)
|
||||||
mot_img.setPicassoImage(data.motImageString)
|
mot_img.setGlideImage(data.motImageString)
|
||||||
mot_expiry.setText(data.motExpiry)
|
mot_expiry.setText(data.motExpiry)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onImageGalleryResult(imageUri: Uri?) {
|
override fun onImageGalleryResult(imageUri: Uri?) {
|
||||||
super.onImageGalleryResult(imageUri)
|
super.onImageGalleryResult(imageUri)
|
||||||
mot_img.setPicassoImage(imageUri)
|
mot_img.setGlideImage(imageUri)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,33 +1,34 @@
|
|||||||
package h_mal.appttude.com.driver.ui.driver.vehicleprofile
|
package h_mal.appttude.com.ui.vehicleprofile
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
|
||||||
import h_mal.appttude.com.driver.Global.DateDialog
|
import h_mal.appttude.com.dialogs.DateDialog
|
||||||
import h_mal.appttude.com.driver.Objects.PrivateHireVehicleObject
|
import h_mal.appttude.com.model.PrivateHireVehicleObject
|
||||||
import h_mal.appttude.com.driver.R
|
import h_mal.appttude.com.R
|
||||||
import h_mal.appttude.com.driver.base.DataSubmissionBaseFragment
|
import h_mal.appttude.com.base.DataSubmissionBaseFragment
|
||||||
import h_mal.appttude.com.driver.utils.setPicassoImage
|
import h_mal.appttude.com.utils.setGlideImage
|
||||||
import h_mal.appttude.com.driver.viewmodels.PrivateHireVehicleViewModel
|
import h_mal.appttude.com.viewmodels.PrivateHireVehicleViewModel
|
||||||
import kotlinx.android.synthetic.main.fragment_private_hire_vehicle.*
|
import kotlinx.android.synthetic.main.fragment_private_hire_vehicle.*
|
||||||
|
|
||||||
|
|
||||||
class PrivateHireVehicleFragment: DataSubmissionBaseFragment<PrivateHireVehicleViewModel, PrivateHireVehicleObject>(){
|
class PrivateHireVehicleFragment: DataSubmissionBaseFragment
|
||||||
|
<PrivateHireVehicleViewModel, PrivateHireVehicleObject>(R.layout.fragment_private_hire_vehicle){
|
||||||
|
|
||||||
private val viewmodel by getFragmentViewModel<PrivateHireVehicleViewModel>()
|
private val viewmodel by getFragmentViewModel<PrivateHireVehicleViewModel>()
|
||||||
override fun getViewModel(): PrivateHireVehicleViewModel = viewmodel
|
override fun getViewModel(): PrivateHireVehicleViewModel = viewmodel
|
||||||
override var model = PrivateHireVehicleObject()
|
override var model = PrivateHireVehicleObject()
|
||||||
override fun getLayoutId(): Int = R.layout.fragment_private_hire_vehicle
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
ph_no.setTextOnChange{ model.phCarNumber = it }
|
ph_no.setTextOnChange{ model.phCarNumber = it }
|
||||||
ph_expiry.apply {
|
ph_expiry.apply {
|
||||||
setTextOnChange{ model.phCarExpiry = it }
|
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
DateDialog(this)
|
DateDialog(this){ date ->
|
||||||
|
model.phCarExpiry = date
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,13 +44,13 @@ class PrivateHireVehicleFragment: DataSubmissionBaseFragment<PrivateHireVehicleV
|
|||||||
|
|
||||||
override fun setFields(data: PrivateHireVehicleObject) {
|
override fun setFields(data: PrivateHireVehicleObject) {
|
||||||
super.setFields(data)
|
super.setFields(data)
|
||||||
imageView2.setPicassoImage(data.phCarImageString)
|
imageView2.setGlideImage(data.phCarImageString)
|
||||||
ph_no.setText(data.phCarNumber)
|
ph_no.setText(data.phCarNumber)
|
||||||
ph_expiry.setText(data.phCarExpiry)
|
ph_expiry.setText(data.phCarExpiry)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onImageGalleryResult(imageUri: Uri?) {
|
override fun onImageGalleryResult(imageUri: Uri?) {
|
||||||
super.onImageGalleryResult(imageUri)
|
super.onImageGalleryResult(imageUri)
|
||||||
imageView2.setPicassoImage(imageUri)
|
imageView2.setGlideImage(imageUri)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,22 @@
|
|||||||
package h_mal.appttude.com.driver.ui.driver.vehicleprofile
|
package h_mal.appttude.com.ui.vehicleprofile
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
|
||||||
import h_mal.appttude.com.driver.Global.DateDialog
|
import h_mal.appttude.com.dialogs.DateDialog
|
||||||
import h_mal.appttude.com.driver.R
|
import h_mal.appttude.com.R
|
||||||
import h_mal.appttude.com.driver.base.DataSubmissionBaseFragment
|
import h_mal.appttude.com.base.DataSubmissionBaseFragment
|
||||||
import h_mal.appttude.com.driver.model.VehicleProfileObject
|
import h_mal.appttude.com.model.VehicleProfileObject
|
||||||
import h_mal.appttude.com.driver.viewmodels.VehicleProfileViewModel
|
import h_mal.appttude.com.viewmodels.VehicleProfileViewModel
|
||||||
import kotlinx.android.synthetic.main.fragment_vehicle_setup.*
|
import kotlinx.android.synthetic.main.fragment_vehicle_setup.*
|
||||||
|
|
||||||
|
|
||||||
class VehicleProfileFragment: DataSubmissionBaseFragment<VehicleProfileViewModel, VehicleProfileObject>(){
|
class VehicleProfileFragment: DataSubmissionBaseFragment
|
||||||
|
<VehicleProfileViewModel, VehicleProfileObject>(R.layout.fragment_vehicle_setup){
|
||||||
|
|
||||||
private val viewmodel by getFragmentViewModel<VehicleProfileViewModel>()
|
private val viewmodel by getFragmentViewModel<VehicleProfileViewModel>()
|
||||||
override fun getViewModel(): VehicleProfileViewModel = viewmodel
|
override fun getViewModel(): VehicleProfileViewModel = viewmodel
|
||||||
override var model = VehicleProfileObject()
|
override var model = VehicleProfileObject()
|
||||||
override fun getLayoutId(): Int = R.layout.fragment_vehicle_setup
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
@@ -29,9 +29,10 @@ class VehicleProfileFragment: DataSubmissionBaseFragment<VehicleProfileViewModel
|
|||||||
address.setTextOnChange { model.keeperAddress = it }
|
address.setTextOnChange { model.keeperAddress = it }
|
||||||
postcode.setTextOnChange { model.keeperPostCode = it }
|
postcode.setTextOnChange { model.keeperPostCode = it }
|
||||||
start_date.apply {
|
start_date.apply {
|
||||||
setTextOnChange{ model.startDate = it }
|
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
DateDialog(this)
|
DateDialog(this){ date ->
|
||||||
|
model.startDate = date
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
seized_checkbox.setOnCheckedChangeListener { _, res -> model.isSeized = res}
|
seized_checkbox.setOnCheckedChangeListener { _, res -> model.isSeized = res}
|
||||||
74
app/src/driver/res/layout/fragment_welcome.xml
Normal file
74
app/src/driver/res/layout/fragment_welcome.xml
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
<?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"
|
||||||
|
android:background="@drawable/background_with_curve"
|
||||||
|
tools:context=".ui.user.LoginFragment">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/background_img"
|
||||||
|
android:src="@drawable/welcome_background"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
style="@style/imageBackground"
|
||||||
|
android:contentDescription="@string/image_description" />
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:padding="@dimen/activity_horizontal_margin"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/email_sign_in_button"
|
||||||
|
style="@style/TextButton.WithIcon"
|
||||||
|
android:text="@string/login"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0.9" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/register_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/or_create_my_account"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:layout_marginTop="@dimen/activity_horizontal_margin"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/email_sign_in_button" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView3"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/hello_nice_to_meet_you"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
android:layout_marginTop="32dp"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView4"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/get_a_new_experience"
|
||||||
|
android:layout_marginTop="6dp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textSize="24sp"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/textView3"/>
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
4
app/src/driver/res/values/strings.xml
Normal file
4
app/src/driver/res/values/strings.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<resources>
|
||||||
|
<!-- TODO: Remove or change this placeholder text -->
|
||||||
|
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||||
|
</resources>
|
||||||
@@ -1,50 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="h_mal.appttude.com.driver">
|
package="h_mal.appttude.com">
|
||||||
<!-- To auto-complete the email text field in the login form with the user's emails -->
|
<!-- To auto-complete the email text field in the login form with the user's emails -->
|
||||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
|
||||||
<uses-permission android:name="android.permission.READ_PROFILE" />
|
|
||||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
|
||||||
<uses-permission android:name="android.permission.CAMERA" />
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".application.DriverApplication"
|
android:name="h_mal.appttude.com.application.DriverApplication"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
<activity android:name=".update.UpdateActivity" />
|
|
||||||
<activity
|
|
||||||
android:name=".ui.user.LoginActivity"
|
|
||||||
android:label="@string/app_name"
|
|
||||||
android:theme="@style/Theme.Design.NoActionBar">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
<activity
|
|
||||||
android:name=".ui.driver.MainActivity"
|
|
||||||
android:configChanges="orientation|screenSize"
|
|
||||||
android:label="@string/app_name"
|
|
||||||
android:theme="@style/AppTheme.NoActionBar" />
|
|
||||||
|
|
||||||
<provider
|
|
||||||
android:name="androidx.core.content.FileProvider"
|
|
||||||
android:authorities="h_mal.appttude.com.driver"
|
|
||||||
android:exported="false"
|
|
||||||
android:grantUriPermissions="true">
|
|
||||||
<meta-data
|
|
||||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
|
||||||
android:resource="@xml/file_paths" />
|
|
||||||
</provider>
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package h_mal.appttude.com.driver.Archive
|
package h_mal.appttude.com.Archive
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
@@ -10,12 +10,11 @@ import com.google.firebase.database.DataSnapshot
|
|||||||
import com.google.firebase.database.DatabaseError
|
import com.google.firebase.database.DatabaseError
|
||||||
import com.google.firebase.database.DatabaseReference
|
import com.google.firebase.database.DatabaseReference
|
||||||
import com.google.firebase.database.ValueEventListener
|
import com.google.firebase.database.ValueEventListener
|
||||||
import h_mal.appttude.com.driver.Global.FirebaseClass
|
|
||||||
import h_mal.appttude.com.driver.Objects.ArchiveObject
|
import h_mal.appttude.com.R
|
||||||
import h_mal.appttude.com.driver.R
|
|
||||||
|
|
||||||
class ArchiveFragment : Fragment() {
|
class ArchiveFragment : Fragment() {
|
||||||
var archive: ArchiveObject? = null
|
// var archive: ArchiveObject? = null
|
||||||
private var reference: DatabaseReference? = null
|
private var reference: DatabaseReference? = null
|
||||||
private var listView: ListView? = null
|
private var listView: ListView? = null
|
||||||
var archiveString: String? = null
|
var archiveString: String? = null
|
||||||
@@ -27,18 +26,18 @@ class ArchiveFragment : Fragment() {
|
|||||||
// )
|
// )
|
||||||
// .child(FirebaseClass.ARCHIVE_FIREBASE)
|
// .child(FirebaseClass.ARCHIVE_FIREBASE)
|
||||||
|
|
||||||
archiveString = requireArguments().getString("archive")
|
// archiveString = requireArguments().getString("archive")
|
||||||
var s: String = ""
|
// var s: String = ""
|
||||||
when (archiveString) {
|
// when (archiveString) {
|
||||||
FirebaseClass.PRIVATE_HIRE_FIREBASE -> s = "Private Hire"
|
// FirebaseClass.PRIVATE_HIRE_FIREBASE -> s = "Private Hire"
|
||||||
FirebaseClass.DRIVERS_LICENSE_FIREBASE -> s = "License"
|
// FirebaseClass.DRIVERS_LICENSE_FIREBASE -> s = "License"
|
||||||
FirebaseClass.VEHICLE_DETAILS_FIREBASE -> s = "Vehicle"
|
// FirebaseClass.VEHICLE_DETAILS_FIREBASE -> s = "Vehicle"
|
||||||
FirebaseClass.MOT_FIREBASE -> s = "M.O.T"
|
// FirebaseClass.MOT_FIREBASE -> s = "M.O.T"
|
||||||
FirebaseClass.INSURANCE_FIREBASE -> s = "Insurance"
|
// FirebaseClass.INSURANCE_FIREBASE -> s = "Insurance"
|
||||||
FirebaseClass.LOG_BOOK_FIREBASE -> s = "Logbook"
|
// FirebaseClass.LOG_BOOK_FIREBASE -> s = "Logbook"
|
||||||
FirebaseClass.PRIVATE_HIRE_VEHICLE_LICENSE -> s = "Private Hire Vehicle"
|
// FirebaseClass.PRIVATE_HIRE_VEHICLE_LICENSE -> s = "Private Hire Vehicle"
|
||||||
}
|
// }
|
||||||
requireActivity().title = s + " Archive"
|
// requireActivity().title = s + " Archive"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
@@ -52,12 +51,12 @@ class ArchiveFragment : Fragment() {
|
|||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
|
||||||
var valueEventListener: ValueEventListener = object : ValueEventListener {
|
// var valueEventListener: ValueEventListener = object : ValueEventListener {
|
||||||
override fun onDataChange(dataSnapshot: DataSnapshot) {
|
// override fun onDataChange(dataSnapshot: DataSnapshot) {
|
||||||
archive = dataSnapshot.getValue(ArchiveObject::class.java)
|
// archive = dataSnapshot.getValue(ArchiveObject::class.java)
|
||||||
listView!!.adapter = ArchiveObjectListAdapter(archive, requireContext(), archiveString)
|
// listView!!.adapter = ArchiveObjectListAdapter(archive, requireContext(), archiveString)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override fun onCancelled(databaseError: DatabaseError) {}
|
// override fun onCancelled(databaseError: DatabaseError) {}
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,221 @@
|
|||||||
|
package h_mal.appttude.com.Archive
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.BaseAdapter
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.TextView
|
||||||
|
//import h_mal.appttude.com.Global.FirebaseClass
|
||||||
|
//import h_mal.appttude.com.Global.ImageSwiperClass
|
||||||
|
//import h_mal.appttude.com.Objects.ArchiveObject
|
||||||
|
import h_mal.appttude.com.model.InsuranceObject
|
||||||
|
import h_mal.appttude.com.R
|
||||||
|
import h_mal.appttude.com.model.VehicleProfileObject
|
||||||
|
import h_mal.appttude.com.utils.DateUtils.convertDateStringDatePattern
|
||||||
|
import java.text.ParseException
|
||||||
|
|
||||||
|
class ArchiveObjectListAdapter(
|
||||||
|
// var archiveObject: ArchiveObject?,
|
||||||
|
var context: Context?,
|
||||||
|
var archiveString: String?
|
||||||
|
) : BaseAdapter() {
|
||||||
|
var size: Int = 0
|
||||||
|
lateinit var mKeys: Array<String>
|
||||||
|
private var dateArchivedText: TextView? = null
|
||||||
|
override fun getCount(): Int {
|
||||||
|
return size
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItem(position: Int): Any? {
|
||||||
|
when (archiveString) {
|
||||||
|
// FirebaseClass.PRIVATE_HIRE_FIREBASE -> return archiveObject?.private_hire
|
||||||
|
// ?.get(mKeys[position])
|
||||||
|
// FirebaseClass.DRIVERS_LICENSE_FIREBASE -> return archiveObject?.driver_license
|
||||||
|
// ?.get(mKeys[position])
|
||||||
|
// FirebaseClass.VEHICLE_DETAILS_FIREBASE -> return archiveObject?.vehicle_details
|
||||||
|
// ?.get(mKeys[position])
|
||||||
|
// FirebaseClass.MOT_FIREBASE -> return archiveObject?.mot_details?.get(mKeys[position])
|
||||||
|
// FirebaseClass.INSURANCE_FIREBASE -> return archiveObject?.insurance_details?.get(
|
||||||
|
// mKeys[position]
|
||||||
|
// )
|
||||||
|
// FirebaseClass.LOG_BOOK_FIREBASE -> return archiveObject?.log_book
|
||||||
|
// ?.get(mKeys.get(position))
|
||||||
|
// FirebaseClass.PRIVATE_HIRE_VEHICLE_LICENSE -> return archiveObject?.ph_car?.get(mKeys[position])
|
||||||
|
else -> return mKeys[position]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemId(position: Int): Long {
|
||||||
|
return position.toLong()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getView(position: Int, convertView: View, parent: ViewGroup): View {
|
||||||
|
var listItemView: View = convertView
|
||||||
|
//
|
||||||
|
// if (listItemView == null) {
|
||||||
|
// if (((archiveString == FirebaseClass.PRIVATE_HIRE_FIREBASE) || (archiveString == FirebaseClass.DRIVERS_LICENSE_FIREBASE) || (archiveString == FirebaseClass.MOT_FIREBASE) || (archiveString == FirebaseClass.LOG_BOOK_FIREBASE) || (archiveString == FirebaseClass.PRIVATE_HIRE_VEHICLE_LICENSE))) {
|
||||||
|
// listItemView = LayoutInflater.from(context).inflate(
|
||||||
|
// R.layout.archive_license_item, parent, false
|
||||||
|
// )
|
||||||
|
// val imageView: ImageView = listItemView.findViewById(R.id.image_archive)
|
||||||
|
// dateArchivedText = listItemView.findViewById(R.id.date_archived)
|
||||||
|
// val expiryHolder: LinearLayout = listItemView.findViewById(R.id.expiry_view)
|
||||||
|
// val fieldTwo: LinearLayout = listItemView.findViewById(R.id.field_two_view)
|
||||||
|
// val expiryText: TextView = listItemView.findViewById(R.id.exp_text)
|
||||||
|
// val fiewTwoLable: TextView = listItemView.findViewById(R.id.field_two)
|
||||||
|
// val fieldTwoText: TextView = listItemView.findViewById(R.id.field_two_text)
|
||||||
|
// when (archiveString) {
|
||||||
|
//// FirebaseClass.PRIVATE_HIRE_FIREBASE -> {
|
||||||
|
//// expiryHolder.visibility = View.VISIBLE
|
||||||
|
//// fieldTwo.visibility = View.VISIBLE
|
||||||
|
//// val privateHireObject: PrivateHireObject =
|
||||||
|
//// getItem(position) as PrivateHireObject
|
||||||
|
//// Picasso.get().load(privateHireObject.phImageString)
|
||||||
|
//// .placeholder(R.drawable.choice_img)
|
||||||
|
//// .into(imageView)
|
||||||
|
//// dateString(position)
|
||||||
|
//// expiryText.text = privateHireObject.phExpiry
|
||||||
|
//// fiewTwoLable.text = "Private Hire License No.:"
|
||||||
|
//// fieldTwoText.text = privateHireObject.phNumber
|
||||||
|
//// }
|
||||||
|
//// FirebaseClass.DRIVERS_LICENSE_FIREBASE -> {
|
||||||
|
//// expiryHolder.visibility = View.VISIBLE
|
||||||
|
//// fieldTwo.visibility = View.VISIBLE
|
||||||
|
//// val driversLicenseObject: DriversLicenseObject =
|
||||||
|
//// getItem(position) as DriversLicenseObject
|
||||||
|
//// Picasso.get().load(driversLicenseObject.licenseImageString)
|
||||||
|
//// .placeholder(R.drawable.choice_img)
|
||||||
|
//// .into(imageView)
|
||||||
|
//// dateString(position)
|
||||||
|
//// expiryText.text = driversLicenseObject.licenseExpiry
|
||||||
|
//// fiewTwoLable.text = "License No.:"
|
||||||
|
//// fieldTwoText.text = driversLicenseObject.licenseNumber
|
||||||
|
//// }
|
||||||
|
//// FirebaseClass.MOT_FIREBASE -> {
|
||||||
|
//// expiryHolder.visibility = View.VISIBLE
|
||||||
|
//// fieldTwo.visibility = View.GONE
|
||||||
|
//// val motObject: MotObject = getItem(position) as MotObject
|
||||||
|
//// Picasso.get().load(motObject.motImageString)
|
||||||
|
//// .placeholder(R.drawable.choice_img)
|
||||||
|
//// .into(imageView)
|
||||||
|
//// dateString(position)
|
||||||
|
//// expiryText.text = motObject.motExpiry
|
||||||
|
//// }
|
||||||
|
//// FirebaseClass.LOG_BOOK_FIREBASE -> {
|
||||||
|
//// expiryHolder.visibility = View.GONE
|
||||||
|
//// fieldTwo.visibility = View.VISIBLE
|
||||||
|
//// val logbookObject: LogbookObject = getItem(position) as LogbookObject
|
||||||
|
//// Picasso.get().load(logbookObject.photoString)
|
||||||
|
//// .into(MainActivity.loadImage(imageView))
|
||||||
|
//// dateString(position)
|
||||||
|
//// fiewTwoLable.text = "V5C No.:"
|
||||||
|
//// fieldTwoText.text = logbookObject.v5cnumber
|
||||||
|
//// }
|
||||||
|
//// FirebaseClass.PRIVATE_HIRE_VEHICLE_LICENSE -> {
|
||||||
|
//// expiryHolder.visibility = View.VISIBLE
|
||||||
|
//// fieldTwo.visibility = View.VISIBLE
|
||||||
|
//// val privateHireVehicleObject: PrivateHireVehicleObject =
|
||||||
|
//// getItem(position) as PrivateHireVehicleObject
|
||||||
|
//// Picasso.get().load(privateHireVehicleObject.phCarImageString)
|
||||||
|
//// .into(MainActivity.loadImage(imageView))
|
||||||
|
//// dateString(position)
|
||||||
|
//// expiryText.text = privateHireVehicleObject.phCarExpiry
|
||||||
|
//// fiewTwoLable.text = "Private Hire Vehicle License No.:"
|
||||||
|
//// fieldTwoText.text = privateHireVehicleObject.phCarNumber
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
//// } else if ((archiveString == FirebaseClass.INSURANCE_FIREBASE)) {
|
||||||
|
//// listItemView = LayoutInflater.from(context).inflate(
|
||||||
|
//// R.layout.archive_insurance_item, parent, false
|
||||||
|
//// )
|
||||||
|
//// val holder: View = listItemView.findViewById(R.id.image_pager)
|
||||||
|
//// val swiperClass: ImageSwiperClass = ImageSwiperClass(context, holder)
|
||||||
|
//// // swiperClass.hideDelete();
|
||||||
|
//// listItemView.findViewById<View>(R.id.delete).visibility = View.GONE
|
||||||
|
//// // holder.findViewById(R.id.delete).setVisibility(View.INVISIBLE);
|
||||||
|
//// dateArchivedText = listItemView.findViewById(R.id.date_archived)
|
||||||
|
//// dateString(position)
|
||||||
|
//// val expiryText: TextView = listItemView.findViewById(R.id.exp_text)
|
||||||
|
//// val fieldTwoText: TextView = listItemView.findViewById(R.id.archive_insurer)
|
||||||
|
//// val insuranceObject: InsuranceObject = getItem(position) as InsuranceObject
|
||||||
|
////// swiperClass.reinstantiateList(insuranceObject.photoStrings)
|
||||||
|
//// expiryText.text = insuranceObject.expiryDate
|
||||||
|
//// fieldTwoText.text = insuranceObject.insurerName
|
||||||
|
//// } else if ((archiveString == FirebaseClass.VEHICLE_DETAILS_FIREBASE)) {
|
||||||
|
//// listItemView = LayoutInflater.from(context).inflate(
|
||||||
|
//// R.layout.archive_vehicle_item, parent, false
|
||||||
|
//// )
|
||||||
|
//// dateArchivedText = listItemView.findViewById(R.id.date_archived)
|
||||||
|
//// dateString(position)
|
||||||
|
//// val numberPlate: TextView = listItemView.findViewById(R.id.number_plate)
|
||||||
|
//// val keeperName: TextView = listItemView.findViewById(R.id.keeper_name)
|
||||||
|
//// val keeperAddress: TextView = listItemView.findViewById(R.id.keeper_address)
|
||||||
|
//// val carText: TextView = listItemView.findViewById(R.id.car_text_arch)
|
||||||
|
//// val carColour: TextView = listItemView.findViewById(R.id.car_colour)
|
||||||
|
//// val carSeized: TextView = listItemView.findViewById(R.id.seized_checkbox)
|
||||||
|
//// val startDate: TextView = listItemView.findViewById(R.id.first_date)
|
||||||
|
//// val vehicleProfileObject: VehicleProfileObject =
|
||||||
|
//// getItem(position) as VehicleProfileObject
|
||||||
|
//// numberPlate.text = vehicleProfileObject.reg
|
||||||
|
//// keeperName.text = vehicleProfileObject.keeperName
|
||||||
|
//// keeperAddress.text = vehicleProfileObject.keeperAddress + "\n" + vehicleProfileObject.keeperPostCode
|
||||||
|
//// carText.text = vehicleProfileObject.make + " " + vehicleProfileObject.model
|
||||||
|
//// carColour.text = vehicleProfileObject.colour
|
||||||
|
//// val s: String
|
||||||
|
//// if (vehicleProfileObject.isSeized) {
|
||||||
|
//// s = "Yes"
|
||||||
|
//// } else {
|
||||||
|
//// s = "No"
|
||||||
|
//// }
|
||||||
|
//// carSeized.text = s
|
||||||
|
//// startDate.text = vehicleProfileObject.startDate
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
return listItemView
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun dateString(position: Int) {
|
||||||
|
var success: Boolean = true
|
||||||
|
try {
|
||||||
|
dateArchivedText!!.text = mKeys[position].convertDateStringDatePattern("yyyyMMdd_HHmmss", "dd/MM/yyyy")
|
||||||
|
} catch (e: ParseException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
success = false
|
||||||
|
} finally {
|
||||||
|
if (!success) {
|
||||||
|
dateArchivedText!!.text = mKeys.get(position).substring(0, 8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val TAG: String = "ArchiveObjectListAdapte"
|
||||||
|
}
|
||||||
|
|
||||||
|
// init {
|
||||||
|
// archiveObject?.apply {
|
||||||
|
// val map = when (archiveString) {
|
||||||
|
// FirebaseClass.PRIVATE_HIRE_FIREBASE -> private_hire
|
||||||
|
// FirebaseClass.DRIVERS_LICENSE_FIREBASE -> driver_license
|
||||||
|
// FirebaseClass.VEHICLE_DETAILS_FIREBASE -> vehicle_details
|
||||||
|
// FirebaseClass.MOT_FIREBASE -> mot_details
|
||||||
|
// FirebaseClass.INSURANCE_FIREBASE -> insurance_details
|
||||||
|
// FirebaseClass.LOG_BOOK_FIREBASE -> log_book
|
||||||
|
// FirebaseClass.PRIVATE_HIRE_VEHICLE_LICENSE -> ph_car
|
||||||
|
// else -> null
|
||||||
|
// }
|
||||||
|
// setUp(map)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
private fun setUp(map: HashMap<String,*>?){
|
||||||
|
size = map?.size ?: 0
|
||||||
|
map?.keys?.toTypedArray()?.let{
|
||||||
|
mKeys = it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package h_mal.appttude.com.driver.application
|
package h_mal.appttude.com.application
|
||||||
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import h_mal.appttude.com.driver.data.FirebaseAuthSource
|
import h_mal.appttude.com.data.FirebaseAuthSource
|
||||||
import h_mal.appttude.com.driver.data.FirebaseDatabaseSource
|
import h_mal.appttude.com.data.FirebaseDatabaseSource
|
||||||
import h_mal.appttude.com.driver.data.FirebaseStorageSource
|
import h_mal.appttude.com.data.FirebaseStorageSource
|
||||||
import h_mal.appttude.com.driver.viewmodels.*
|
import h_mal.appttude.com.viewmodels.*
|
||||||
|
|
||||||
class ApplicationViewModelFactory(
|
class ApplicationViewModelFactory(
|
||||||
private val auth: FirebaseAuthSource,
|
private val auth: FirebaseAuthSource,
|
||||||
@@ -28,6 +28,7 @@ class ApplicationViewModelFactory(
|
|||||||
isAssignableFrom(MotViewModel::class.java) -> MotViewModel(auth, database, storage)
|
isAssignableFrom(MotViewModel::class.java) -> MotViewModel(auth, database, storage)
|
||||||
isAssignableFrom(LogbookViewModel::class.java) -> LogbookViewModel(auth, database, storage)
|
isAssignableFrom(LogbookViewModel::class.java) -> LogbookViewModel(auth, database, storage)
|
||||||
isAssignableFrom(PrivateHireVehicleViewModel::class.java) -> PrivateHireVehicleViewModel(auth, database, storage)
|
isAssignableFrom(PrivateHireVehicleViewModel::class.java) -> PrivateHireVehicleViewModel(auth, database, storage)
|
||||||
|
isAssignableFrom(RoleViewModel::class.java) -> RoleViewModel(auth, database, storage)
|
||||||
else -> throw IllegalArgumentException("Unknown ViewModel class")
|
else -> throw IllegalArgumentException("Unknown ViewModel class")
|
||||||
} as T
|
} as T
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
package h_mal.appttude.com.driver.application
|
package h_mal.appttude.com.application
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import h_mal.appttude.com.driver.data.FirebaseAuthSource
|
import h_mal.appttude.com.data.FirebaseAuthSource
|
||||||
import h_mal.appttude.com.driver.data.FirebaseDatabaseSource
|
import h_mal.appttude.com.data.FirebaseDatabaseSource
|
||||||
import h_mal.appttude.com.driver.data.FirebaseStorageSource
|
import h_mal.appttude.com.data.FirebaseStorageSource
|
||||||
|
import h_mal.appttude.com.espresso.IdlingResourceClass
|
||||||
import org.kodein.di.Kodein
|
import org.kodein.di.Kodein
|
||||||
import org.kodein.di.KodeinAware
|
import org.kodein.di.KodeinAware
|
||||||
import org.kodein.di.android.x.androidXModule
|
import org.kodein.di.android.x.androidXModule
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package h_mal.appttude.com.driver.base
|
package h_mal.appttude.com.base
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.view.ViewGroup.LayoutParams
|
import android.view.ViewGroup.LayoutParams
|
||||||
import android.view.ViewGroup.LayoutParams.*
|
import android.view.ViewGroup.LayoutParams.*
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
@@ -11,13 +10,14 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import h_mal.appttude.com.driver.R
|
import h_mal.appttude.com.application.ApplicationViewModelFactory
|
||||||
import h_mal.appttude.com.driver.application.ApplicationViewModelFactory
|
import h_mal.appttude.com.R
|
||||||
import h_mal.appttude.com.driver.data.ViewState
|
import h_mal.appttude.com.data.ViewState
|
||||||
import h_mal.appttude.com.driver.utils.displayToast
|
import h_mal.appttude.com.espresso.IdlingResourceClass
|
||||||
import h_mal.appttude.com.driver.utils.hide
|
import h_mal.appttude.com.utils.displayToast
|
||||||
import h_mal.appttude.com.driver.utils.show
|
import h_mal.appttude.com.utils.hide
|
||||||
import h_mal.appttude.com.driver.utils.triggerAnimation
|
import h_mal.appttude.com.utils.show
|
||||||
|
import h_mal.appttude.com.utils.triggerAnimation
|
||||||
import org.kodein.di.KodeinAware
|
import org.kodein.di.KodeinAware
|
||||||
import org.kodein.di.android.kodein
|
import org.kodein.di.android.kodein
|
||||||
import org.kodein.di.generic.instance
|
import org.kodein.di.generic.instance
|
||||||
@@ -32,6 +32,7 @@ abstract class BaseActivity<V : BaseViewModel> : AppCompatActivity(), KodeinAwar
|
|||||||
|
|
||||||
override val kodein by kodein()
|
override val kodein by kodein()
|
||||||
val factory by instance<ApplicationViewModelFactory>()
|
val factory by instance<ApplicationViewModelFactory>()
|
||||||
|
private val idlingResource by instance<IdlingResourceClass>()
|
||||||
|
|
||||||
inline fun <reified VM : ViewModel> createLazyViewModel(): Lazy<VM> = viewModels { factory }
|
inline fun <reified VM : ViewModel> createLazyViewModel(): Lazy<VM> = viewModels { factory }
|
||||||
inline fun <reified VM : ViewModel> createViewModel(): VM =
|
inline fun <reified VM : ViewModel> createViewModel(): VM =
|
||||||
@@ -56,7 +57,6 @@ abstract class BaseActivity<V : BaseViewModel> : AppCompatActivity(), KodeinAwar
|
|||||||
loadingView = layoutInflater.inflate(R.layout.progress_layout, null)
|
loadingView = layoutInflater.inflate(R.layout.progress_layout, null)
|
||||||
loadingView.setOnClickListener(null)
|
loadingView.setOnClickListener(null)
|
||||||
addContentView(loadingView, LayoutParams(MATCH_PARENT, MATCH_PARENT))
|
addContentView(loadingView, LayoutParams(MATCH_PARENT, MATCH_PARENT))
|
||||||
|
|
||||||
loadingView.hide()
|
loadingView.hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,6 +76,7 @@ abstract class BaseActivity<V : BaseViewModel> : AppCompatActivity(), KodeinAwar
|
|||||||
open fun onStarted() {
|
open fun onStarted() {
|
||||||
loadingView.fadeIn()
|
loadingView.fadeIn()
|
||||||
loading = true
|
loading = true
|
||||||
|
IdlingResourceClass.increment()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,6 +85,7 @@ abstract class BaseActivity<V : BaseViewModel> : AppCompatActivity(), KodeinAwar
|
|||||||
open fun onSuccess(data: Any?) {
|
open fun onSuccess(data: Any?) {
|
||||||
loadingView.fadeOut()
|
loadingView.fadeOut()
|
||||||
loading = false
|
loading = false
|
||||||
|
IdlingResourceClass.decrement()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,6 +95,7 @@ abstract class BaseActivity<V : BaseViewModel> : AppCompatActivity(), KodeinAwar
|
|||||||
error?.let { displayToast(it) }
|
error?.let { displayToast(it) }
|
||||||
loadingView.fadeOut()
|
loadingView.fadeOut()
|
||||||
loading = false
|
loading = false
|
||||||
|
IdlingResourceClass.decrement()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun configureObserver() {
|
private fun configureObserver() {
|
||||||
@@ -1,34 +1,32 @@
|
|||||||
package h_mal.appttude.com.driver.base
|
package h_mal.appttude.com.base
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.ClipData
|
import android.content.ClipData
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import androidx.annotation.LayoutRes
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
import androidx.lifecycle.Observer
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import h_mal.appttude.com.driver.application.ApplicationViewModelFactory
|
import h_mal.appttude.com.application.ApplicationViewModelFactory
|
||||||
import h_mal.appttude.com.driver.data.ViewState
|
import h_mal.appttude.com.data.ViewState
|
||||||
import h_mal.appttude.com.driver.utils.PermissionsUtils
|
import h_mal.appttude.com.utils.PermissionsUtils
|
||||||
import org.kodein.di.KodeinAware
|
import org.kodein.di.KodeinAware
|
||||||
import org.kodein.di.android.x.kodein
|
import org.kodein.di.android.x.kodein
|
||||||
import org.kodein.di.generic.instance
|
import org.kodein.di.generic.instance
|
||||||
|
|
||||||
const val IMAGE_SELECT_REQUEST_CODE = 401
|
const val IMAGE_SELECT_REQUEST_CODE = 401
|
||||||
abstract class BaseFragment<V : BaseViewModel> : Fragment(), KodeinAware {
|
|
||||||
|
abstract class BaseFragment<V : BaseViewModel>(@LayoutRes contentLayoutId: Int) :
|
||||||
|
Fragment(contentLayoutId), KodeinAware {
|
||||||
|
|
||||||
var mActivity: BaseActivity<V>? = null
|
var mActivity: BaseActivity<V>? = null
|
||||||
abstract fun getViewModel(): V
|
abstract fun getViewModel(): V
|
||||||
abstract fun getLayoutId(): Int
|
|
||||||
|
|
||||||
private var multipleImage: Boolean = false
|
private var multipleImage: Boolean = false
|
||||||
|
|
||||||
fun setImageSelectionAsMultiple(){
|
fun setImageSelectionAsMultiple() {
|
||||||
multipleImage = true
|
multipleImage = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,12 +35,6 @@ abstract class BaseFragment<V : BaseViewModel> : Fragment(), KodeinAware {
|
|||||||
|
|
||||||
inline fun <reified VM : ViewModel> getFragmentViewModel(): Lazy<VM> = viewModels { factory }
|
inline fun <reified VM : ViewModel> getFragmentViewModel(): Lazy<VM> = viewModels { factory }
|
||||||
|
|
||||||
override fun onCreateView(
|
|
||||||
inflater: LayoutInflater,
|
|
||||||
container: ViewGroup?,
|
|
||||||
savedInstanceState: Bundle?
|
|
||||||
): View? = inflater.inflate(getLayoutId(), container, false)
|
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
@@ -72,22 +64,22 @@ abstract class BaseFragment<V : BaseViewModel> : Fragment(), KodeinAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun configureObserver() {
|
private fun configureObserver() {
|
||||||
getViewModel().uiState.observe(viewLifecycleOwner, Observer {
|
getViewModel().uiState.observe(viewLifecycleOwner) {
|
||||||
when (it) {
|
when (it) {
|
||||||
is ViewState.HasStarted -> onStarted()
|
is ViewState.HasStarted -> onStarted()
|
||||||
is ViewState.HasData<*> -> onSuccess(it.data.getContentIfNotHandled())
|
is ViewState.HasData<*> -> onSuccess(it.data.getContentIfNotHandled())
|
||||||
is ViewState.HasError -> onFailure(it.error.getContentIfNotHandled())
|
is ViewState.HasError -> onFailure(it.error.getContentIfNotHandled())
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
if (resultCode == Activity.RESULT_OK){
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
when(requestCode){
|
when (requestCode) {
|
||||||
IMAGE_SELECT_REQUEST_CODE -> {
|
IMAGE_SELECT_REQUEST_CODE -> {
|
||||||
data?.clipData?.convertToList()?.let { clip ->
|
data?.clipData?.convertToList()?.let { clip ->
|
||||||
val list = clip.takeIf { it.size > 10 }?.let{
|
val list = clip.takeIf { it.size > 10 }?.let {
|
||||||
clip.subList(0, 9)
|
clip.subList(0, 9)
|
||||||
} ?: clip
|
} ?: clip
|
||||||
onImageGalleryResult(list)
|
onImageGalleryResult(list)
|
||||||
@@ -100,15 +92,7 @@ abstract class BaseFragment<V : BaseViewModel> : Fragment(), KodeinAware {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ClipData.convertToList(): List<Uri> {
|
private fun ClipData.convertToList(): List<Uri> = 0.rangeTo(itemCount).map { getItemAt(it).uri }
|
||||||
val list = mutableListOf<Uri>()
|
|
||||||
for (i in 0 until itemCount) {
|
|
||||||
val item: ClipData.Item = getItemAt(i)
|
|
||||||
val uri = item.uri
|
|
||||||
list.add(uri)
|
|
||||||
}
|
|
||||||
return list.toList()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pair with {@link #Fragment.onRequestPermissionsResult}
|
* Pair with {@link #Fragment.onRequestPermissionsResult}
|
||||||
@@ -121,7 +105,7 @@ abstract class BaseFragment<V : BaseViewModel> : Fragment(), KodeinAware {
|
|||||||
fun onPermissionRequest(
|
fun onPermissionRequest(
|
||||||
requestCode: Int, ourRequestCode: Int, grantResults: IntArray,
|
requestCode: Int, ourRequestCode: Int, grantResults: IntArray,
|
||||||
permissionGranted: () -> Unit
|
permissionGranted: () -> Unit
|
||||||
){
|
) {
|
||||||
when (requestCode) {
|
when (requestCode) {
|
||||||
ourRequestCode -> {
|
ourRequestCode -> {
|
||||||
if (PermissionsUtils.isGranted(grantResults)) {
|
if (PermissionsUtils.isGranted(grantResults)) {
|
||||||
@@ -132,13 +116,20 @@ abstract class BaseFragment<V : BaseViewModel> : Fragment(), KodeinAware {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun onImageGalleryResult(imageUri: Uri?){ }
|
/**
|
||||||
open fun onImageGalleryResult(imageUris: List<Uri>?){ }
|
* Called on the result of image selection
|
||||||
|
*/
|
||||||
|
open fun onImageGalleryResult(imageUri: Uri?) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called on the result of multiple image selection
|
||||||
|
*/
|
||||||
|
open fun onImageGalleryResult(imageUris: List<Uri>?) {}
|
||||||
|
|
||||||
fun openGalleryForImage() {
|
fun openGalleryForImage() {
|
||||||
val intent = Intent(Intent.ACTION_PICK)
|
val intent = Intent(Intent.ACTION_PICK)
|
||||||
intent.type = "image/*"
|
intent.type = "image/*"
|
||||||
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, multipleImage);
|
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, multipleImage)
|
||||||
startActivityForResult(intent, IMAGE_SELECT_REQUEST_CODE)
|
startActivityForResult(intent, IMAGE_SELECT_REQUEST_CODE)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package h_mal.appttude.com.driver.base
|
package h_mal.appttude.com.base
|
||||||
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import h_mal.appttude.com.driver.data.ViewState
|
import h_mal.appttude.com.data.ViewState
|
||||||
import h_mal.appttude.com.driver.utils.Event
|
import h_mal.appttude.com.utils.Event
|
||||||
|
|
||||||
abstract class BaseViewModel: ViewModel(){
|
abstract class BaseViewModel: ViewModel(){
|
||||||
open val uiState: MutableLiveData<ViewState> = MutableLiveData()
|
open val uiState: MutableLiveData<ViewState> = MutableLiveData()
|
||||||
@@ -1,16 +1,21 @@
|
|||||||
package h_mal.appttude.com.driver.base
|
package h_mal.appttude.com.base
|
||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
|
import androidx.annotation.LayoutRes
|
||||||
import androidx.core.widget.doAfterTextChanged
|
import androidx.core.widget.doAfterTextChanged
|
||||||
import h_mal.appttude.com.driver.utils.PermissionsUtils.askForPermissions
|
import h_mal.appttude.com.data.UserAuthState
|
||||||
import h_mal.appttude.com.driver.utils.TextValidationUtils.validateEditText
|
import h_mal.appttude.com.ui.user.LoginActivity
|
||||||
|
import h_mal.appttude.com.utils.PermissionsUtils.askForPermissions
|
||||||
|
import h_mal.appttude.com.utils.TextValidationUtils.validateEditText
|
||||||
|
|
||||||
private const val IMAGE_PERMISSION_RESULT = 402
|
private const val IMAGE_PERMISSION_RESULT = 402
|
||||||
abstract class DataSubmissionBaseFragment<V : DataSubmissionBaseViewModel<T>, T: Any> : BaseFragment<BaseViewModel>(){
|
abstract class DataSubmissionBaseFragment<V : DataSubmissionBaseViewModel<T>, T: Any>
|
||||||
|
(@LayoutRes contentLayoutId: Int) : BaseFragment<BaseViewModel>(contentLayoutId){
|
||||||
|
|
||||||
var picUri: Uri? = null
|
var picUri: Uri? = null
|
||||||
|
|
||||||
@@ -19,10 +24,17 @@ abstract class DataSubmissionBaseFragment<V : DataSubmissionBaseViewModel<T>, T:
|
|||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
getViewModel().stateLiveData.observe(viewLifecycleOwner) {
|
||||||
|
if (it is UserAuthState.LoggedOut) {
|
||||||
|
val intent = Intent(requireContext(), LoginActivity::class.java)
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
startActivity(intent)
|
||||||
|
requireActivity().finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
getViewModel().getDataFromDatabase()
|
getViewModel().getDataFromDatabase()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
override fun onSuccess(data: Any?) {
|
override fun onSuccess(data: Any?) {
|
||||||
super.onSuccess(data)
|
super.onSuccess(data)
|
||||||
@@ -37,9 +49,7 @@ abstract class DataSubmissionBaseFragment<V : DataSubmissionBaseViewModel<T>, T:
|
|||||||
model = data
|
model = data
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun submit(){
|
open fun submit(){}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fun openGalleryWithPermissionRequest(){
|
fun openGalleryWithPermissionRequest(){
|
||||||
if (askForPermissions(Manifest.permission.READ_EXTERNAL_STORAGE, IMAGE_PERMISSION_RESULT)) {
|
if (askForPermissions(Manifest.permission.READ_EXTERNAL_STORAGE, IMAGE_PERMISSION_RESULT)) {
|
||||||
@@ -1,23 +1,25 @@
|
|||||||
package h_mal.appttude.com.driver.base
|
package h_mal.appttude.com.base
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
import com.google.firebase.database.DatabaseReference
|
import com.google.firebase.database.DatabaseReference
|
||||||
import com.google.firebase.storage.StorageReference
|
import com.google.firebase.storage.StorageReference
|
||||||
import h_mal.appttude.com.driver.data.FirebaseCompletion
|
import h_mal.appttude.com.data.*
|
||||||
import h_mal.appttude.com.driver.data.FirebaseDatabaseSource
|
import h_mal.appttude.com.utils.Coroutines.io
|
||||||
import h_mal.appttude.com.driver.data.FirebaseStorageSource
|
import h_mal.appttude.com.utils.DateUtils.getDateTimeStamp
|
||||||
import h_mal.appttude.com.driver.utils.Coroutines.io
|
import h_mal.appttude.com.utils.getDataFromDatabaseRef
|
||||||
import h_mal.appttude.com.driver.utils.DateUtils.getDateTimeStamp
|
|
||||||
import h_mal.appttude.com.driver.utils.getDataFromDatabaseRef
|
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
import kotlinx.coroutines.coroutineScope
|
import kotlinx.coroutines.coroutineScope
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
abstract class DataSubmissionBaseViewModel<T : Any>(
|
abstract class DataSubmissionBaseViewModel<T : Any>(
|
||||||
|
auth: FirebaseAuthentication,
|
||||||
private val database: FirebaseDatabaseSource,
|
private val database: FirebaseDatabaseSource,
|
||||||
private val storage: FirebaseStorageSource?
|
private val storage: FirebaseStorageSource?
|
||||||
) : BaseViewModel() {
|
) : BaseViewModel() {
|
||||||
|
val stateLiveData = auth.userStateListener()
|
||||||
|
val uid: String = auth.getUid() ?: ""
|
||||||
|
|
||||||
abstract val databaseRef: DatabaseReference
|
abstract val databaseRef: DatabaseReference
|
||||||
abstract val storageRef: StorageReference?
|
abstract val storageRef: StorageReference?
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package h_mal.appttude.com.driver.data
|
package h_mal.appttude.com.data
|
||||||
|
|
||||||
sealed class DataFieldState {
|
sealed class DataFieldState {
|
||||||
object DefaultState : DataFieldState()
|
object DefaultState : DataFieldState()
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package h_mal.appttude.com.driver.data
|
package h_mal.appttude.com.data
|
||||||
|
|
||||||
import com.google.firebase.database.DataSnapshot
|
import com.google.firebase.database.DataSnapshot
|
||||||
import com.google.firebase.database.DatabaseError
|
import com.google.firebase.database.DatabaseError
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
package h_mal.appttude.com.driver.data
|
package h_mal.appttude.com.data
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import com.google.android.gms.tasks.Task
|
import com.google.android.gms.tasks.Task
|
||||||
import com.google.firebase.auth.*
|
import com.google.firebase.auth.*
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
class FirebaseAuthSource: FirebaseAuthentication{
|
class FirebaseAuthSource: FirebaseAuthentication{
|
||||||
private val auth = FirebaseAuth.getInstance()
|
private val auth = FirebaseAuth.getInstance()
|
||||||
@@ -24,25 +25,32 @@ class FirebaseAuthSource: FirebaseAuthentication{
|
|||||||
override fun updateProfile(
|
override fun updateProfile(
|
||||||
name: String?,
|
name: String?,
|
||||||
profilePic: Uri?
|
profilePic: Uri?
|
||||||
): Task<Void>? {
|
): Task<Void> {
|
||||||
val profileUpdates = UserProfileChangeRequest.Builder().apply {
|
val profileUpdates = UserProfileChangeRequest.Builder().apply {
|
||||||
name?.let { setDisplayName(it) }
|
name?.let { setDisplayName(it) }
|
||||||
profilePic?.let { setPhotoUri(it) }
|
profilePic?.let { setPhotoUri(it) }
|
||||||
}.build()
|
}.build()
|
||||||
|
return getCurrentUser().updateProfile(profileUpdates)
|
||||||
return getUser()?.updateProfile(profileUpdates)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reauthenticate(
|
override fun reauthenticate(
|
||||||
email: String,
|
email: String,
|
||||||
password: String
|
password: String
|
||||||
): Task<Void>? {
|
): Task<Void> {
|
||||||
val credential = EmailAuthProvider.getCredential(email, password)
|
val credential = EmailAuthProvider.getCredential(email, password)
|
||||||
|
return getCurrentUser().reauthenticate(credential)
|
||||||
return getUser()?.reauthenticate(credential)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateEmail(email: String): Task<Void>? = getUser()?.updateEmail(email)
|
override fun updateEmail(email: String): Task<Void> = getCurrentUser().updateEmail(email)
|
||||||
override fun updatePassword(password: String): Task<Void>? = getUser()?.updatePassword(password)
|
override fun updatePassword(password: String): Task<Void> = getCurrentUser().updatePassword(password)
|
||||||
override fun deleteProfile() = getUser()?.delete()
|
override fun deleteProfile(): Task<Void> = getCurrentUser().delete()
|
||||||
|
|
||||||
|
|
||||||
|
override fun userStateListener() : FirebaseLiveData {
|
||||||
|
return FirebaseLiveData(auth)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getCurrentUser(): FirebaseUser{
|
||||||
|
return getUser() ?: throw IOException("User not signed in")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package h_mal.appttude.com.driver.data
|
package h_mal.appttude.com.data
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import com.google.android.gms.tasks.Task
|
import com.google.android.gms.tasks.Task
|
||||||
@@ -15,12 +15,13 @@ interface FirebaseAuthentication{
|
|||||||
fun updateProfile(
|
fun updateProfile(
|
||||||
name: String?,
|
name: String?,
|
||||||
profilePic: Uri?
|
profilePic: Uri?
|
||||||
): Task<Void>?
|
): Task<Void>
|
||||||
fun reauthenticate(
|
fun reauthenticate(
|
||||||
email: String,
|
email: String,
|
||||||
password: String
|
password: String
|
||||||
): Task<Void>?
|
): Task<Void>
|
||||||
fun updateEmail(email: String): Task<Void>?
|
fun updateEmail(email: String): Task<Void>
|
||||||
fun updatePassword(password: String): Task<Void>?
|
fun updatePassword(password: String): Task<Void>
|
||||||
fun deleteProfile(): Task<Void>?
|
fun deleteProfile(): Task<Void>
|
||||||
|
fun userStateListener() : FirebaseLiveData
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package h_mal.appttude.com.driver.data
|
package h_mal.appttude.com.data
|
||||||
|
|
||||||
sealed class FirebaseCompletion{
|
sealed class FirebaseCompletion{
|
||||||
object Default: FirebaseCompletion()
|
object Default: FirebaseCompletion()
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package h_mal.appttude.com.driver.data
|
package h_mal.appttude.com.data
|
||||||
|
|
||||||
import com.google.firebase.database.DatabaseReference
|
import com.google.firebase.database.DatabaseReference
|
||||||
import com.google.firebase.database.FirebaseDatabase
|
import com.google.firebase.database.FirebaseDatabase
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package h_mal.appttude.com.data
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import com.google.firebase.auth.FirebaseAuth
|
||||||
|
import com.google.firebase.auth.FirebaseUser
|
||||||
|
|
||||||
|
class FirebaseLiveData(
|
||||||
|
private val firebaseAuth: FirebaseAuth
|
||||||
|
): LiveData<UserAuthState>(){
|
||||||
|
|
||||||
|
override fun onActive() {
|
||||||
|
super.onActive()
|
||||||
|
firebaseAuth.addAuthStateListener(stateListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onInactive() {
|
||||||
|
super.onInactive()
|
||||||
|
firebaseAuth.removeAuthStateListener(stateListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val stateListener = FirebaseAuth.AuthStateListener { p0 ->
|
||||||
|
if (p0.currentUser == null) {
|
||||||
|
postValue(UserAuthState.LoggedOut)
|
||||||
|
} else {
|
||||||
|
postValue(UserAuthState.LoggedIn(p0.currentUser!!))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package h_mal.appttude.com.driver.data
|
package h_mal.appttude.com.data
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import com.google.firebase.storage.FirebaseStorage
|
import com.google.firebase.storage.FirebaseStorage
|
||||||
4
app/src/main/java/h_mal/appttude/com/data/Roles.kt
Normal file
4
app/src/main/java/h_mal/appttude/com/data/Roles.kt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
package h_mal.appttude.com.data
|
||||||
|
|
||||||
|
const val DRIVER = "driver"
|
||||||
|
const val ADMIN = "super_user"
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package h_mal.appttude.com.data
|
||||||
|
|
||||||
|
import com.google.firebase.auth.FirebaseUser
|
||||||
|
import h_mal.appttude.com.utils.Event
|
||||||
|
|
||||||
|
sealed class UserAuthState {
|
||||||
|
object LoggedOut : UserAuthState()
|
||||||
|
class LoggedIn(val data: FirebaseUser) : UserAuthState()
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package h_mal.appttude.com.driver.data
|
package h_mal.appttude.com.data
|
||||||
|
|
||||||
import h_mal.appttude.com.driver.utils.Event
|
import h_mal.appttude.com.utils.Event
|
||||||
|
|
||||||
|
|
||||||
sealed class ViewState {
|
sealed class ViewState {
|
||||||
@@ -1,30 +1,34 @@
|
|||||||
package h_mal.appttude.com.driver.Global
|
package h_mal.appttude.com.dialogs
|
||||||
|
|
||||||
|
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.app.DatePickerDialog
|
import android.app.DatePickerDialog
|
||||||
import android.app.DatePickerDialog.OnDateSetListener
|
import android.app.DatePickerDialog.OnDateSetListener
|
||||||
import android.content.Context
|
|
||||||
import android.icu.util.Calendar
|
import android.icu.util.Calendar
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.view.View
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import h_mal.appttude.com.driver.R
|
import h_mal.appttude.com.R
|
||||||
import h_mal.appttude.com.driver.utils.DateUtils
|
import h_mal.appttude.com.utils.DateUtils
|
||||||
|
|
||||||
|
|
||||||
private const val DATE_FORMAT = "dd/MM/yyyy"
|
private const val DATE_FORMAT = "dd/MM/yyyy"
|
||||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||||
class DateDialog(
|
class DateDialog(
|
||||||
private val editText: EditText
|
private val editText: EditText,
|
||||||
|
dateSelected:(String?) -> Unit
|
||||||
) : DatePickerDialog(editText.context, AlertDialog.THEME_HOLO_LIGHT) {
|
) : DatePickerDialog(editText.context, AlertDialog.THEME_HOLO_LIGHT) {
|
||||||
|
|
||||||
var dateSetListener: OnDateSetListener =
|
private val dateSetListener: OnDateSetListener =
|
||||||
OnDateSetListener { _, year, month, dayOfMonth ->
|
OnDateSetListener { _, year, month, dayOfMonth ->
|
||||||
val cal = Calendar.getInstance()
|
val cal = Calendar.getInstance()
|
||||||
cal.set(year, month + 1, dayOfMonth)
|
cal.set(year, month + 1, dayOfMonth)
|
||||||
|
|
||||||
editText.setText(DateUtils.parseCalenderIntoDateString(cal, DATE_FORMAT))
|
val date = DateUtils.parseCalenderIntoDateString(cal, DATE_FORMAT)
|
||||||
|
dateSelected(date)
|
||||||
|
editText.setText(date)
|
||||||
|
editText.error = null
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package h_mal.appttude.com.driver.dialogs
|
package h_mal.appttude.com.dialogs
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
@@ -10,11 +10,11 @@ object ExitDialog{
|
|||||||
fun Activity.displayExitDialog() = AlertDialog.Builder(this)
|
fun Activity.displayExitDialog() = AlertDialog.Builder(this)
|
||||||
.setTitle("Leave?")
|
.setTitle("Leave?")
|
||||||
.setMessage("Are you sure you want to exit?")
|
.setMessage("Are you sure you want to exit?")
|
||||||
.setNegativeButton(android.R.string.no, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.setPositiveButton(
|
.setPositiveButton(
|
||||||
android.R.string.yes
|
android.R.string.ok
|
||||||
) { _, _ ->
|
) { _, _ ->
|
||||||
this.finish()
|
finish()
|
||||||
exitProcess(0)
|
exitProcess(0)
|
||||||
}
|
}
|
||||||
.create()
|
.create()
|
||||||
@@ -1,227 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.Archive
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.BaseAdapter
|
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.LinearLayout
|
|
||||||
import android.widget.TextView
|
|
||||||
import com.squareup.picasso.Picasso
|
|
||||||
import h_mal.appttude.com.driver.Global.FirebaseClass
|
|
||||||
import h_mal.appttude.com.driver.Global.ImageSwiperClass
|
|
||||||
import h_mal.appttude.com.driver.ui.driver.MainActivity
|
|
||||||
import h_mal.appttude.com.driver.Objects.ArchiveObject
|
|
||||||
import h_mal.appttude.com.driver.Objects.InsuranceObject
|
|
||||||
import h_mal.appttude.com.driver.Objects.LogbookObject
|
|
||||||
import h_mal.appttude.com.driver.Objects.PrivateHireVehicleObject
|
|
||||||
import h_mal.appttude.com.driver.R
|
|
||||||
import h_mal.appttude.com.driver.model.DriversLicenseObject
|
|
||||||
import h_mal.appttude.com.driver.model.MotObject
|
|
||||||
import h_mal.appttude.com.driver.model.PrivateHireObject
|
|
||||||
import h_mal.appttude.com.driver.model.VehicleProfileObject
|
|
||||||
import h_mal.appttude.com.driver.utils.DateUtils.convertDateStringDatePattern
|
|
||||||
import java.text.ParseException
|
|
||||||
|
|
||||||
class ArchiveObjectListAdapter(
|
|
||||||
var archiveObject: ArchiveObject?,
|
|
||||||
var context: Context?,
|
|
||||||
var archiveString: String?
|
|
||||||
) : BaseAdapter() {
|
|
||||||
var size: Int = 0
|
|
||||||
lateinit var mKeys: Array<String>
|
|
||||||
private var dateArchivedText: TextView? = null
|
|
||||||
override fun getCount(): Int {
|
|
||||||
return size
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItem(position: Int): Any? {
|
|
||||||
when (archiveString) {
|
|
||||||
FirebaseClass.PRIVATE_HIRE_FIREBASE -> return archiveObject?.private_hire
|
|
||||||
?.get(mKeys[position])
|
|
||||||
FirebaseClass.DRIVERS_LICENSE_FIREBASE -> return archiveObject?.driver_license
|
|
||||||
?.get(mKeys[position])
|
|
||||||
FirebaseClass.VEHICLE_DETAILS_FIREBASE -> return archiveObject?.vehicle_details
|
|
||||||
?.get(mKeys[position])
|
|
||||||
FirebaseClass.MOT_FIREBASE -> return archiveObject?.mot_details?.get(mKeys[position])
|
|
||||||
FirebaseClass.INSURANCE_FIREBASE -> return archiveObject?.insurance_details?.get(
|
|
||||||
mKeys[position]
|
|
||||||
)
|
|
||||||
FirebaseClass.LOG_BOOK_FIREBASE -> return archiveObject?.log_book
|
|
||||||
?.get(mKeys.get(position))
|
|
||||||
FirebaseClass.PRIVATE_HIRE_VEHICLE_LICENSE -> return archiveObject?.ph_car?.get(mKeys[position])
|
|
||||||
else -> return mKeys[position]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItemId(position: Int): Long {
|
|
||||||
return position.toLong()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getView(position: Int, convertView: View, parent: ViewGroup): View {
|
|
||||||
var listItemView: View = convertView
|
|
||||||
if (listItemView == null) {
|
|
||||||
if (((archiveString == FirebaseClass.PRIVATE_HIRE_FIREBASE) || (archiveString == FirebaseClass.DRIVERS_LICENSE_FIREBASE) || (archiveString == FirebaseClass.MOT_FIREBASE) || (archiveString == FirebaseClass.LOG_BOOK_FIREBASE) || (archiveString == FirebaseClass.PRIVATE_HIRE_VEHICLE_LICENSE))) {
|
|
||||||
listItemView = LayoutInflater.from(context).inflate(
|
|
||||||
R.layout.archive_license_item, parent, false
|
|
||||||
)
|
|
||||||
val imageView: ImageView = listItemView.findViewById(R.id.image_archive)
|
|
||||||
dateArchivedText = listItemView.findViewById(R.id.date_archived)
|
|
||||||
val expiryHolder: LinearLayout = listItemView.findViewById(R.id.expiry_view)
|
|
||||||
val fieldTwo: LinearLayout = listItemView.findViewById(R.id.field_two_view)
|
|
||||||
val expiryText: TextView = listItemView.findViewById(R.id.exp_text)
|
|
||||||
val fiewTwoLable: TextView = listItemView.findViewById(R.id.field_two)
|
|
||||||
val fieldTwoText: TextView = listItemView.findViewById(R.id.field_two_text)
|
|
||||||
when (archiveString) {
|
|
||||||
// FirebaseClass.PRIVATE_HIRE_FIREBASE -> {
|
|
||||||
// expiryHolder.visibility = View.VISIBLE
|
|
||||||
// fieldTwo.visibility = View.VISIBLE
|
|
||||||
// val privateHireObject: PrivateHireObject =
|
|
||||||
// getItem(position) as PrivateHireObject
|
|
||||||
// Picasso.get().load(privateHireObject.phImageString)
|
|
||||||
// .placeholder(R.drawable.choice_img)
|
|
||||||
// .into(imageView)
|
|
||||||
// dateString(position)
|
|
||||||
// expiryText.text = privateHireObject.phExpiry
|
|
||||||
// fiewTwoLable.text = "Private Hire License No.:"
|
|
||||||
// fieldTwoText.text = privateHireObject.phNumber
|
|
||||||
// }
|
|
||||||
// FirebaseClass.DRIVERS_LICENSE_FIREBASE -> {
|
|
||||||
// expiryHolder.visibility = View.VISIBLE
|
|
||||||
// fieldTwo.visibility = View.VISIBLE
|
|
||||||
// val driversLicenseObject: DriversLicenseObject =
|
|
||||||
// getItem(position) as DriversLicenseObject
|
|
||||||
// Picasso.get().load(driversLicenseObject.licenseImageString)
|
|
||||||
// .placeholder(R.drawable.choice_img)
|
|
||||||
// .into(imageView)
|
|
||||||
// dateString(position)
|
|
||||||
// expiryText.text = driversLicenseObject.licenseExpiry
|
|
||||||
// fiewTwoLable.text = "License No.:"
|
|
||||||
// fieldTwoText.text = driversLicenseObject.licenseNumber
|
|
||||||
// }
|
|
||||||
// FirebaseClass.MOT_FIREBASE -> {
|
|
||||||
// expiryHolder.visibility = View.VISIBLE
|
|
||||||
// fieldTwo.visibility = View.GONE
|
|
||||||
// val motObject: MotObject = getItem(position) as MotObject
|
|
||||||
// Picasso.get().load(motObject.motImageString)
|
|
||||||
// .placeholder(R.drawable.choice_img)
|
|
||||||
// .into(imageView)
|
|
||||||
// dateString(position)
|
|
||||||
// expiryText.text = motObject.motExpiry
|
|
||||||
// }
|
|
||||||
// FirebaseClass.LOG_BOOK_FIREBASE -> {
|
|
||||||
// expiryHolder.visibility = View.GONE
|
|
||||||
// fieldTwo.visibility = View.VISIBLE
|
|
||||||
// val logbookObject: LogbookObject = getItem(position) as LogbookObject
|
|
||||||
// Picasso.get().load(logbookObject.photoString)
|
|
||||||
// .into(MainActivity.loadImage(imageView))
|
|
||||||
// dateString(position)
|
|
||||||
// fiewTwoLable.text = "V5C No.:"
|
|
||||||
// fieldTwoText.text = logbookObject.v5cnumber
|
|
||||||
// }
|
|
||||||
// FirebaseClass.PRIVATE_HIRE_VEHICLE_LICENSE -> {
|
|
||||||
// expiryHolder.visibility = View.VISIBLE
|
|
||||||
// fieldTwo.visibility = View.VISIBLE
|
|
||||||
// val privateHireVehicleObject: PrivateHireVehicleObject =
|
|
||||||
// getItem(position) as PrivateHireVehicleObject
|
|
||||||
// Picasso.get().load(privateHireVehicleObject.phCarImageString)
|
|
||||||
// .into(MainActivity.loadImage(imageView))
|
|
||||||
// dateString(position)
|
|
||||||
// expiryText.text = privateHireVehicleObject.phCarExpiry
|
|
||||||
// fiewTwoLable.text = "Private Hire Vehicle License No.:"
|
|
||||||
// fieldTwoText.text = privateHireVehicleObject.phCarNumber
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
} else if ((archiveString == FirebaseClass.INSURANCE_FIREBASE)) {
|
|
||||||
listItemView = LayoutInflater.from(context).inflate(
|
|
||||||
R.layout.archive_insurance_item, parent, false
|
|
||||||
)
|
|
||||||
val holder: View = listItemView.findViewById(R.id.image_pager)
|
|
||||||
val swiperClass: ImageSwiperClass = ImageSwiperClass(context, holder)
|
|
||||||
// swiperClass.hideDelete();
|
|
||||||
listItemView.findViewById<View>(R.id.delete).visibility = View.GONE
|
|
||||||
// holder.findViewById(R.id.delete).setVisibility(View.INVISIBLE);
|
|
||||||
dateArchivedText = listItemView.findViewById(R.id.date_archived)
|
|
||||||
dateString(position)
|
|
||||||
val expiryText: TextView = listItemView.findViewById(R.id.exp_text)
|
|
||||||
val fieldTwoText: TextView = listItemView.findViewById(R.id.archive_insurer)
|
|
||||||
val insuranceObject: InsuranceObject = getItem(position) as InsuranceObject
|
|
||||||
// swiperClass.reinstantiateList(insuranceObject.photoStrings)
|
|
||||||
expiryText.text = insuranceObject.expiryDate
|
|
||||||
fieldTwoText.text = insuranceObject.insurerName
|
|
||||||
} else if ((archiveString == FirebaseClass.VEHICLE_DETAILS_FIREBASE)) {
|
|
||||||
listItemView = LayoutInflater.from(context).inflate(
|
|
||||||
R.layout.archive_vehicle_item, parent, false
|
|
||||||
)
|
|
||||||
dateArchivedText = listItemView.findViewById(R.id.date_archived)
|
|
||||||
dateString(position)
|
|
||||||
val numberPlate: TextView = listItemView.findViewById(R.id.number_plate)
|
|
||||||
val keeperName: TextView = listItemView.findViewById(R.id.keeper_name)
|
|
||||||
val keeperAddress: TextView = listItemView.findViewById(R.id.keeper_address)
|
|
||||||
val carText: TextView = listItemView.findViewById(R.id.car_text_arch)
|
|
||||||
val carColour: TextView = listItemView.findViewById(R.id.car_colour)
|
|
||||||
val carSeized: TextView = listItemView.findViewById(R.id.seized_checkbox)
|
|
||||||
val startDate: TextView = listItemView.findViewById(R.id.first_date)
|
|
||||||
val vehicleProfileObject: VehicleProfileObject =
|
|
||||||
getItem(position) as VehicleProfileObject
|
|
||||||
numberPlate.text = vehicleProfileObject.reg
|
|
||||||
keeperName.text = vehicleProfileObject.keeperName
|
|
||||||
keeperAddress.text = vehicleProfileObject.keeperAddress + "\n" + vehicleProfileObject.keeperPostCode
|
|
||||||
carText.text = vehicleProfileObject.make + " " + vehicleProfileObject.model
|
|
||||||
carColour.text = vehicleProfileObject.colour
|
|
||||||
val s: String
|
|
||||||
if (vehicleProfileObject.isSeized) {
|
|
||||||
s = "Yes"
|
|
||||||
} else {
|
|
||||||
s = "No"
|
|
||||||
}
|
|
||||||
carSeized.text = s
|
|
||||||
startDate.text = vehicleProfileObject.startDate
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return listItemView
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun dateString(position: Int) {
|
|
||||||
var success: Boolean = true
|
|
||||||
try {
|
|
||||||
dateArchivedText!!.text = mKeys[position].convertDateStringDatePattern("yyyyMMdd_HHmmss", "dd/MM/yyyy")
|
|
||||||
} catch (e: ParseException) {
|
|
||||||
e.printStackTrace()
|
|
||||||
success = false
|
|
||||||
} finally {
|
|
||||||
if (!success) {
|
|
||||||
dateArchivedText!!.text = mKeys.get(position).substring(0, 8)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private val TAG: String = "ArchiveObjectListAdapte"
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
|
||||||
archiveObject?.apply {
|
|
||||||
val map = when (archiveString) {
|
|
||||||
FirebaseClass.PRIVATE_HIRE_FIREBASE -> private_hire
|
|
||||||
FirebaseClass.DRIVERS_LICENSE_FIREBASE -> driver_license
|
|
||||||
FirebaseClass.VEHICLE_DETAILS_FIREBASE -> vehicle_details
|
|
||||||
FirebaseClass.MOT_FIREBASE -> mot_details
|
|
||||||
FirebaseClass.INSURANCE_FIREBASE -> insurance_details
|
|
||||||
FirebaseClass.LOG_BOOK_FIREBASE -> log_book
|
|
||||||
FirebaseClass.PRIVATE_HIRE_VEHICLE_LICENSE -> ph_car
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
setUp(map)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setUp(map: HashMap<String,*>?){
|
|
||||||
size = map?.size ?: 0
|
|
||||||
map?.keys?.toTypedArray()?.let{
|
|
||||||
mKeys = it
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.Global
|
|
||||||
|
|
||||||
import h_mal.appttude.com.driver.Objects.ApprovalsObject
|
|
||||||
import h_mal.appttude.com.driver.Objects.WholeDriverObject
|
|
||||||
import h_mal.appttude.com.driver.R
|
|
||||||
|
|
||||||
|
|
||||||
class ApprovalsClass {
|
|
||||||
fun getOverApprovalStatusCode(wholeDriverObject: WholeDriverObject?): Int {
|
|
||||||
if (wholeDriverObject!!.approvalsObject != null) {
|
|
||||||
val approvalsObject: ApprovalsObject = wholeDriverObject!!.approvalsObject!!
|
|
||||||
val ints: IntArray = intArrayOf(
|
|
||||||
approvalsObject.driver_details_approval,
|
|
||||||
approvalsObject.driver_license_approval,
|
|
||||||
approvalsObject.private_hire_approval,
|
|
||||||
approvalsObject.vehicle_details_approval,
|
|
||||||
approvalsObject.insurance_details_approval,
|
|
||||||
approvalsObject.mot_details_approval,
|
|
||||||
approvalsObject.log_book_approval,
|
|
||||||
approvalsObject.ph_car_approval
|
|
||||||
)
|
|
||||||
return setImageResource(mode(ints))
|
|
||||||
}
|
|
||||||
return setImageResource(FirebaseClass.NO_DATE_PRESENT)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setStatusCode(userId: String?, approvalNameString: String, status: Int) {
|
|
||||||
// if (!(approvalNameString == "")) {
|
|
||||||
// MainActivity.mDatabase!!.child(FirebaseClass.USER_FIREBASE)
|
|
||||||
// .child((userId)!!).child(FirebaseClass.USER_APPROVALS)
|
|
||||||
// .child(approvalNameString)
|
|
||||||
// .setValue(status).addOnCompleteListener { task ->
|
|
||||||
// if (task.isSuccessful) {
|
|
||||||
// } else {
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setImageResource(statusCode: Int): Int {
|
|
||||||
val imageResource: Int
|
|
||||||
when (statusCode) {
|
|
||||||
FirebaseClass.APPROVAL_PENDING -> imageResource = R.drawable.pending
|
|
||||||
FirebaseClass.APPROVAL_DENIED -> imageResource = R.drawable.denied
|
|
||||||
FirebaseClass.APPROVED -> imageResource = R.drawable.approved
|
|
||||||
else -> imageResource = R.drawable.zero
|
|
||||||
}
|
|
||||||
return imageResource
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
fun mode(array: IntArray): Int {
|
|
||||||
var mode: Int = array.get(0)
|
|
||||||
var maxCount: Int = 0
|
|
||||||
if (matchedArray(array, 3)) {
|
|
||||||
return 3
|
|
||||||
} else if (matchedArray(array, 0)) {
|
|
||||||
return 0
|
|
||||||
} else {
|
|
||||||
for (i in array.indices) {
|
|
||||||
val value: Int = array.get(i)
|
|
||||||
var count: Int = 1
|
|
||||||
for (j in array.indices) {
|
|
||||||
if (array.get(j) == value) count++
|
|
||||||
if (count > maxCount) {
|
|
||||||
mode = value
|
|
||||||
maxCount = count
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mode == 3) {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mode
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun matchedArray(array: IntArray, match: Int): Boolean {
|
|
||||||
for (i: Int in array) {
|
|
||||||
if (i != match) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.Global
|
|
||||||
|
|
||||||
import android.app.AlertDialog
|
|
||||||
import android.content.Context
|
|
||||||
import android.os.Bundle
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import h_mal.appttude.com.driver.utils.UPLOAD_NEW
|
|
||||||
|
|
||||||
|
|
||||||
class ArchiveClass {
|
|
||||||
fun archiveRecord(UID: String?, item: String?, `object`: Any?) {
|
|
||||||
// val toPath: DatabaseReference =
|
|
||||||
// MainActivity.mDatabase!!.child(FirebaseClass.USER_FIREBASE).child(
|
|
||||||
// (UID)!!
|
|
||||||
// )
|
|
||||||
// .child(FirebaseClass.ARCHIVE_FIREBASE).child((item)!!)
|
|
||||||
// toPath.child(MainActivity.dateTimeStamp).setValue(`object`)
|
|
||||||
// .addOnCompleteListener { task ->
|
|
||||||
// if (task.isSuccessful) {
|
|
||||||
// Log.i(TAG, "onComplete: archive successful")
|
|
||||||
// } else {
|
|
||||||
// Log.i(TAG, "onComplete: archive unsuccessful")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun openDialogArchive(context: Context?, `object`: Any?, fragment: Fragment) {
|
|
||||||
if (`object` == null) {
|
|
||||||
// executeFragment(fragment)
|
|
||||||
} else {
|
|
||||||
val builder: AlertDialog.Builder = AlertDialog.Builder(context)
|
|
||||||
builder.setMessage("Do you want to View/Edit or Upload new?")
|
|
||||||
.setPositiveButton("View/Edit"
|
|
||||||
) { _, _ ->
|
|
||||||
// executeFragment(fragment)
|
|
||||||
}
|
|
||||||
.setNegativeButton("Upload New"
|
|
||||||
) { _, _ ->
|
|
||||||
val bundle = Bundle()
|
|
||||||
bundle.putString(UPLOAD_NEW, "Yes")
|
|
||||||
fragment.arguments = bundle
|
|
||||||
// executeFragment(fragment)
|
|
||||||
}
|
|
||||||
.create().show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun openDialogArchive(context: Context?, `object`: Any?, user: String?, fragment: Fragment?) {
|
|
||||||
val bundle: Bundle = Bundle()
|
|
||||||
bundle.putString("user_id", user)
|
|
||||||
fragment!!.arguments = bundle
|
|
||||||
if (`object` == null) {
|
|
||||||
// executeFragment(fragment)
|
|
||||||
} else {
|
|
||||||
val builder: AlertDialog.Builder = AlertDialog.Builder(context)
|
|
||||||
builder.setMessage("Do you want to View/Edit or Upload new?")
|
|
||||||
.setPositiveButton("View/Edit"
|
|
||||||
) { _, _ ->
|
|
||||||
// executeFragment(fragment)
|
|
||||||
}
|
|
||||||
.setNegativeButton("Upload New"
|
|
||||||
) { _, _ ->
|
|
||||||
bundle.putString(UPLOAD_NEW, "Yes")
|
|
||||||
// executeFragment(fragment)
|
|
||||||
}
|
|
||||||
.create().show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.Global
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.net.Uri
|
|
||||||
|
|
||||||
class FirebaseClass constructor(var context: Context?, var filePath: Uri?, var delegate: Response) {
|
|
||||||
open interface Response {
|
|
||||||
fun processFinish(output: Uri?)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun uploadImage(path: String, name: String) {
|
|
||||||
// if (filePath != null) {
|
|
||||||
// val progressDialog: ProgressDialog = ProgressDialog(context)
|
|
||||||
// progressDialog.setTitle("Uploading...")
|
|
||||||
// progressDialog.show()
|
|
||||||
// val ref: StorageReference = MainActivity.storageReference!!.child(
|
|
||||||
// ("images/" + MainActivity.auth!!.currentUser!!
|
|
||||||
// .uid + "/" + path
|
|
||||||
// + "/" + name)
|
|
||||||
// )
|
|
||||||
// val uploadTask: UploadTask = ref.putFile(filePath!!)
|
|
||||||
// uploadTask.addOnProgressListener { taskSnapshot ->
|
|
||||||
// val progress: Double =
|
|
||||||
// (100.0 * taskSnapshot.bytesTransferred / taskSnapshot
|
|
||||||
// .totalByteCount)
|
|
||||||
// progressDialog.setMessage("Uploaded " + progress.toInt() + "%")
|
|
||||||
// }.continueWithTask { task ->
|
|
||||||
// if (!task.isSuccessful) {
|
|
||||||
// throw (task.exception)!!
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Continue with the task to get the download URL
|
|
||||||
// ref.downloadUrl
|
|
||||||
// }.addOnCompleteListener { task ->
|
|
||||||
// if (task.isSuccessful) {
|
|
||||||
// delegate.processFinish(task.result)
|
|
||||||
// progressDialog.dismiss()
|
|
||||||
// context?.displayToast("Uploaded Successfully")
|
|
||||||
// println("onComplete: uploaded Successful uri: " + task.result)
|
|
||||||
// } else {
|
|
||||||
// delegate.processFinish(null)
|
|
||||||
// progressDialog.dismiss()
|
|
||||||
// context?.displayToast("Uploaded Successfully")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val USER_FIREBASE: String = "user"
|
|
||||||
val DRIVER_FIREBASE: String = "driver_profile"
|
|
||||||
val DRIVER_DETAILS_FIREBASE: String = "driver_details"
|
|
||||||
val PRIVATE_HIRE_FIREBASE: String = "private_hire"
|
|
||||||
val DRIVERS_LICENSE_FIREBASE: String = "driver_license"
|
|
||||||
val DRIVER_STATUS: String = "driver_status"
|
|
||||||
val USER_APPROVALS: String = "approvalsObject"
|
|
||||||
val APPROVAL_CONSTANT: String = "_approval"
|
|
||||||
val ARCHIVE_FIREBASE: String = "archive"
|
|
||||||
val DRIVER_NUMBER: String = "driver_number"
|
|
||||||
val VEHICLE_FIREBASE: String = "vehicle_profile"
|
|
||||||
val MOT_FIREBASE: String = "mot_details"
|
|
||||||
val VEHICLE_DETAILS_FIREBASE: String = "vehicle_details"
|
|
||||||
val INSURANCE_FIREBASE: String = "insurance_details"
|
|
||||||
val LOG_BOOK_FIREBASE: String = "log_book"
|
|
||||||
val PRIVATE_HIRE_VEHICLE_LICENSE: String = "private_hire_vehicle"
|
|
||||||
val NO_DATE_PRESENT: Int = 0
|
|
||||||
val APPROVAL_PENDING: Int = 1
|
|
||||||
val APPROVAL_DENIED: Int = 2
|
|
||||||
val APPROVED: Int = 3
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.Global
|
|
||||||
|
|
||||||
import android.Manifest
|
|
||||||
import android.app.Dialog
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.DialogInterface
|
|
||||||
import android.content.Intent
|
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.icu.text.SimpleDateFormat
|
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.os.Environment
|
|
||||||
import android.provider.MediaStore
|
|
||||||
import android.widget.Button
|
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.core.app.ActivityCompat
|
|
||||||
import androidx.core.content.FileProvider
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import h_mal.appttude.com.driver.R
|
|
||||||
import java.io.File
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
|
|
||||||
class ImageSelectorDialog : Dialog {
|
|
||||||
private val TAG: String = this.javaClass.simpleName
|
|
||||||
private var saveFileName: String
|
|
||||||
var fragment: Fragment? = null
|
|
||||||
|
|
||||||
constructor(context: Context) : super(context) {
|
|
||||||
saveFileName = "default_name"
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(context: Context, themeResId: Int) : super(context, themeResId) {
|
|
||||||
saveFileName = "default_name"
|
|
||||||
}
|
|
||||||
|
|
||||||
protected constructor(
|
|
||||||
context: Context,
|
|
||||||
cancelable: Boolean,
|
|
||||||
cancelListener: DialogInterface.OnCancelListener?
|
|
||||||
) : super(context, cancelable, cancelListener) {
|
|
||||||
saveFileName = "default_name"
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
setContentView(R.layout.address_dialog)
|
|
||||||
|
|
||||||
//check if we have we have storage rights
|
|
||||||
val permissionPic: Int = ActivityCompat.checkSelfPermission(
|
|
||||||
context,
|
|
||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
|
||||||
)
|
|
||||||
val permissionCam: Int =
|
|
||||||
ActivityCompat.checkSelfPermission(context, Manifest.permission.CAMERA)
|
|
||||||
// fragment = MainActivity.mainFragmentManager.fragments[0]
|
|
||||||
val upload: Button = findViewById(R.id.upload)
|
|
||||||
val takePic: Button = findViewById(R.id.take_pic)
|
|
||||||
upload.setOnClickListener {
|
|
||||||
if (permissionPic == PackageManager.PERMISSION_GRANTED) {
|
|
||||||
chooseImage()
|
|
||||||
} else {
|
|
||||||
Toast.makeText(context, "Storage permissions required", Toast.LENGTH_SHORT)
|
|
||||||
.show()
|
|
||||||
ActivityCompat.requestPermissions(
|
|
||||||
(fragment!!.requireActivity()),
|
|
||||||
arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
|
|
||||||
STORAGE_PERMISSION_CODE
|
|
||||||
)
|
|
||||||
}
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
takePic.setOnClickListener {
|
|
||||||
if (permissionCam == PackageManager.PERMISSION_GRANTED) {
|
|
||||||
val cameraIntent: Intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
|
|
||||||
val file: File = createFile()
|
|
||||||
photoURI = Uri.fromFile(file)
|
|
||||||
val imageUri: Uri = FileProvider.getUriForFile(
|
|
||||||
context,
|
|
||||||
"h_mal.appttude.com.driver",
|
|
||||||
file
|
|
||||||
)
|
|
||||||
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri)
|
|
||||||
fragment!!.startActivityForResult(cameraIntent, CAMERA_REQUEST)
|
|
||||||
} else {
|
|
||||||
Toast.makeText(context, "Camera Permissions required", Toast.LENGTH_SHORT)
|
|
||||||
.show()
|
|
||||||
ActivityCompat.requestPermissions(
|
|
||||||
(fragment!!.requireActivity()), arrayOf(Manifest.permission.CAMERA),
|
|
||||||
MY_CAMERA_PERMISSION_CODE
|
|
||||||
)
|
|
||||||
}
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setImageName(saveFileName: String) {
|
|
||||||
this.saveFileName = saveFileName
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun createFile(): File {
|
|
||||||
//create directory
|
|
||||||
val root: File = context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
|
|
||||||
//create file
|
|
||||||
val sdf: SimpleDateFormat = SimpleDateFormat("yyyyMMdd_HHmm")
|
|
||||||
val currentDateandTime: String = sdf.format(Date())
|
|
||||||
val fname: String = saveFileName + currentDateandTime
|
|
||||||
val image: File = File(root, fname)
|
|
||||||
return image
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun chooseImage() {
|
|
||||||
val intent: Intent = Intent()
|
|
||||||
intent.type = "image/*"
|
|
||||||
intent.action = Intent.ACTION_GET_CONTENT
|
|
||||||
fragment!!.startActivityForResult(
|
|
||||||
Intent.createChooser(intent, "Select Picture"),
|
|
||||||
PICK_IMAGE_REQUEST
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val PICK_IMAGE_REQUEST: Int = 71
|
|
||||||
val CAMERA_REQUEST: Int = 1888
|
|
||||||
val MY_CAMERA_PERMISSION_CODE: Int = 100
|
|
||||||
val STORAGE_PERMISSION_CODE: Int = 101
|
|
||||||
var photoURI: Uri? = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.Global
|
|
||||||
|
|
||||||
import android.Manifest
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.Intent
|
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Environment
|
|
||||||
import android.provider.MediaStore
|
|
||||||
import android.view.View
|
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.core.app.ActivityCompat
|
|
||||||
import h_mal.appttude.com.driver.utils.DateUtils.getDateStamp
|
|
||||||
import h_mal.appttude.com.driver.utils.DateUtils.getDateTimeStamp
|
|
||||||
import java.io.File
|
|
||||||
import java.io.FileOutputStream
|
|
||||||
import java.io.IOException
|
|
||||||
|
|
||||||
class ImageSelectorResults // public FilepathResponse delegate;
|
|
||||||
{
|
|
||||||
lateinit var activity: Activity
|
|
||||||
|
|
||||||
interface FilepathResponse {
|
|
||||||
fun processFinish(output: Uri?)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Results(
|
|
||||||
activity: Activity, requestCode: Int, resultCode: Int, data: Intent?, filePath: Uri?,
|
|
||||||
imageView: ImageView?, delegate: FilepathResponse
|
|
||||||
) {
|
|
||||||
var filePath: Uri? = filePath
|
|
||||||
this.activity = activity
|
|
||||||
if ((requestCode == ImageSelectorDialog.PICK_IMAGE_REQUEST) && (resultCode == Activity.RESULT_OK
|
|
||||||
) && (data != null) && (data.data != null)
|
|
||||||
) {
|
|
||||||
val uri = data.data
|
|
||||||
var bitmap: Bitmap? = null
|
|
||||||
try {
|
|
||||||
bitmap =
|
|
||||||
MediaStore.Images.Media.getBitmap(activity.contentResolver, uri)
|
|
||||||
if (imageView!!.visibility != View.VISIBLE) {
|
|
||||||
imageView.visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
imageView.setImageBitmap(bitmap)
|
|
||||||
} catch (e: IOException) {
|
|
||||||
e.printStackTrace()
|
|
||||||
} finally {
|
|
||||||
if (bitmap != null) {
|
|
||||||
delegate.processFinish(uri)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (requestCode == ImageSelectorDialog.CAMERA_REQUEST && resultCode == Activity.RESULT_OK) {
|
|
||||||
//check if we have we have storage rights
|
|
||||||
val permission: Int = ActivityCompat.checkSelfPermission(
|
|
||||||
(activity)!!,
|
|
||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
|
||||||
)
|
|
||||||
if (permission != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
Toast.makeText(activity, "Storage permissions not granted", Toast.LENGTH_SHORT)
|
|
||||||
.show()
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
val f: File =
|
|
||||||
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
|
|
||||||
val fname: String = "driver" + getDateStamp() + ".jpg"
|
|
||||||
val image = File(f, fname)
|
|
||||||
val fileOutputStream = FileOutputStream(image)
|
|
||||||
filePath = ImageSelectorDialog.photoURI
|
|
||||||
val bitmap: Bitmap = MediaStore.Images.Media
|
|
||||||
.getBitmap(
|
|
||||||
activity.contentResolver,
|
|
||||||
ImageSelectorDialog.photoURI
|
|
||||||
)
|
|
||||||
imageView!!.setImageBitmap(bitmap)
|
|
||||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fileOutputStream)
|
|
||||||
fileOutputStream.flush()
|
|
||||||
fileOutputStream.close()
|
|
||||||
galleryAddPic()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delegate.processFinish(filePath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Results(
|
|
||||||
activity: Activity,
|
|
||||||
requestCode: Int,
|
|
||||||
resultCode: Int,
|
|
||||||
data: Intent?,
|
|
||||||
filePath: Uri?,
|
|
||||||
delegate: FilepathResponse
|
|
||||||
) {
|
|
||||||
var filePath: Uri? = filePath
|
|
||||||
this.activity = activity
|
|
||||||
if ((requestCode == ImageSelectorDialog.PICK_IMAGE_REQUEST) && (resultCode == Activity.RESULT_OK
|
|
||||||
) && (data != null) && (data.data != null)
|
|
||||||
) {
|
|
||||||
filePath = data.data
|
|
||||||
var bitmap: Bitmap? = null
|
|
||||||
try {
|
|
||||||
bitmap =
|
|
||||||
MediaStore.Images.Media.getBitmap(activity.contentResolver, filePath)
|
|
||||||
} catch (e: IOException) {
|
|
||||||
e.printStackTrace()
|
|
||||||
} finally {
|
|
||||||
if (bitmap != null) {
|
|
||||||
delegate.processFinish(filePath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (requestCode == ImageSelectorDialog.CAMERA_REQUEST && resultCode == Activity.RESULT_OK) {
|
|
||||||
//check if we have we have storage rights
|
|
||||||
val permission: Int = ActivityCompat.checkSelfPermission(
|
|
||||||
(activity),
|
|
||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
|
||||||
)
|
|
||||||
if (permission != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
Toast.makeText(activity, "Storage permissions not granted", Toast.LENGTH_SHORT)
|
|
||||||
.show()
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
val f: File =
|
|
||||||
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
|
|
||||||
val fname: String = "driver" + getDateTimeStamp() + ".jpg"
|
|
||||||
val image: File = File(f, fname)
|
|
||||||
val fileOutputStream: FileOutputStream = FileOutputStream(image)
|
|
||||||
filePath = ImageSelectorDialog.photoURI
|
|
||||||
val bitmap: Bitmap = MediaStore.Images.Media
|
|
||||||
.getBitmap(
|
|
||||||
activity.contentResolver,
|
|
||||||
ImageSelectorDialog.photoURI
|
|
||||||
)
|
|
||||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fileOutputStream)
|
|
||||||
fileOutputStream.flush()
|
|
||||||
fileOutputStream.close()
|
|
||||||
galleryAddPic()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delegate.processFinish(filePath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun galleryAddPic() {
|
|
||||||
val mediaScanIntent: Intent = Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE)
|
|
||||||
val f: File = File(ImageSelectorDialog.photoURI!!.path)
|
|
||||||
val contentUri: Uri = Uri.fromFile(f)
|
|
||||||
mediaScanIntent.data = contentUri
|
|
||||||
activity.sendBroadcast(mediaScanIntent)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.Global
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.ContextWrapper
|
|
||||||
import android.view.View
|
|
||||||
import android.widget.ImageView
|
|
||||||
import h_mal.appttude.com.driver.R
|
|
||||||
|
|
||||||
|
|
||||||
class ImageSwiperClass(
|
|
||||||
private val context: Context?,
|
|
||||||
wholeView: View
|
|
||||||
) : ContextWrapper(context) {
|
|
||||||
private var left: ImageView = wholeView.findViewById(R.id.left)
|
|
||||||
private var right: ImageView = wholeView.findViewById(R.id.right)
|
|
||||||
|
|
||||||
var list: List<Any>? = null
|
|
||||||
|
|
||||||
// fun addLocalString(uris: List<Uri>) {
|
|
||||||
// list = uris
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// fun addFirebaseStrings(uris: List<String>) {
|
|
||||||
// list = uris
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private var adapter: SlidingImageViewAdapter? = null
|
|
||||||
// lateinit var viewPager: ViewPager
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// fun reinstantiateList(imageStrings: MutableList<String?>?) {
|
|
||||||
// this.imageStrings = imageStrings
|
|
||||||
// adapter = SlidingImageViewAdapter()
|
|
||||||
// viewPager.adapter = adapter
|
|
||||||
// setArrows()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// fun hideDelete() {
|
|
||||||
// delete.hide()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private val leftClick: View.OnClickListener = View.OnClickListener {
|
|
||||||
// viewPager.currentItem = viewPager.currentItem - 1
|
|
||||||
// setArrows()
|
|
||||||
// }
|
|
||||||
// private val rightClick: View.OnClickListener = View.OnClickListener {
|
|
||||||
// viewPager.currentItem = viewPager.currentItem + 1
|
|
||||||
// setArrows()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private fun deleteDialog(position: Int) {
|
|
||||||
// val builder: AlertDialog.Builder = AlertDialog.Builder(context)
|
|
||||||
// builder.setMessage("Are you sure you want to delete?")
|
|
||||||
// .setPositiveButton(
|
|
||||||
// android.R.string.ok
|
|
||||||
// ) { _, _ ->
|
|
||||||
// imageStrings!!.removeAt(position)
|
|
||||||
// viewPager.adapter = adapter
|
|
||||||
// // adapter.notifyDataSetChanged();
|
|
||||||
// }
|
|
||||||
// .setNegativeButton(android.R.string.cancel, null)
|
|
||||||
// .create()
|
|
||||||
// .show()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private fun setArrows() {
|
|
||||||
// with(list) {
|
|
||||||
// when (list) {
|
|
||||||
// isNullOrEmpty() -> { }
|
|
||||||
// isNotEmpty() -> { }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (list?.isNotEmpty()) {
|
|
||||||
// //left arrow
|
|
||||||
// if (viewPager.currentItem > 0) {
|
|
||||||
// setAnimation(left, true)
|
|
||||||
// } else {
|
|
||||||
// setAnimation(left, false)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //right
|
|
||||||
// if (viewPager.currentItem == imageStrings!!.size - 1) {
|
|
||||||
// setAnimation(right, false)
|
|
||||||
// } else {
|
|
||||||
// setAnimation(right, true)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (imageStrings == null) {
|
|
||||||
// setAnimation(left, false)
|
|
||||||
// setAnimation(right, false)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private fun setAnimation(view: ImageView, up: Boolean) {
|
|
||||||
// val start: Float
|
|
||||||
// val finish: Float
|
|
||||||
// if (up) {
|
|
||||||
// start = 0.2f
|
|
||||||
// finish = 1.0f
|
|
||||||
// } else {
|
|
||||||
// start = 1.0f
|
|
||||||
// finish = 0.2f
|
|
||||||
// }
|
|
||||||
// val animation1 = AlphaAnimation(start, finish)
|
|
||||||
// animation1.duration = 500
|
|
||||||
// animation1.fillAfter = true
|
|
||||||
// view.alpha = finish
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// internal inner class SlidingImageViewAdapter : PagerAdapter() {
|
|
||||||
//
|
|
||||||
// override fun getCount(): Int = list?.size ?: 0
|
|
||||||
//
|
|
||||||
// override fun destroyItem(container: ViewGroup, position: Int, item: Any) {
|
|
||||||
// container.removeView(item as View?)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun isViewFromObject(view: View, o: Any): Boolean = view == o
|
|
||||||
//
|
|
||||||
// override fun instantiateItem(container: ViewGroup, position: Int): Any {
|
|
||||||
// val pagerPic: View =
|
|
||||||
// LayoutInflater.from(context).inflate(R.layout.insurance_item, container, false)
|
|
||||||
// setArrows()
|
|
||||||
// if (imageStrings != null && imageStrings!!.size > 0) {
|
|
||||||
// mainImage = pagerPic.rootView.findViewById(R.id.main_image)
|
|
||||||
// Picasso.get().load(imageStrings!!.get(position))
|
|
||||||
// .placeholder(R.drawable.choice_img)
|
|
||||||
// .into(MainActivity.loadImage(mainImage))
|
|
||||||
// }
|
|
||||||
// container.addView(pagerPic, 0)
|
|
||||||
// return pagerPic
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// init {
|
|
||||||
// left.setOnClickListener(leftClick)
|
|
||||||
// right.setOnClickListener(rightClick)
|
|
||||||
// viewPager = wholeView.findViewById(R.id.view_pager)
|
|
||||||
// delete = wholeView.findViewById(R.id.delete)
|
|
||||||
// viewPager.addOnPageChangeListener(object : OnPageChangeListener {
|
|
||||||
// override fun onPageScrolled(i: Int, v: Float, i1: Int) {
|
|
||||||
// val animation1: AlphaAnimation = AlphaAnimation(0.2f, 1.0f)
|
|
||||||
// animation1.duration = 200
|
|
||||||
// animation1.fillAfter = true
|
|
||||||
// delete.startAnimation(animation1)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onPageSelected(i: Int) {
|
|
||||||
// setArrows()
|
|
||||||
// delete.setOnClickListener { deleteDialog(i) }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onPageScrollStateChanged(i: Int) {}
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.Global
|
|
||||||
|
|
||||||
import android.content.Intent
|
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.os.Environment
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.view.WindowManager
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import com.github.chrisbanes.photoview.PhotoView
|
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
||||||
import h_mal.appttude.com.driver.R
|
|
||||||
import h_mal.appttude.com.driver.utils.DateUtils
|
|
||||||
import java.io.File
|
|
||||||
import java.io.FileNotFoundException
|
|
||||||
import java.io.FileOutputStream
|
|
||||||
import java.io.IOException
|
|
||||||
|
|
||||||
|
|
||||||
class ImageViewClass {
|
|
||||||
fun open(bitmap: Bitmap?) {
|
|
||||||
Companion.bitmap = bitmap
|
|
||||||
// executeFragment(ImageViewerFragment())
|
|
||||||
}
|
|
||||||
|
|
||||||
class ImageViewerFragment : Fragment() {
|
|
||||||
private lateinit var viewer: View
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateView(
|
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
|
||||||
savedInstanceState: Bundle?
|
|
||||||
): View? {
|
|
||||||
// Inflate the layout for this fragment
|
|
||||||
viewer = inflater.inflate(R.layout.fragment_image_viewer, container, false)
|
|
||||||
val fab: FloatingActionButton = viewer.findViewById(R.id.download_pic)
|
|
||||||
if (bitmap != null) {
|
|
||||||
val photoView: PhotoView = viewer.findViewById(R.id.photo_view)
|
|
||||||
photoView.setImageBitmap(bitmap)
|
|
||||||
fab.setOnClickListener(object : View.OnClickListener {
|
|
||||||
override fun onClick(v: View) {
|
|
||||||
try {
|
|
||||||
downloadPic()
|
|
||||||
} catch (e: FileNotFoundException) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return viewer
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onResume() {
|
|
||||||
super.onResume()
|
|
||||||
(activity as AppCompatActivity?)!!.supportActionBar!!.hide()
|
|
||||||
requireActivity().window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStop() {
|
|
||||||
super.onStop()
|
|
||||||
(activity as AppCompatActivity?)!!.supportActionBar!!.show()
|
|
||||||
requireActivity().window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Throws(FileNotFoundException::class)
|
|
||||||
private fun downloadPic() {
|
|
||||||
val f: File =
|
|
||||||
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
|
|
||||||
val fname: String = "driver" + DateUtils.getDateTimeStamp() + ".jpg"
|
|
||||||
val image: File = File(f, fname)
|
|
||||||
val fileOutputStream: FileOutputStream = FileOutputStream(image)
|
|
||||||
bitmap!!.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream)
|
|
||||||
try {
|
|
||||||
fileOutputStream.flush()
|
|
||||||
fileOutputStream.close()
|
|
||||||
val mediaScanIntent: Intent = Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE)
|
|
||||||
val contentUri: Uri = Uri.fromFile(image)
|
|
||||||
mediaScanIntent.data = contentUri
|
|
||||||
requireActivity().sendBroadcast(mediaScanIntent)
|
|
||||||
} catch (e: IOException) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val IMAGE_VALUE: String = "image"
|
|
||||||
private var bitmap: Bitmap? = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.Global
|
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.app.AlertDialog
|
|
||||||
import android.content.DialogInterface
|
|
||||||
import android.widget.ImageView
|
|
||||||
|
|
||||||
|
|
||||||
class SetApprovalDialog constructor(
|
|
||||||
var statusCode: Int,
|
|
||||||
private val activity: Activity,
|
|
||||||
private val userId: String?,
|
|
||||||
position: Int,
|
|
||||||
private val imageView: ImageView
|
|
||||||
) {
|
|
||||||
private val groupNames: Array<String> = arrayOf("Pending", "Denied", "Approved")
|
|
||||||
private val approvalNameString: String
|
|
||||||
fun init() {
|
|
||||||
val checkedItem: Int
|
|
||||||
when (statusCode) {
|
|
||||||
FirebaseClass.APPROVAL_PENDING -> checkedItem = 0
|
|
||||||
FirebaseClass.APPROVAL_DENIED -> checkedItem = 1
|
|
||||||
FirebaseClass.APPROVED -> checkedItem = 2
|
|
||||||
else -> checkedItem = -1
|
|
||||||
}
|
|
||||||
val alertBuilder: AlertDialog.Builder = AlertDialog.Builder(
|
|
||||||
activity
|
|
||||||
)
|
|
||||||
alertBuilder.setSingleChoiceItems(groupNames, checkedItem, singleChoiceListener)
|
|
||||||
// .setPositiveButton(android.R.string.ok, submit);
|
|
||||||
alertBuilder.create().ownerActivity
|
|
||||||
alertBuilder.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
var singleChoiceListener: DialogInterface.OnClickListener =
|
|
||||||
object : DialogInterface.OnClickListener {
|
|
||||||
override fun onClick(dialog: DialogInterface, which: Int) {
|
|
||||||
when (which) {
|
|
||||||
0 -> {
|
|
||||||
statusCode = FirebaseClass.APPROVAL_PENDING
|
|
||||||
publishStatuscode(statusCode, dialog)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
1 -> {
|
|
||||||
statusCode = FirebaseClass.APPROVAL_DENIED
|
|
||||||
publishStatuscode(statusCode, dialog)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
2 -> {
|
|
||||||
statusCode = FirebaseClass.APPROVED
|
|
||||||
publishStatuscode(statusCode, dialog)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun publishStatuscode(status: Int, dialog: DialogInterface) {
|
|
||||||
|
|
||||||
// if (!(approvalNameString == "")) {
|
|
||||||
// MainActivity.mDatabase!!.child(FirebaseClass.USER_FIREBASE).child(
|
|
||||||
// (userId)!!
|
|
||||||
// ).child(FirebaseClass.USER_APPROVALS).child(approvalNameString)
|
|
||||||
// .setValue(status).addOnCompleteListener { task ->
|
|
||||||
// if (task.isSuccessful) {
|
|
||||||
// Toast.makeText(activity, "Status change successful", Toast.LENGTH_SHORT)
|
|
||||||
// .show()
|
|
||||||
// imageView.setImageResource(
|
|
||||||
// MainActivity.approvalsClass!!.setImageResource(
|
|
||||||
// status
|
|
||||||
// )
|
|
||||||
// )
|
|
||||||
// dialog.dismiss()
|
|
||||||
// } else {
|
|
||||||
// Toast.makeText(
|
|
||||||
// activity,
|
|
||||||
// "Status change unsuccessful",
|
|
||||||
// Toast.LENGTH_SHORT
|
|
||||||
// ).show()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// Toast.makeText(activity, "Could not push status", Toast.LENGTH_SHORT).show()
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getElement(i: Int): String {
|
|
||||||
var element: String = ""
|
|
||||||
when (i) {
|
|
||||||
0 -> element =
|
|
||||||
FirebaseClass.DRIVER_DETAILS_FIREBASE + FirebaseClass.APPROVAL_CONSTANT
|
|
||||||
1 -> element =
|
|
||||||
FirebaseClass.DRIVERS_LICENSE_FIREBASE + FirebaseClass.APPROVAL_CONSTANT
|
|
||||||
2 -> element =
|
|
||||||
FirebaseClass.PRIVATE_HIRE_FIREBASE + FirebaseClass.APPROVAL_CONSTANT
|
|
||||||
3 -> element =
|
|
||||||
FirebaseClass.VEHICLE_DETAILS_FIREBASE + FirebaseClass.APPROVAL_CONSTANT
|
|
||||||
4 -> element =
|
|
||||||
FirebaseClass.INSURANCE_FIREBASE + FirebaseClass.APPROVAL_CONSTANT
|
|
||||||
5 -> element =
|
|
||||||
FirebaseClass.MOT_FIREBASE + FirebaseClass.APPROVAL_CONSTANT
|
|
||||||
6 -> element =
|
|
||||||
FirebaseClass.LOG_BOOK_FIREBASE + FirebaseClass.APPROVAL_CONSTANT
|
|
||||||
7 -> element =
|
|
||||||
FirebaseClass.PRIVATE_HIRE_VEHICLE_LICENSE + FirebaseClass.APPROVAL_CONSTANT
|
|
||||||
}
|
|
||||||
return element
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
|
||||||
approvalNameString = getElement(position)
|
|
||||||
init()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.Objects
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class LogbookObject {
|
|
||||||
var photoString: String? = null
|
|
||||||
var v5cnumber: String? = null
|
|
||||||
|
|
||||||
constructor(photoString: String?, v5cnumber: String?) {
|
|
||||||
this.photoString = photoString
|
|
||||||
this.v5cnumber = v5cnumber
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor()
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.data
|
|
||||||
|
|
||||||
enum class Roles(name: String) {
|
|
||||||
Driver("driver"),
|
|
||||||
SuperUser("super_user")
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.ui.driver
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import h_mal.appttude.com.driver.R
|
|
||||||
import h_mal.appttude.com.driver.utils.navigateTo
|
|
||||||
|
|
||||||
import kotlinx.android.synthetic.main.fragment_home_driver.*
|
|
||||||
|
|
||||||
|
|
||||||
class HomeFragment : Fragment() {
|
|
||||||
|
|
||||||
override fun onCreateView(
|
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
|
||||||
savedInstanceState: Bundle?
|
|
||||||
): View? = inflater.inflate(R.layout.fragment_home_driver, container, false)
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
|
|
||||||
driver.setOnClickListener {
|
|
||||||
view.navigateTo(R.id.to_driverOverallFragment)
|
|
||||||
}
|
|
||||||
car.setOnClickListener {
|
|
||||||
view.navigateTo(R.id.to_vehicleOverallFragment)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.ui.driver.driverprofile
|
|
||||||
|
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.View
|
|
||||||
import h_mal.appttude.com.driver.Global.DateDialog
|
|
||||||
import h_mal.appttude.com.driver.R
|
|
||||||
import h_mal.appttude.com.driver.base.DataSubmissionBaseFragment
|
|
||||||
import h_mal.appttude.com.driver.model.DriversLicenseObject
|
|
||||||
import h_mal.appttude.com.driver.utils.setPicassoImage
|
|
||||||
import h_mal.appttude.com.driver.viewmodels.DriverLicenseViewModel
|
|
||||||
import kotlinx.android.synthetic.main.fragment_driver_license.*
|
|
||||||
|
|
||||||
class DriverLicenseFragment : DataSubmissionBaseFragment<DriverLicenseViewModel, DriversLicenseObject>() {
|
|
||||||
|
|
||||||
private val viewmodel: DriverLicenseViewModel by getFragmentViewModel()
|
|
||||||
override fun getViewModel(): DriverLicenseViewModel = viewmodel
|
|
||||||
override fun getLayoutId(): Int = R.layout.fragment_driver_license
|
|
||||||
override var model = DriversLicenseObject()
|
|
||||||
|
|
||||||
private var imageUri: Uri? = null
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
|
|
||||||
lic_expiry.apply {
|
|
||||||
setTextOnChange{ model.licenseExpiry = it }
|
|
||||||
setOnClickListener {
|
|
||||||
DateDialog(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lic_no.setTextOnChange{ model.licenseNumber = it }
|
|
||||||
|
|
||||||
upload_lic.setOnClickListener { openGalleryWithPermissionRequest() }
|
|
||||||
submit.setOnClickListener{ submit() }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun submit(){
|
|
||||||
validateEditTexts(lic_expiry,lic_no).takeIf { !it }?.let { return }
|
|
||||||
|
|
||||||
viewmodel.setDataInDatabase(model, imageUri)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun setFields(data: DriversLicenseObject) {
|
|
||||||
super.setFields(data)
|
|
||||||
driversli_img.setPicassoImage(data.licenseImageString)
|
|
||||||
lic_no.setText(data.licenseNumber)
|
|
||||||
lic_expiry.setText(data.licenseExpiry)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onImageGalleryResult(imageUri: Uri?) {
|
|
||||||
super.onImageGalleryResult(imageUri)
|
|
||||||
this.imageUri = imageUri
|
|
||||||
driversli_img.setPicassoImage(imageUri)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.update
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import h_mal.appttude.com.driver.R
|
|
||||||
import h_mal.appttude.com.driver.base.BaseActivity
|
|
||||||
import h_mal.appttude.com.driver.viewmodels.UpdateUserViewModel
|
|
||||||
|
|
||||||
class UpdateActivity : BaseActivity<UpdateUserViewModel>() {
|
|
||||||
|
|
||||||
override val layoutId: Int = R.layout.update_activity
|
|
||||||
override fun getViewModel(): UpdateUserViewModel? = null
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
createViewModel<UpdateUserViewModel>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.ui.user
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.View
|
|
||||||
import androidx.fragment.app.activityViewModels
|
|
||||||
import com.google.firebase.auth.FirebaseUser
|
|
||||||
import h_mal.appttude.com.driver.R
|
|
||||||
import h_mal.appttude.com.driver.base.BaseFragment
|
|
||||||
import h_mal.appttude.com.driver.data.FirebaseCompletion
|
|
||||||
import h_mal.appttude.com.driver.utils.Coroutines.main
|
|
||||||
import h_mal.appttude.com.driver.utils.navigateTo
|
|
||||||
import h_mal.appttude.com.driver.viewmodels.UserViewModel
|
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
|
|
||||||
|
|
||||||
class SplashScreenFragment : BaseFragment<UserViewModel>() {
|
|
||||||
|
|
||||||
private val userViewModel by activityViewModels<UserViewModel>()
|
|
||||||
override fun getViewModel(): UserViewModel = userViewModel
|
|
||||||
override fun getLayoutId(): Int = R.layout.fragment_splash_screen
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
|
|
||||||
userViewModel.splashscreenCheckUserIsLoggedIn()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSuccess(data: Any?) {
|
|
||||||
super.onSuccess(data)
|
|
||||||
when(data){
|
|
||||||
is FirebaseCompletion.Default -> view?.navigateTo(R.id.to_loginFragment)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.utils
|
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.res.Resources
|
|
||||||
import android.net.Uri
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.view.inputmethod.EditorInfo
|
|
||||||
import android.view.inputmethod.InputMethodManager
|
|
||||||
import android.widget.EditText
|
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.TextView
|
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.annotation.DrawableRes
|
|
||||||
import androidx.appcompat.widget.SearchView
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import com.squareup.picasso.Picasso
|
|
||||||
import h_mal.appttude.com.driver.R
|
|
||||||
|
|
||||||
fun View.show() {
|
|
||||||
this.visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
|
|
||||||
fun View.hide() {
|
|
||||||
this.visibility = View.GONE
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Context.displayToast(message: String) {
|
|
||||||
Toast.makeText(this, message, Toast.LENGTH_LONG).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Fragment.displayToast(message: String) {
|
|
||||||
requireContext().displayToast(message)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun EditText.setEnterPressedListener(action: () -> Unit) {
|
|
||||||
setOnEditorActionListener(TextView.OnEditorActionListener { _, id, _ ->
|
|
||||||
if (id == EditorInfo.IME_ACTION_DONE || id == EditorInfo.IME_NULL) {
|
|
||||||
action()
|
|
||||||
return@OnEditorActionListener true
|
|
||||||
}
|
|
||||||
false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fun ImageView.setPicassoImage(
|
|
||||||
url: String?,
|
|
||||||
@DrawableRes placeholderRes: Int = R.drawable.choice_img_round
|
|
||||||
) {
|
|
||||||
|
|
||||||
val creator = Picasso.get()
|
|
||||||
.load(url)
|
|
||||||
viewTreeObserver.addOnPreDrawListener {
|
|
||||||
creator.resize(width, height)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
creator
|
|
||||||
.placeholder(placeholderRes)
|
|
||||||
.into(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun ImageView.setPicassoImage(
|
|
||||||
url: Uri?,
|
|
||||||
@DrawableRes placeholderRes: Int = R.drawable.choice_img_round
|
|
||||||
) {
|
|
||||||
val creator = Picasso.get()
|
|
||||||
.load(url)
|
|
||||||
viewTreeObserver.addOnPreDrawListener {
|
|
||||||
creator.resize(width, height)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
creator
|
|
||||||
.placeholder(placeholderRes)
|
|
||||||
.into(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun ViewGroup.generateView(layoutId: Int): View = LayoutInflater
|
|
||||||
.from(context)
|
|
||||||
.inflate(layoutId, this, false)
|
|
||||||
|
|
||||||
fun Int.dpToPx(): Int = (this * Resources.getSystem().displayMetrics.density).toInt()
|
|
||||||
|
|
||||||
fun SearchView.onSubmitListener(searchSubmit: (String) -> Unit) {
|
|
||||||
this.setOnQueryTextListener(object :
|
|
||||||
SearchView.OnQueryTextListener {
|
|
||||||
override fun onQueryTextSubmit(s: String): Boolean {
|
|
||||||
searchSubmit.invoke(s)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onQueryTextChange(s: String): Boolean {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Fragment.hideKeyboard() {
|
|
||||||
val imm = context?.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager?
|
|
||||||
imm?.hideSoftInputFromWindow(view?.windowToken, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun EditText.extractString(): String = text.toString().trim()
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
package h_mal.appttude.com.driver.viewmodels
|
|
||||||
|
|
||||||
import android.net.Uri
|
|
||||||
import h_mal.appttude.com.driver.base.BaseViewModel
|
|
||||||
import h_mal.appttude.com.driver.data.FirebaseAuthentication
|
|
||||||
import h_mal.appttude.com.driver.data.FirebaseCompletion
|
|
||||||
import h_mal.appttude.com.driver.data.FirebaseStorageSource
|
|
||||||
import h_mal.appttude.com.driver.utils.Coroutines.io
|
|
||||||
import kotlinx.coroutines.tasks.await
|
|
||||||
import java.io.IOException
|
|
||||||
|
|
||||||
class UpdateUserViewModel(
|
|
||||||
private val auth: FirebaseAuthentication,
|
|
||||||
private val storage: FirebaseStorageSource
|
|
||||||
) : BaseViewModel() {
|
|
||||||
|
|
||||||
fun updateEmail(oldEmail: String, password: String, newEmail: String) = io {
|
|
||||||
doTryOperation("Failed to update email"){
|
|
||||||
auth.reauthenticate(oldEmail, password)?.await()
|
|
||||||
val complete = auth.updateEmail(newEmail)?.await()
|
|
||||||
complete?.postResult("Email address")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun updatePassword(oldEmail: String, password: String, newPassword: String) = io {
|
|
||||||
doTryOperation("Failed to update password"){
|
|
||||||
auth.reauthenticate(oldEmail, password)?.await()
|
|
||||||
val complete = auth.updatePassword(newPassword)?.await()
|
|
||||||
complete?.postResult("Password")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun updateProfile(name: String?, localImageUri: Uri?) = io {
|
|
||||||
if (name.isNullOrBlank() && localImageUri == null) return@io
|
|
||||||
doTryOperation("Failed to update User"){
|
|
||||||
|
|
||||||
val profilePicUrl = localImageUri?.let {
|
|
||||||
val storageRef = storage.profileImageStorageRef(auth.getUid()!!)
|
|
||||||
storage.uploadImage(it, storageRef, "profile_pic")
|
|
||||||
}
|
|
||||||
|
|
||||||
val complete = auth.updateProfile(name, profilePicUrl)?.await()
|
|
||||||
complete.postResult("Profile updated")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun deleteProfile(oldEmail: String, password: String) = io {
|
|
||||||
doTryOperation("Failed to delete profile"){
|
|
||||||
auth.reauthenticate(oldEmail, password)?.await()
|
|
||||||
val complete = auth.deleteProfile()?.await()
|
|
||||||
complete?.let {
|
|
||||||
onSuccess(FirebaseCompletion.ProfileDeleted("Profile deleted"))
|
|
||||||
return@doTryOperation
|
|
||||||
}
|
|
||||||
throw IOException("Failed to complete")
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun getUser(): Boolean {
|
|
||||||
return auth.getUser()?.let {
|
|
||||||
onSuccess(it)
|
|
||||||
true
|
|
||||||
} ?: false
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun Void?.postResult(section: String){
|
|
||||||
this?.let {
|
|
||||||
onSuccess(FirebaseCompletion.Changed("$section has been updated"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
throw IOException("Failed to complete")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package h_mal.appttude.com.espresso
|
||||||
|
|
||||||
|
import androidx.test.espresso.idling.CountingIdlingResource
|
||||||
|
|
||||||
|
object IdlingResourceClass {
|
||||||
|
private val CLASS_NAME = "IdlingResourceClass"
|
||||||
|
|
||||||
|
private const val RESOURCE = "GLOBAL"
|
||||||
|
|
||||||
|
@JvmField val countingIdlingResource = CountingIdlingResource(RESOURCE)
|
||||||
|
|
||||||
|
fun increment() {
|
||||||
|
if (!countingIdlingResource.isIdleNow) {
|
||||||
|
countingIdlingResource.increment()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun decrement() {
|
||||||
|
if (countingIdlingResource.isIdleNow) {
|
||||||
|
countingIdlingResource.decrement()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package h_mal.appttude.com.driver.model
|
package h_mal.appttude.com.model
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package h_mal.appttude.com.driver.model
|
package h_mal.appttude.com.model
|
||||||
|
|
||||||
|
|
||||||
data class DriversLicenseObject(
|
data class DriversLicenseObject(
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package h_mal.appttude.com.driver.Objects
|
package h_mal.appttude.com.model
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package h_mal.appttude.com.model
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
data class LogbookObject(
|
||||||
|
var photoString: String? = null,
|
||||||
|
var v5cnumber: String? = null
|
||||||
|
)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package h_mal.appttude.com.driver.model
|
package h_mal.appttude.com.model
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user