first commit
13
.gitignore
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea/caches
|
||||||
|
/.idea/libraries
|
||||||
|
/.idea/modules.xml
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/navEditor.xml
|
||||||
|
/.idea/assetWizardSettings.xml
|
||||||
|
.DS_Store
|
||||||
|
/build
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
||||||
122
.idea/codeStyles/Project.xml
generated
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<code_scheme name="Project" version="173">
|
||||||
|
<AndroidXmlCodeStyleSettings>
|
||||||
|
<option name="USE_CUSTOM_SETTINGS" value="true" />
|
||||||
|
</AndroidXmlCodeStyleSettings>
|
||||||
|
<JetCodeStyleSettings>
|
||||||
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
|
</JetCodeStyleSettings>
|
||||||
|
<XML>
|
||||||
|
<option name="XML_KEEP_LINE_BREAKS" value="false" />
|
||||||
|
<option name="XML_ALIGN_ATTRIBUTES" value="false" />
|
||||||
|
<option name="XML_SPACE_INSIDE_EMPTY_TAG" value="true" />
|
||||||
|
</XML>
|
||||||
|
<codeStyleSettings language="XML">
|
||||||
|
<option name="FORCE_REARRANGE_MODE" value="1" />
|
||||||
|
<indentOptions>
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
</indentOptions>
|
||||||
|
<arrangement>
|
||||||
|
<rules>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>xmlns:android</NAME>
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>xmlns:.*</NAME>
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:id</NAME>
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:name</NAME>
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>name</NAME>
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>style</NAME>
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
</rules>
|
||||||
|
</arrangement>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="kotlin">
|
||||||
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
|
</codeStyleSettings>
|
||||||
|
</code_scheme>
|
||||||
|
</component>
|
||||||
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||||
|
</state>
|
||||||
|
</component>
|
||||||
7
.idea/dictionaries/h_mal.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<component name="ProjectDictionaryState">
|
||||||
|
<dictionary name="h_mal">
|
||||||
|
<words>
|
||||||
|
<w>mandetory</w>
|
||||||
|
</words>
|
||||||
|
</dictionary>
|
||||||
|
</component>
|
||||||
4
.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
|
||||||
|
</project>
|
||||||
18
.idea/gradle.xml
generated
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/app" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
14
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CMakeSettings">
|
||||||
|
<configurations>
|
||||||
|
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
|
||||||
|
</configurations>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="Android" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
12
.idea/runConfigurations.xml
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?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>
|
||||||
10
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/Android-project" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/Days_left--Kotlin-" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/Farmr" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/Firebase_function" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/Udacity_Score_Keeper_App" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
1
app/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/build
|
||||||
50
app/build.gradle
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-android-extensions'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 28
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "com.appttude.h_mal.days_left_kotlin"
|
||||||
|
minSdkVersion 23
|
||||||
|
targetSdkVersion 28
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
|
implementation 'androidx.appcompat:appcompat:1.0.0'
|
||||||
|
implementation 'com.google.android.material:material:1.0.0'
|
||||||
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
|
implementation 'androidx.vectordrawable:vectordrawable:1.0.0'
|
||||||
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
|
implementation 'com.google.android.gms:play-services-auth:17.0.0'
|
||||||
|
implementation 'com.google.firebase:firebase-core:17.2.0'
|
||||||
|
implementation 'com.google.firebase:firebase-auth:19.1.0'
|
||||||
|
implementation 'com.google.firebase:firebase-storage:19.1.0'
|
||||||
|
implementation 'com.google.firebase:firebase-database:19.1.0'
|
||||||
|
implementation 'com.firebaseui:firebase-ui-database:1.1.1'
|
||||||
|
implementation 'com.google.firebase:firebase-functions:19.0.1'
|
||||||
|
implementation 'com.google.firebase:firebase-analytics:17.2.0'
|
||||||
|
implementation 'com.google.code.gson:gson:2.3.1'
|
||||||
|
implementation 'com.squareup.picasso:picasso:2.71828'
|
||||||
|
implementation 'androidx.annotation:annotation:1.1.0'
|
||||||
|
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
|
||||||
|
testImplementation 'junit:junit:4.12'
|
||||||
|
androidTestImplementation 'androidx.test:runner:1.1.0'
|
||||||
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'com.google.gms.google-services'
|
||||||
69
app/google-services.json
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
{
|
||||||
|
"project_info": {
|
||||||
|
"project_number": "640643168912",
|
||||||
|
"firebase_url": "https://farmr-8a496.firebaseio.com",
|
||||||
|
"project_id": "farmr-8a496",
|
||||||
|
"storage_bucket": "farmr-8a496.appspot.com"
|
||||||
|
},
|
||||||
|
"client": [
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:640643168912:android:34c3a70dd882364a",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "com.appttude.h_mal.days_left"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "640643168912-0ssmglfad3vi7f6pok33rrjalm5phlq4.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyA4PcycGfWC3SBUxWqK2qMr9bEpwB3SWaY"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "640643168912-0ssmglfad3vi7f6pok33rrjalm5phlq4.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:640643168912:android:ef74534912ef190a2bb615",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "com.appttude.h_mal.days_left_kotlin"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "640643168912-0ssmglfad3vi7f6pok33rrjalm5phlq4.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyA4PcycGfWC3SBUxWqK2qMr9bEpwB3SWaY"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "640643168912-0ssmglfad3vi7f6pok33rrjalm5phlq4.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"configuration_version": "1"
|
||||||
|
}
|
||||||
21
app/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import androidx.test.InstrumentationRegistry
|
||||||
|
import androidx.test.runner.AndroidJUnit4
|
||||||
|
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
import org.junit.Assert.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrumented test, which will execute on an Android device.
|
||||||
|
*
|
||||||
|
* See [testing documentation](http://d.android.com/tools/testing).
|
||||||
|
*/
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class ExampleInstrumentedTest {
|
||||||
|
@Test
|
||||||
|
fun useAppContext() {
|
||||||
|
// Context of the app under test.
|
||||||
|
val appContext = InstrumentationRegistry.getTargetContext()
|
||||||
|
assertEquals("com.appttude.h_mal.days_left_kotlin", appContext.packageName)
|
||||||
|
}
|
||||||
|
}
|
||||||
43
app/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.appttude.h_mal.days_left_kotlin">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
|
<activity android:name=".AddItemActivity"></activity>
|
||||||
|
<activity
|
||||||
|
android:name=".Login.FullscreenActivity"
|
||||||
|
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||||
|
android:label="@string/app_name">
|
||||||
|
<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=".ChangeUserDetailsActivity" />
|
||||||
|
<activity android:name=".AddShiftActivity" />
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||||
|
android:label="@string/app_name" />
|
||||||
|
<provider
|
||||||
|
android:name="androidx.core.content.FileProvider"
|
||||||
|
android:authorities="${applicationId}.provider"
|
||||||
|
android:exported="false"
|
||||||
|
android:grantUriPermissions="true">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
|
android:resource="@xml/provider_paths"/>
|
||||||
|
</provider>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.ArrayAdapter
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Objects.AbnObject
|
||||||
|
import kotlinx.android.synthetic.main.abn_list_item.view.*
|
||||||
|
|
||||||
|
class AbnListAdapter(context: Context, objects: List<AbnObject>) :
|
||||||
|
ArrayAdapter<AbnObject>(context, 0, objects){
|
||||||
|
|
||||||
|
|
||||||
|
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
||||||
|
var view: View? = convertView
|
||||||
|
if (view == null) {
|
||||||
|
view = LayoutInflater.from(context).inflate(R.layout.abn_list_item, parent, false)!!
|
||||||
|
}
|
||||||
|
|
||||||
|
val currentObject = getItem(position)
|
||||||
|
|
||||||
|
view.farm_name.text = currentObject?.companyName
|
||||||
|
view.abn_text.text = currentObject?.abn
|
||||||
|
view.postcode_text.text = currentObject?.postCode.toString()
|
||||||
|
|
||||||
|
return view
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.net.Uri
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.*
|
||||||
|
import android.view.inputmethod.InputMethodManager
|
||||||
|
import android.widget.*
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Objects.AbnObject
|
||||||
|
import com.google.android.gms.tasks.Task
|
||||||
|
import com.google.firebase.functions.FirebaseFunctions
|
||||||
|
import com.google.firebase.functions.FirebaseFunctionsException
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import com.google.gson.JsonObject
|
||||||
|
import kotlinx.android.synthetic.main.activity_add_item.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_add_employer.*
|
||||||
|
import org.json.JSONArray
|
||||||
|
import java.util.HashMap
|
||||||
|
import androidx.core.content.ContextCompat.getSystemService
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class AddEmployerFragment : Fragment() {
|
||||||
|
val TAG = "AddEmployer"
|
||||||
|
|
||||||
|
lateinit var searchView: SearchView
|
||||||
|
lateinit var mFunctions: FirebaseFunctions
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
mFunctions = FirebaseFunctions.getInstance()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
setHasOptionsMenu(true)
|
||||||
|
|
||||||
|
return inflater.inflate(R.layout.fragment_add_employer, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) {
|
||||||
|
inflater?.inflate(R.menu.menu_search, menu)
|
||||||
|
val searchItem = menu?.findItem(R.id.app_bar_search)
|
||||||
|
|
||||||
|
searchView = searchItem?.actionView as SearchView
|
||||||
|
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener{
|
||||||
|
override fun onQueryTextChange(newText: String?): Boolean {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onQueryTextSubmit(query: String?): Boolean {
|
||||||
|
val imm = activity?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
imm.hideSoftInputFromWindow(view?.getWindowToken(), 0)
|
||||||
|
|
||||||
|
query?.let {
|
||||||
|
abnLookUp(it).addOnCompleteListener{ task ->
|
||||||
|
spinning_pb.visibility = View.GONE
|
||||||
|
if (task.isSuccessful){
|
||||||
|
val jsonArray = task.result
|
||||||
|
var abnList = ArrayList<AbnObject>()
|
||||||
|
|
||||||
|
jsonArray?.let {
|
||||||
|
for (i in 0 until it.size){
|
||||||
|
|
||||||
|
val item = hashIntoObj(it.get(i) as Map<String,Any>)
|
||||||
|
// val abnobj = item.values as AbnObject
|
||||||
|
abnList.add(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (abnList.size > 0){
|
||||||
|
list_view.adapter = AbnListAdapter(context!!, abnList)
|
||||||
|
empty_list.visibility = View.GONE
|
||||||
|
}else{
|
||||||
|
empty_list.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
val e = task.exception
|
||||||
|
if (e is FirebaseFunctionsException) {
|
||||||
|
val ffe = e as FirebaseFunctionsException?
|
||||||
|
val code = ffe!!.code
|
||||||
|
val details = ffe.details as String
|
||||||
|
|
||||||
|
Log.e(code.toString(),details)
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.w(TAG, "addMessage:onFailure", e)
|
||||||
|
Toast.makeText(context, "An error occurred.", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
super.onCreateOptionsMenu(menu, inflater)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun abnLookUp(input : String) : Task<ArrayList<*>> {
|
||||||
|
spinning_pb.visibility = View.VISIBLE
|
||||||
|
// Create the arguments to the callable function.
|
||||||
|
val data = HashMap<String, Any>()
|
||||||
|
data["input"] = input
|
||||||
|
data["push"] = true
|
||||||
|
|
||||||
|
return mFunctions
|
||||||
|
.getHttpsCallable("abnLooKUp")
|
||||||
|
.call(data)
|
||||||
|
.continueWith{ task ->
|
||||||
|
// This continuation runs on either success or failure, but if the task
|
||||||
|
// has failed then getResult() will throw an Exception which will be
|
||||||
|
// propagated down.
|
||||||
|
val result = task.result?.data as ArrayList<*>
|
||||||
|
|
||||||
|
Log.i(TAG, "then: " + result.toString())
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun hashIntoObj(map: Map<String,Any>): AbnObject {
|
||||||
|
val abn = map.getValue("abn") as String
|
||||||
|
val companyName = map.getValue("companyName") as String
|
||||||
|
val postCode = map.getValue("postCode") as Int
|
||||||
|
val state = map.getValue("state") as String
|
||||||
|
|
||||||
|
return AbnObject(abn, companyName, postCode, state)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.content.DialogInterface
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.AddShiftActivity.Companion.EMPLOYERREQUEST
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.AddShiftActivity.Companion.REQUEST
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.AddShiftActivity.Companion.TASK_CONSTANT
|
||||||
|
import kotlinx.android.synthetic.main.activity_add_item.*
|
||||||
|
|
||||||
|
class AddItemActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.activity_add_item)
|
||||||
|
|
||||||
|
setSupportActionBar(toolbar)
|
||||||
|
|
||||||
|
val requestCode = intent.getIntExtra(REQUEST, EMPLOYERREQUEST)
|
||||||
|
|
||||||
|
if (requestCode == EMPLOYERREQUEST) {
|
||||||
|
supportFragmentManager.beginTransaction().replace(R.id.container, AddEmployerFragment()).addToBackStack("Employer").commit()
|
||||||
|
} else {
|
||||||
|
val taskObject = intent.getSerializableExtra(TASK_CONSTANT)
|
||||||
|
val addTaskFragment = AddTaskFragment()
|
||||||
|
if (taskObject != null) {
|
||||||
|
val bundle = Bundle()
|
||||||
|
bundle.putSerializable(TASK_CONSTANT, taskObject)
|
||||||
|
addTaskFragment.arguments = bundle
|
||||||
|
}
|
||||||
|
supportFragmentManager.beginTransaction().replace(R.id.container, addTaskFragment).addToBackStack("Task").commit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed() {
|
||||||
|
|
||||||
|
AlertDialog.Builder(this)
|
||||||
|
.setTitle("Leave?")
|
||||||
|
.setMessage("Are you sure you return to previous?")
|
||||||
|
.setNegativeButton(android.R.string.no, null)
|
||||||
|
.setPositiveButton(android.R.string.yes, DialogInterface.OnClickListener {
|
||||||
|
arg0, arg1 -> finish() })
|
||||||
|
.create().show()
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,585 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.app.AlertDialog
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.DialogInterface
|
||||||
|
import android.content.Intent
|
||||||
|
import android.graphics.Typeface
|
||||||
|
import android.os.Build
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.text.TextUtils
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.animation.AnimationUtils
|
||||||
|
import android.widget.*
|
||||||
|
import androidx.cardview.widget.CardView
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.EMPLOYER_FIREBASE
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.PIECE
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.SHIFT_FIREBASE
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.SHIFT_ID
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.TASK_FIREBASE
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.USER_FIREBASE
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.auth
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.mDatabase
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Objects.AbnObject
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Objects.ShiftObject
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Objects.TaskObject
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Objects.TimeObject
|
||||||
|
import com.google.android.gms.tasks.Task
|
||||||
|
import com.google.firebase.database.DataSnapshot
|
||||||
|
import com.google.firebase.database.DatabaseError
|
||||||
|
import com.google.firebase.database.DatabaseReference
|
||||||
|
import com.google.firebase.database.ValueEventListener
|
||||||
|
import kotlinx.android.synthetic.main.activity_add_shift.*
|
||||||
|
import kotlinx.android.synthetic.main.activity_add_shift.date
|
||||||
|
import kotlinx.android.synthetic.main.activity_add_shift.search_button
|
||||||
|
import kotlinx.android.synthetic.main.activity_add_shift.units
|
||||||
|
import kotlinx.android.synthetic.main.dialog_previous_abns_used.*
|
||||||
|
import kotlinx.android.synthetic.main.dialog_previous_abns_used.view.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_add_task.*
|
||||||
|
import java.sql.Time
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.collections.ArrayList
|
||||||
|
import kotlinx.android.synthetic.main.list_item.time as time1
|
||||||
|
|
||||||
|
class AddShiftActivity : AppCompatActivity() {
|
||||||
|
companion object{
|
||||||
|
val EMPLOYERREQUEST = 339
|
||||||
|
val TASKREQUEST = 445
|
||||||
|
val REQUEST = "request"
|
||||||
|
val EMPLOYER_CONSTANT = "employer"
|
||||||
|
val TASK_CONSTANT = "task"
|
||||||
|
}
|
||||||
|
|
||||||
|
var timeObject: TimeObject? = null
|
||||||
|
var abnObject: AbnObject? = null
|
||||||
|
var taskObject: TaskObject? = null
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.activity_add_shift)
|
||||||
|
|
||||||
|
select_employer_card.setOnClickListener(employerListener)
|
||||||
|
select_task_card.setOnClickListener(taskListener)
|
||||||
|
select_times_card.setOnClickListener{
|
||||||
|
val timeDialogClass = TimeDialogClass(this@AddShiftActivity)
|
||||||
|
timeDialogClass.create()?.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
date.isFocusable = false
|
||||||
|
date.setOnClickListener {
|
||||||
|
lateinit var dateDialog: DateDialog
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
dateDialog = DateDialog(date, this@AddShiftActivity)
|
||||||
|
dateDialog.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
search_button.setOnClickListener(submitListener)
|
||||||
|
|
||||||
|
intent.getStringExtra(SHIFT_ID)?.let {
|
||||||
|
progress_bar.visibility = View.VISIBLE
|
||||||
|
|
||||||
|
mDatabase.child(USER_FIREBASE).child(auth.uid!!).child(SHIFT_FIREBASE).child(it)
|
||||||
|
.addListenerForSingleValueEvent(object : ValueEventListener{
|
||||||
|
override fun onCancelled(p0: DatabaseError) {
|
||||||
|
progress_bar.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDataChange(dataSnapshot: DataSnapshot) {
|
||||||
|
progress_bar.visibility = View.GONE
|
||||||
|
val shiftObject:ShiftObject? = dataSnapshot.getValue(ShiftObject::class.java)
|
||||||
|
|
||||||
|
shiftObject?.let {shift ->
|
||||||
|
abnObject = shift.abnObject
|
||||||
|
taskObject = shift.taskObject
|
||||||
|
|
||||||
|
shift.timeObject?.timeIn?.let {
|
||||||
|
timeObject = shift.timeObject
|
||||||
|
setTimeSummary()
|
||||||
|
Toast.makeText(baseContext,"toasted",Toast.LENGTH_SHORT)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shift.taskObject?.workType.equals(PIECE)) {
|
||||||
|
units.setText(shift.unitsCount.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
date.setText(shiftObject.shiftDate)
|
||||||
|
|
||||||
|
setTaskCard()
|
||||||
|
setEmployerCard()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal val submitListener: View.OnClickListener = View.OnClickListener {
|
||||||
|
if (timeObject == null){
|
||||||
|
|
||||||
|
Toast.makeText(baseContext,"Time information missing",Toast.LENGTH_SHORT).show()
|
||||||
|
return@OnClickListener
|
||||||
|
}
|
||||||
|
if (abnObject == null){
|
||||||
|
|
||||||
|
Toast.makeText(baseContext,"Employer information missing",Toast.LENGTH_SHORT).show()
|
||||||
|
return@OnClickListener
|
||||||
|
}
|
||||||
|
if (taskObject == null){
|
||||||
|
|
||||||
|
Toast.makeText(baseContext,"Task information missing",Toast.LENGTH_SHORT).show()
|
||||||
|
return@OnClickListener
|
||||||
|
}
|
||||||
|
if (date.text.isBlank()){
|
||||||
|
|
||||||
|
Toast.makeText(baseContext,"Date missing",Toast.LENGTH_SHORT).show()
|
||||||
|
return@OnClickListener
|
||||||
|
}
|
||||||
|
if (taskObject?.workType == PIECE && units.text.isEmpty()){
|
||||||
|
|
||||||
|
Toast.makeText(baseContext,"Units information missing",Toast.LENGTH_SHORT).show()
|
||||||
|
return@OnClickListener
|
||||||
|
}
|
||||||
|
|
||||||
|
var shiftobj = ShiftObject()
|
||||||
|
|
||||||
|
shiftobj.abnObject = abnObject
|
||||||
|
shiftobj.taskObject = taskObject as TaskObject
|
||||||
|
shiftobj.timeObject = timeObject as TimeObject
|
||||||
|
shiftobj.shiftDate = date.text.toString()
|
||||||
|
shiftobj.dateTimeAdded = getDateTimeString()
|
||||||
|
shiftobj.unitsCount = units.text.toString().toFloat()
|
||||||
|
|
||||||
|
val shiftReference: DatabaseReference
|
||||||
|
val ShiftID = intent.getStringExtra(SHIFT_ID)
|
||||||
|
|
||||||
|
if (ShiftID != null) {
|
||||||
|
shiftReference = mDatabase.child(USER_FIREBASE).child(auth.uid!!).child(SHIFT_FIREBASE).child(ShiftID)
|
||||||
|
//Updating a shift
|
||||||
|
} else {
|
||||||
|
shiftReference = mDatabase.child(USER_FIREBASE).child(auth.uid!!).child(SHIFT_FIREBASE).push()
|
||||||
|
//Pushing a brand new shift
|
||||||
|
}
|
||||||
|
|
||||||
|
progress_bar.visibility = View.VISIBLE
|
||||||
|
shiftReference.setValue(shiftobj).addOnCompleteListener{task ->
|
||||||
|
Log.i("Firebase", "onComplete: " + task.getResult()!!)
|
||||||
|
if (task.isSuccessful()) {
|
||||||
|
finish()
|
||||||
|
}else{
|
||||||
|
Toast.makeText(baseContext,"Could not submit shift", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
progress_bar.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal var employerListener: View.OnClickListener = View.OnClickListener {
|
||||||
|
progress_bar.visibility = (View.VISIBLE)
|
||||||
|
|
||||||
|
turnShiftsIntoRecentlyUsed().let {
|
||||||
|
if (it.isNotEmpty()){
|
||||||
|
val dialogView = LayoutInflater.from(this).inflate(R.layout.dialog_previous_abns_used, null)
|
||||||
|
|
||||||
|
val abnListAdapter = AbnListAdapter(this, it)
|
||||||
|
|
||||||
|
dialogView.list_item_list_dialog.setAdapter(abnListAdapter)
|
||||||
|
|
||||||
|
val builder = AlertDialog.Builder(this)
|
||||||
|
builder.setView(dialogView)
|
||||||
|
|
||||||
|
val alertDialog = builder.create()
|
||||||
|
alertDialog.show()
|
||||||
|
|
||||||
|
dialogView.button_list_dialog.setOnClickListener(View.OnClickListener {
|
||||||
|
startActivity()
|
||||||
|
alertDialog.dismiss()
|
||||||
|
})
|
||||||
|
|
||||||
|
dialogView.list_item_list_dialog.setOnItemClickListener(AdapterView.OnItemClickListener { parent, view, position, id ->
|
||||||
|
abnObject = it.get(position)
|
||||||
|
setEmployerCard()
|
||||||
|
alertDialog.dismiss()
|
||||||
|
})
|
||||||
|
progress_bar.setVisibility(View.GONE)
|
||||||
|
}else{
|
||||||
|
startActivity()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal var taskListener: View.OnClickListener = View.OnClickListener {
|
||||||
|
progress_bar.visibility = (View.VISIBLE)
|
||||||
|
|
||||||
|
val cont: Context = this
|
||||||
|
|
||||||
|
if (abnObject != null) {
|
||||||
|
mDatabase.child(EMPLOYER_FIREBASE).child(abnObject!!.abn!!).child(TASK_FIREBASE)
|
||||||
|
.addListenerForSingleValueEvent(object : ValueEventListener{
|
||||||
|
override fun onCancelled(p0: DatabaseError) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDataChange(p0: DataSnapshot) {
|
||||||
|
var list = ArrayList<TaskObject>()
|
||||||
|
p0.exists().let {
|
||||||
|
|
||||||
|
for (snapshot in p0.children){
|
||||||
|
list.add(snapshot.getValue(TaskObject::class.java)!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val dialogView = LayoutInflater.from(cont).inflate(R.layout.dialog_previous_abns_used, null)
|
||||||
|
|
||||||
|
val dialogListAdapter = DialogListAdapter(cont, list)
|
||||||
|
dialogView.list_item_list_dialog.setAdapter(dialogListAdapter)
|
||||||
|
|
||||||
|
val builder = AlertDialog.Builder(cont)
|
||||||
|
builder.setView(dialogView)
|
||||||
|
|
||||||
|
val alertDialog = builder.create()
|
||||||
|
alertDialog.show()
|
||||||
|
|
||||||
|
dialogView.button_list_dialog.setOnClickListener(View.OnClickListener {
|
||||||
|
val intent = Intent(cont, AddItemActivity::class.java)
|
||||||
|
intent.putExtra(REQUEST, TASKREQUEST)
|
||||||
|
startActivityForResult(intent, TASKREQUEST)
|
||||||
|
alertDialog.dismiss()
|
||||||
|
})
|
||||||
|
|
||||||
|
dialogView.list_item_list_dialog.setOnItemClickListener(AdapterView.OnItemClickListener { parent, view, position, id ->
|
||||||
|
taskObject = list.get(position)
|
||||||
|
setTaskCard()
|
||||||
|
alertDialog.dismiss()
|
||||||
|
})
|
||||||
|
progress_bar.setVisibility(View.GONE)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
val intent = Intent(this@AddShiftActivity, AddItemActivity::class.java)
|
||||||
|
intent.putExtra(REQUEST, TASKREQUEST)
|
||||||
|
taskObject?.let {
|
||||||
|
intent.putExtra(TASK_CONSTANT, it)
|
||||||
|
}
|
||||||
|
startActivityForResult(intent, TASKREQUEST)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setEmployerCard() {
|
||||||
|
if (lable_1.visibility == View.VISIBLE) {
|
||||||
|
toggleViewVisibility(select_employer_card)
|
||||||
|
}
|
||||||
|
|
||||||
|
employer_name.text = abnObject?.companyName
|
||||||
|
val loc = abnObject?.state + " " + abnObject?.postCode
|
||||||
|
employer_location.text = loc
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setTaskCard() {
|
||||||
|
if (lable_2.getVisibility() == View.VISIBLE) {
|
||||||
|
toggleViewVisibility(select_task_card)
|
||||||
|
}
|
||||||
|
|
||||||
|
task.text = taskObject?.task
|
||||||
|
|
||||||
|
var summary = taskObject?.workType + " - $" + taskObject?.rate + " /"
|
||||||
|
if (taskObject?.workType.equals("Piece Rate")) {
|
||||||
|
summary = summary + "Unit"
|
||||||
|
|
||||||
|
units.visibility = View.VISIBLE
|
||||||
|
select_times_card.visibility = (View.VISIBLE)
|
||||||
|
} else {
|
||||||
|
summary = summary + "Hour"
|
||||||
|
|
||||||
|
units.visibility = View.GONE
|
||||||
|
select_times_card.visibility = (View.VISIBLE)
|
||||||
|
}
|
||||||
|
|
||||||
|
task_summary.setText(summary)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun toggleViewVisibility(cardView: CardView) {
|
||||||
|
when (cardView.getId()) {
|
||||||
|
R.id.select_employer_card -> {
|
||||||
|
setVisibility(employer_layout)
|
||||||
|
setVisibility(lable_1)
|
||||||
|
}
|
||||||
|
R.id.select_task_card -> {
|
||||||
|
setVisibility(task_layout)
|
||||||
|
setVisibility(lable_2)
|
||||||
|
}
|
||||||
|
R.id.select_times_card -> {
|
||||||
|
setVisibility(time_layout)
|
||||||
|
setVisibility(lable_3)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setVisibility (view: View) {
|
||||||
|
val vis: Int
|
||||||
|
if (view.visibility == View.VISIBLE) {
|
||||||
|
vis = View.GONE
|
||||||
|
} else {
|
||||||
|
vis = View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
|
view.visibility = vis
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun turnShiftsIntoRecentlyUsed() : List<AbnObject>{
|
||||||
|
val uniqueList = mutableMapOf<String,AbnObject>()
|
||||||
|
MainActivity.shiftList.forEach {
|
||||||
|
uniqueList.put(it.abnObject?.abn!!, it.abnObject!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
return uniqueList.values.toList()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startActivity() {
|
||||||
|
val intent = Intent(this, AddItemActivity::class.java)
|
||||||
|
intent.putExtra(REQUEST, EMPLOYERREQUEST)
|
||||||
|
startActivityForResult(intent, EMPLOYERREQUEST)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal inner class TimeDialogClass(context: Context?) :
|
||||||
|
AlertDialog.Builder(context) {
|
||||||
|
|
||||||
|
private var timePickerTimePicker: TimePicker? = null
|
||||||
|
private var startTimeTextView: TextView? = null
|
||||||
|
private var finishTimeTextView: TextView? = null
|
||||||
|
private var breakEditText: EditText? = null
|
||||||
|
|
||||||
|
private var currentTag: String? = null
|
||||||
|
private var alertDialog: AlertDialog? = null
|
||||||
|
private var breakInt: Int = 0
|
||||||
|
|
||||||
|
|
||||||
|
var timeSelect: View.OnClickListener = View.OnClickListener { v ->
|
||||||
|
|
||||||
|
currentTag = v.tag as String
|
||||||
|
val timeString: String?
|
||||||
|
|
||||||
|
if (currentTag == "start") {
|
||||||
|
timeString = timeObject?.timeIn
|
||||||
|
toggleTextButtons(true)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
timeString = timeObject?.timeOut
|
||||||
|
toggleTextButtons(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timeString != null) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
timePickerTimePicker!!.hour = getTime(timeString)[0]
|
||||||
|
timePickerTimePicker!!.minute = getTime(timeString)[1]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val calendar = Calendar.getInstance()
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
timePickerTimePicker!!.hour = calendar.get(Calendar.HOUR_OF_DAY)
|
||||||
|
timePickerTimePicker!!.minute = calendar.get(Calendar.MINUTE)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (timeObject?.timeIn == null && timeObject?.timeOut == null){
|
||||||
|
timeObject = TimeObject()
|
||||||
|
}
|
||||||
|
|
||||||
|
setView(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setView(view: View?): AlertDialog.Builder {
|
||||||
|
val view = View.inflate(context, R.layout.dialog_add_times, null)
|
||||||
|
|
||||||
|
currentTag = "start"
|
||||||
|
|
||||||
|
startTimeTextView = view!!.findViewById(R.id.from_date)
|
||||||
|
finishTimeTextView = view.findViewById(R.id.to_date)
|
||||||
|
timePickerTimePicker = view.findViewById(R.id.time_picker)
|
||||||
|
breakEditText = view.findViewById(R.id.breaktime)
|
||||||
|
val okText: TextView = view.findViewById(R.id.ok)
|
||||||
|
|
||||||
|
timePickerTimePicker!!.setIs24HourView(true)
|
||||||
|
|
||||||
|
initialiseTime()
|
||||||
|
|
||||||
|
okText.setOnClickListener {
|
||||||
|
if (timeObject?.timeIn != null && timeObject?.timeOut != null) {
|
||||||
|
timeObject?.hours = calculateDuration()
|
||||||
|
timeObject?.breakEpoch = breakInt
|
||||||
|
|
||||||
|
Toast.makeText(context, convertTimeFloat(timeObject?.hours!!), Toast.LENGTH_SHORT).show()
|
||||||
|
|
||||||
|
if (lable_3.visibility == View.VISIBLE) {
|
||||||
|
toggleViewVisibility(select_times_card)
|
||||||
|
}
|
||||||
|
|
||||||
|
time.text = convertTimeFloat(timeObject?.hours!!)
|
||||||
|
|
||||||
|
setTimeSummary()
|
||||||
|
}
|
||||||
|
|
||||||
|
alertDialog!!.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
breakEditText!!.setText(timeObject?.breakEpoch.toString())
|
||||||
|
|
||||||
|
startTimeTextView!!.tag = "start"
|
||||||
|
finishTimeTextView!!.tag = "finish"
|
||||||
|
|
||||||
|
startTimeTextView!!.setOnClickListener(timeSelect)
|
||||||
|
finishTimeTextView!!.setOnClickListener(timeSelect)
|
||||||
|
|
||||||
|
timePickerTimePicker!!.setOnTimeChangedListener{view, hourOfDay, minute ->
|
||||||
|
val ddTime = String.format("%02d", hourOfDay) + ":" + String.format("%02d", minute)
|
||||||
|
|
||||||
|
if (currentTag == "start") {
|
||||||
|
timeObject!!.timeIn = ddTime
|
||||||
|
} else {
|
||||||
|
timeObject!!.timeOut = ddTime
|
||||||
|
}
|
||||||
|
}
|
||||||
|
toggleTextButtons(true)
|
||||||
|
|
||||||
|
return super.setView(view)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun create(): AlertDialog? {
|
||||||
|
alertDialog = super.create()
|
||||||
|
|
||||||
|
return alertDialog
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setNegativeButton(textId: Int, listener: DialogInterface.OnClickListener): AlertDialog.Builder {
|
||||||
|
return super.setNegativeButton(
|
||||||
|
android.R.string.cancel
|
||||||
|
) { dialog, which -> dialog.dismiss() }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getTime(s: String): IntArray {
|
||||||
|
|
||||||
|
return intArrayOf(Integer.parseInt(s.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[0]),
|
||||||
|
Integer.parseInt(s.split(
|
||||||
|
":".toRegex()
|
||||||
|
).dropLastWhile { it.isEmpty() }.toTypedArray()[1]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initialiseTime(){
|
||||||
|
val timeString = timeObject?.timeIn
|
||||||
|
|
||||||
|
if (timeString != null) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
timePickerTimePicker!!.hour = getTime(timeString)[0]
|
||||||
|
timePickerTimePicker!!.minute = getTime(timeString)[1]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val calendar = Calendar.getInstance()
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
timePickerTimePicker!!.hour = calendar.get(Calendar.HOUR_OF_DAY)
|
||||||
|
timePickerTimePicker!!.minute = calendar.get(Calendar.MINUTE)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun calculateDuration(): Float {
|
||||||
|
val startTime = timeObject?.timeIn
|
||||||
|
val finishTime = timeObject?.timeOut
|
||||||
|
val breakText = breakEditText!!.text.toString().trim { it <= ' ' }
|
||||||
|
|
||||||
|
val hoursIn = getTime(startTime!!)[0]
|
||||||
|
val hoursOut = getTime(finishTime!!)[0]
|
||||||
|
val minutesIn = getTime(startTime)[1]
|
||||||
|
val minutesOut = getTime(finishTime)[1]
|
||||||
|
|
||||||
|
breakInt = 0
|
||||||
|
if (!TextUtils.isEmpty(breakText)) {
|
||||||
|
breakInt = Integer.parseInt(breakText)
|
||||||
|
}
|
||||||
|
val duration: Float
|
||||||
|
|
||||||
|
if (hoursOut > hoursIn) {
|
||||||
|
duration =
|
||||||
|
hoursOut.toFloat() + minutesOut.toFloat() / 60 - (hoursIn.toFloat() + minutesIn.toFloat() / 60) - breakInt.toFloat() / 60
|
||||||
|
} else {
|
||||||
|
duration =
|
||||||
|
hoursOut.toFloat() + minutesOut.toFloat() / 60 - (hoursIn.toFloat() + minutesIn.toFloat() / 60) - breakInt.toFloat() / 60 + 24
|
||||||
|
}
|
||||||
|
|
||||||
|
val s = String.format("%.2f", duration)
|
||||||
|
return java.lang.Float.parseFloat(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun toggleTextButtons(top: Boolean) {
|
||||||
|
setFadeAnimation(startTimeTextView!!)
|
||||||
|
setFadeAnimation(finishTimeTextView!!)
|
||||||
|
|
||||||
|
if (top) {
|
||||||
|
startTimeTextView!!.setTypeface(null, Typeface.BOLD)
|
||||||
|
finishTimeTextView!!.setTypeface(null, Typeface.NORMAL)
|
||||||
|
|
||||||
|
startTimeTextView!!.setBackgroundColor(context.resources.getColor(R.color.one))
|
||||||
|
finishTimeTextView!!.setBackgroundColor(context.resources.getColor(android.R.color.white))
|
||||||
|
} else {
|
||||||
|
finishTimeTextView!!.setTypeface(null, Typeface.BOLD)
|
||||||
|
startTimeTextView!!.setTypeface(null, Typeface.NORMAL)
|
||||||
|
|
||||||
|
finishTimeTextView!!.setBackgroundColor(context.resources.getColor(R.color.one))
|
||||||
|
startTimeTextView!!.setBackgroundColor(context.resources.getColor(android.R.color.white))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setFadeAnimation(view: View) {
|
||||||
|
val bottomUp = AnimationUtils.loadAnimation(
|
||||||
|
context,
|
||||||
|
R.anim.fade_in
|
||||||
|
)
|
||||||
|
|
||||||
|
view.animation = bottomUp
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun convertTimeFloat(timeIn: Float): String {
|
||||||
|
val hour = timeIn.toInt()
|
||||||
|
val minutes = (timeIn - hour).toInt() * 60
|
||||||
|
|
||||||
|
return hour.toString() + "hours " + minutes.toString() + "mins"
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setTimeSummary() {
|
||||||
|
if (lable_3.visibility == View.VISIBLE) {
|
||||||
|
toggleViewVisibility(select_times_card)
|
||||||
|
}
|
||||||
|
|
||||||
|
val s = timeObject?.timeIn + " - " + timeObject?.timeOut
|
||||||
|
time_summary.text = s
|
||||||
|
if (timeObject!!.breakEpoch > 0) {
|
||||||
|
break_holder.visibility = View.VISIBLE
|
||||||
|
break_summary.text = timeObject!!.breakEpoch.toString() + " minutes"
|
||||||
|
} else {
|
||||||
|
break_holder.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
time.setText(convertTimeFloat(timeObject!!.hours))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getDateTimeString(): String {
|
||||||
|
val cal = Calendar.getInstance()
|
||||||
|
val sdf = SimpleDateFormat("dd/MM/yyyy hh:mm:ss", Locale.ENGLISH)
|
||||||
|
|
||||||
|
return sdf.format(cal.time)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,255 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.app.AlertDialog
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.DialogInterface
|
||||||
|
import android.content.Intent
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.net.Uri
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.text.TextUtils
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.MotionEvent
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.*
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.AddShiftActivity.Companion.TASK_CONSTANT
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Objects.TaskObject
|
||||||
|
import kotlinx.android.synthetic.main.fragment_add_task.*
|
||||||
|
import java.lang.Float
|
||||||
|
|
||||||
|
class AddTaskFragment : Fragment() {
|
||||||
|
lateinit var taskList: Array<String>
|
||||||
|
lateinit var strings: Array<String>
|
||||||
|
lateinit var workTypeArray: Array<String>
|
||||||
|
var current = ""
|
||||||
|
var previous = ""
|
||||||
|
var product = ""
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
initialiseArrayString()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
|
||||||
|
return inflater.inflate(R.layout.fragment_add_task, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
if (arguments != null) {
|
||||||
|
val bundle = arguments
|
||||||
|
val taskObject = bundle?.getSerializable(TASK_CONSTANT) as TaskObject
|
||||||
|
spinner_one.setSelection(getSpinnerOneSelection(taskObject.workType!!))
|
||||||
|
pay_rate.setText(taskObject.rate.toString())
|
||||||
|
spinner_Two.setSelection(getSpinnerTwoSelection(taskObject.task!!))
|
||||||
|
}
|
||||||
|
|
||||||
|
setupSpinnerOne()
|
||||||
|
setupSpinnerTwo()
|
||||||
|
|
||||||
|
search_button.setOnClickListener(submit)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initialiseArrayString() {
|
||||||
|
taskList = resources.getStringArray(R.array.task_list)
|
||||||
|
strings = arrayOf<String>(taskList[0], taskList[1] + product, taskList[2], taskList[3])
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupSpinnerOne() {
|
||||||
|
workTypeArray = resources.getStringArray(R.array.work_type)
|
||||||
|
val spinnerArrayAdapter = object : ArrayAdapter<String>(
|
||||||
|
context, android.R.layout.simple_spinner_item,
|
||||||
|
workTypeArray
|
||||||
|
) {
|
||||||
|
override fun isEnabled(position: Int): Boolean {
|
||||||
|
return position != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getDropDownView(position: Int, convertView: View?, parent: ViewGroup): View {
|
||||||
|
val view = super.getDropDownView(position, convertView, parent)
|
||||||
|
val tv = view as TextView
|
||||||
|
if (position == 0) {
|
||||||
|
// Set the hint text color gray
|
||||||
|
tv.setTextColor(Color.GRAY)
|
||||||
|
} else {
|
||||||
|
tv.setTextColor(Color.BLACK)
|
||||||
|
}
|
||||||
|
return view
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
spinnerArrayAdapter.setDropDownViewResource(
|
||||||
|
android.R.layout
|
||||||
|
.simple_spinner_dropdown_item
|
||||||
|
)
|
||||||
|
spinner_one.adapter = spinnerArrayAdapter
|
||||||
|
spinner_one.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
|
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
||||||
|
when (position) {
|
||||||
|
1 -> unit_text.text = "per Unit"
|
||||||
|
2 -> unit_text.text = "per Hour"
|
||||||
|
else -> {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNothingSelected(parent: AdapterView<*>) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupSpinnerTwo() {
|
||||||
|
val spinnerArrayAdapter = object : ArrayAdapter<String>(
|
||||||
|
context, android.R.layout.simple_spinner_item,
|
||||||
|
strings
|
||||||
|
) {
|
||||||
|
override fun isEnabled(position: Int): Boolean {
|
||||||
|
return position != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getDropDownView(position: Int, convertView: View?, parent: ViewGroup): View {
|
||||||
|
val view = super.getDropDownView(position, convertView, parent)
|
||||||
|
val tv = view as TextView
|
||||||
|
if (position == 0) {
|
||||||
|
tv.setTextColor(Color.GRAY)
|
||||||
|
} else {
|
||||||
|
tv.setTextColor(Color.BLACK)
|
||||||
|
}
|
||||||
|
return view
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spinnerArrayAdapter.setDropDownViewResource(
|
||||||
|
android.R.layout
|
||||||
|
.simple_spinner_dropdown_item
|
||||||
|
)
|
||||||
|
spinner_Two.adapter = spinnerArrayAdapter
|
||||||
|
|
||||||
|
val listener = SpinnerInteractionListener()
|
||||||
|
|
||||||
|
spinner_Two.onItemSelectedListener = listener
|
||||||
|
spinner_Two.setOnTouchListener(listener)
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class SpinnerInteractionListener : AdapterView.OnItemSelectedListener, View.OnTouchListener {
|
||||||
|
|
||||||
|
internal var userSelect = false
|
||||||
|
|
||||||
|
override fun onTouch(v: View, event: MotionEvent): Boolean {
|
||||||
|
userSelect = true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onItemSelected(parent: AdapterView<*>, view: View, pos: Int, id: Long) {
|
||||||
|
if (userSelect) {
|
||||||
|
Toast.makeText(context, "current = $pos", Toast.LENGTH_SHORT).show()
|
||||||
|
|
||||||
|
previous = current
|
||||||
|
current = parent.getItemAtPosition(pos) as String
|
||||||
|
|
||||||
|
if (pos == 1) {
|
||||||
|
val edittext = EditText(context)
|
||||||
|
edittext.hint = "Product Harvested?"
|
||||||
|
val builder = AlertDialog.Builder(context)
|
||||||
|
builder.setView(edittext)
|
||||||
|
builder.setNegativeButton(android.R.string.cancel) { dialog, which ->
|
||||||
|
spinner_Two.setSelection(getPosition(previous))
|
||||||
|
dialog.dismiss()
|
||||||
|
}.setPositiveButton(android.R.string.ok) { dialog, which ->
|
||||||
|
val text = edittext.text.toString()
|
||||||
|
if (!TextUtils.isEmpty(text)) {
|
||||||
|
product = " $text"
|
||||||
|
initialiseArrayString()
|
||||||
|
setupSpinnerTwo()
|
||||||
|
spinner_Two.setSelection(1)
|
||||||
|
}
|
||||||
|
dialog.dismiss()
|
||||||
|
}.setOnCancelListener {
|
||||||
|
|
||||||
|
}
|
||||||
|
builder.setCancelable(false).create().show()
|
||||||
|
}
|
||||||
|
|
||||||
|
userSelect = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNothingSelected(parent: AdapterView<*>) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
internal var submit: View.OnClickListener = View.OnClickListener {
|
||||||
|
val workType = spinner_one.selectedItem as String
|
||||||
|
var rate = pay_rate.text.toString().trim({ it <= ' ' })
|
||||||
|
val task = spinner_Two.selectedItem as String
|
||||||
|
if (workType != strings[0] &&
|
||||||
|
!TextUtils.isEmpty(rate) &&
|
||||||
|
task != taskList[0]
|
||||||
|
) {
|
||||||
|
if ((spinner_Two.selectedItem as String).contains(workTypeArray[1]) && task == workTypeArray[1]) {
|
||||||
|
Toast.makeText(context, "Insert A product Harvested", Toast.LENGTH_SHORT).show()
|
||||||
|
} else {
|
||||||
|
rate = String.format("%.2f", java.lang.Float.valueOf(rate))
|
||||||
|
val taskObject = TaskObject(workType, Float.valueOf(rate), task)
|
||||||
|
|
||||||
|
val returnIntent = Intent()
|
||||||
|
returnIntent.putExtra("TaskObject", taskObject)
|
||||||
|
activity?.setResult(Activity.RESULT_OK, returnIntent)
|
||||||
|
activity?.finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Toast.makeText(context, "Insert All Required data", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getSpinnerOneSelection(s: String): Int {
|
||||||
|
return when (s) {
|
||||||
|
"Hourly" -> 1
|
||||||
|
"Piece Rate" -> 2
|
||||||
|
else -> {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getSpinnerTwoSelection(s: String): Int {
|
||||||
|
val strings = resources.getStringArray(R.array.task_list)
|
||||||
|
var i = 1
|
||||||
|
for (string in strings) {
|
||||||
|
|
||||||
|
if (s.contains(string)) {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getPosition(previous: String?): Int {
|
||||||
|
var i = 0
|
||||||
|
if (previous != null) {
|
||||||
|
for (s in strings) {
|
||||||
|
if (previous.contains(s)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.view.animation.Animation
|
||||||
|
import android.view.animation.Transformation
|
||||||
|
|
||||||
|
class ArcAnimation(val arcView: CircleView, val newAngle : Float) : Animation(){
|
||||||
|
|
||||||
|
var oldAngle: Float = arcView.getArcAngle()
|
||||||
|
|
||||||
|
override fun applyTransformation(interpolatedTime: Float, t: Transformation?) {
|
||||||
|
super.applyTransformation(interpolatedTime, t)
|
||||||
|
val angle = 0 + (newAngle - oldAngle) * interpolatedTime
|
||||||
|
|
||||||
|
arcView.setArcAngle(angle)
|
||||||
|
arcView.requestLayout()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.view.animation.Animation
|
||||||
|
import android.view.animation.Transformation
|
||||||
|
|
||||||
|
class BarAnimation(val barView: BarView, val targetWidth: Int, val startWidth : Int) : Animation(){
|
||||||
|
|
||||||
|
override fun applyTransformation(interpolatedTime: Float, t: Transformation?) {
|
||||||
|
super.applyTransformation(interpolatedTime, t)
|
||||||
|
|
||||||
|
val newWidth = (startWidth + targetWidth * interpolatedTime).toInt()
|
||||||
|
|
||||||
|
barView.getLayoutParams().width = newWidth
|
||||||
|
barView.requestLayout()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.graphics.Canvas
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.graphics.Paint
|
||||||
|
import android.graphics.RectF
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.View
|
||||||
|
|
||||||
|
class BarView(context: Context?, attrs: AttributeSet?) : View(context, attrs){
|
||||||
|
|
||||||
|
private var topRect: RectF = RectF()
|
||||||
|
private var bottomRect: RectF = RectF()
|
||||||
|
private var hardEdge: RectF = RectF()
|
||||||
|
|
||||||
|
private var colourOne: Paint = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||||
|
private var colourTwo: Paint = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||||
|
|
||||||
|
private var cover:Float
|
||||||
|
|
||||||
|
init {
|
||||||
|
colourOne.color = Color.BLUE
|
||||||
|
colourTwo.color = Color.GREEN
|
||||||
|
cover = 0.toFloat()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDraw(canvas: Canvas?) {
|
||||||
|
super.onDraw(canvas)
|
||||||
|
|
||||||
|
topRect.centerX()
|
||||||
|
topRect.centerY()
|
||||||
|
topRect.left = 0f
|
||||||
|
topRect.top = 0f
|
||||||
|
topRect.right = width.toFloat()
|
||||||
|
topRect.bottom = height.toFloat()
|
||||||
|
|
||||||
|
canvas?.drawRoundRect(topRect, 20f, 20f, colourOne)
|
||||||
|
|
||||||
|
bottomRect.centerX()
|
||||||
|
bottomRect.centerY()
|
||||||
|
if (cover < 0.05f) {
|
||||||
|
cover = 0.05f
|
||||||
|
}
|
||||||
|
bottomRect.left = (width - 20) * cover
|
||||||
|
bottomRect.top = 0f
|
||||||
|
bottomRect.right = width.toFloat()
|
||||||
|
bottomRect.bottom = height.toFloat()
|
||||||
|
|
||||||
|
canvas?.drawRoundRect(bottomRect, 20f, 20f, colourTwo)
|
||||||
|
|
||||||
|
hardEdge.centerX()
|
||||||
|
hardEdge.centerY()
|
||||||
|
hardEdge.top = bottomRect.top
|
||||||
|
hardEdge.bottom = bottomRect.bottom
|
||||||
|
|
||||||
|
hardEdge.left = bottomRect.left
|
||||||
|
hardEdge.right = hardEdge.left + 60
|
||||||
|
|
||||||
|
canvas?.drawRoundRect(hardEdge, 0f, 0f, colourTwo)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getCover(): Float {
|
||||||
|
return cover
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setCover(cover: Float) {
|
||||||
|
this.cover = cover
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setCover(total: Float, number: Float) {
|
||||||
|
this.cover = number / total
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setColourOne(colour: Int) {
|
||||||
|
colourOne.color = colour
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setColourTwo(colour: Int) {
|
||||||
|
colourTwo.color = colour
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,175 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.app.AlertDialog
|
||||||
|
import android.content.DialogInterface
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.text.InputType
|
||||||
|
import android.text.TextUtils
|
||||||
|
import android.util.Log
|
||||||
|
import android.widget.EditText
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.Toast
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.auth
|
||||||
|
import com.google.android.gms.tasks.OnCompleteListener
|
||||||
|
import com.google.android.gms.tasks.OnFailureListener
|
||||||
|
import com.google.android.gms.tasks.Task
|
||||||
|
import com.google.firebase.auth.EmailAuthProvider
|
||||||
|
import com.google.firebase.auth.FirebaseAuth
|
||||||
|
import com.google.firebase.auth.UserProfileChangeRequest
|
||||||
|
import kotlinx.android.synthetic.main.activity_change_user_details.*
|
||||||
|
|
||||||
|
class ChangeUserDetailsActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
private val TAG = "ChangeDetailsActivity"
|
||||||
|
|
||||||
|
var user = auth.currentUser
|
||||||
|
|
||||||
|
private val EMAIL_CONSTANT = "Email Address"
|
||||||
|
private val PW_CONSTANT = "Password"
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.activity_change_user_details)
|
||||||
|
|
||||||
|
change_profile_name.setOnClickListener{
|
||||||
|
val dialog = AlertDialog.Builder(this@ChangeUserDetailsActivity)
|
||||||
|
dialog.setTitle("Update Username")
|
||||||
|
|
||||||
|
val titleBox = EditText(this@ChangeUserDetailsActivity)
|
||||||
|
titleBox.setText(user?.getDisplayName())
|
||||||
|
dialog.setView(titleBox)
|
||||||
|
dialog.setPositiveButton(
|
||||||
|
"Update"
|
||||||
|
) { dialog, which ->
|
||||||
|
updateProfile(titleBox.text.toString().trim { it <= ' ' })
|
||||||
|
}
|
||||||
|
dialog.create().show()
|
||||||
|
}
|
||||||
|
|
||||||
|
change_email.setOnClickListener{
|
||||||
|
showDialog(EMAIL_CONSTANT)
|
||||||
|
}
|
||||||
|
|
||||||
|
change_pw.setOnClickListener{
|
||||||
|
showDialog(PW_CONSTANT)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateProfile(profileName: String) {
|
||||||
|
val profileUpdatesBuilder = UserProfileChangeRequest.Builder()
|
||||||
|
|
||||||
|
if (!TextUtils.isEmpty(profileName)) {
|
||||||
|
profileUpdatesBuilder.setDisplayName(profileName)
|
||||||
|
}
|
||||||
|
|
||||||
|
val profileUpdates = profileUpdatesBuilder.build()
|
||||||
|
|
||||||
|
user?.updateProfile(profileUpdates)
|
||||||
|
?.addOnCompleteListener { task ->
|
||||||
|
if (task.isSuccessful) {
|
||||||
|
Log.i(TAG, "User profile updated.")
|
||||||
|
// viewController.reloadDrawer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?.addOnFailureListener {
|
||||||
|
Toast.makeText(this@ChangeUserDetailsActivity, "Update Failed", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun changeCredentials(email: String, password: String, changeText: String, selector: String) {
|
||||||
|
//todo: change to function
|
||||||
|
|
||||||
|
// Get auth credentials from the user for re-authentication
|
||||||
|
val credential = EmailAuthProvider
|
||||||
|
.getCredential(email, password) // Current Login Credentials \\
|
||||||
|
// Prompt the user to re-provide their sign-in credentials
|
||||||
|
user?.reauthenticate(credential)
|
||||||
|
?.addOnCompleteListener {
|
||||||
|
Log.d(TAG, "User re-authenticated.")
|
||||||
|
|
||||||
|
user = FirebaseAuth.getInstance().currentUser
|
||||||
|
if (selector == EMAIL_CONSTANT) {
|
||||||
|
|
||||||
|
user?.updateEmail(changeText)!!
|
||||||
|
.addOnCompleteListener { task ->
|
||||||
|
if (task.isSuccessful) {
|
||||||
|
Log.d(TAG, "User email address updated.")
|
||||||
|
Toast.makeText(
|
||||||
|
this@ChangeUserDetailsActivity,
|
||||||
|
"Email Update Successful",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
|
||||||
|
// viewController.reloadDrawer();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(
|
||||||
|
this@ChangeUserDetailsActivity,
|
||||||
|
"Email Update Unsuccessful",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (selector == PW_CONSTANT) {
|
||||||
|
user?.updatePassword(changeText)!!
|
||||||
|
.addOnCompleteListener { task ->
|
||||||
|
if (task.isSuccessful) {
|
||||||
|
Log.d(TAG, "User email address updated.")
|
||||||
|
Toast.makeText(
|
||||||
|
this@ChangeUserDetailsActivity,
|
||||||
|
"Password Update Successful",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
} else {
|
||||||
|
Toast.makeText(
|
||||||
|
this@ChangeUserDetailsActivity,
|
||||||
|
"Password Update Unsuccessful",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showDialog(update: String) {
|
||||||
|
//Make new Dialog
|
||||||
|
val dialog = AlertDialog.Builder(this@ChangeUserDetailsActivity)
|
||||||
|
dialog.setTitle("Update $update")
|
||||||
|
|
||||||
|
val layout = LinearLayout(this@ChangeUserDetailsActivity)
|
||||||
|
layout.orientation = LinearLayout.VERTICAL
|
||||||
|
layout.setPadding(28, 0, 56, 0)
|
||||||
|
|
||||||
|
val box1 = EditText(this@ChangeUserDetailsActivity)
|
||||||
|
box1.hint = "Current Email Address"
|
||||||
|
box1.inputType = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
|
||||||
|
layout.addView(box1) // Notice this is an add method
|
||||||
|
|
||||||
|
val box2 = EditText(this@ChangeUserDetailsActivity)
|
||||||
|
box2.hint = "Current Password"
|
||||||
|
box2.inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD
|
||||||
|
layout.addView(box2) // Another add method
|
||||||
|
|
||||||
|
val box3 = EditText(this@ChangeUserDetailsActivity)
|
||||||
|
if (update == PW_CONSTANT) {
|
||||||
|
box3.inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD
|
||||||
|
} else {
|
||||||
|
box3.inputType = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
|
||||||
|
}
|
||||||
|
box3.hint = "New $update"
|
||||||
|
layout.addView(box3) // Another add method
|
||||||
|
|
||||||
|
dialog.setView(layout)
|
||||||
|
dialog.setPositiveButton("Update") { dialog, which ->
|
||||||
|
val email = box1.text.toString().trim { it <= ' ' }
|
||||||
|
val password = box2.text.toString().trim { it <= ' ' }
|
||||||
|
val textThree = box3.text.toString().trim { it <= ' ' }
|
||||||
|
|
||||||
|
changeCredentials(email, password, textThree, update)
|
||||||
|
}
|
||||||
|
dialog.create().show()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.graphics.*
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.DragEvent
|
||||||
|
import android.view.View
|
||||||
|
|
||||||
|
class CircleView(context: Context?, attrs: AttributeSet?) : View(context, attrs){
|
||||||
|
|
||||||
|
private var arcAngle: Float = 0.toFloat()
|
||||||
|
private var mRect: RectF = RectF()
|
||||||
|
private var mRect2: RectF = RectF()
|
||||||
|
private var mPaint: Paint = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||||
|
private var paint2: Paint = Paint()
|
||||||
|
private var thinkness: Int = 0
|
||||||
|
|
||||||
|
init {
|
||||||
|
paint2.isAntiAlias = true
|
||||||
|
paint2.color = Color.TRANSPARENT
|
||||||
|
paint2.xfermode = PorterDuffXfermode(PorterDuff.Mode.CLEAR)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||||
|
super.onMeasure(widthMeasureSpec, widthMeasureSpec)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDraw(canvas: Canvas?) {
|
||||||
|
super.onDraw(canvas)
|
||||||
|
|
||||||
|
if (thinkness == 0) {
|
||||||
|
thinkness = 35
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mRect.centerX()
|
||||||
|
mRect.centerY()
|
||||||
|
mRect.left = 10f
|
||||||
|
mRect.top = 10f
|
||||||
|
mRect.right = (width - 10).toFloat()
|
||||||
|
mRect.bottom = (width - 10).toFloat()
|
||||||
|
|
||||||
|
mRect2.centerX()
|
||||||
|
mRect2.centerY()
|
||||||
|
mRect2.left = mRect.left + thinkness
|
||||||
|
mRect2.top = mRect.top + thinkness
|
||||||
|
mRect2.right = mRect.right - thinkness
|
||||||
|
mRect2.bottom = mRect.bottom - thinkness
|
||||||
|
|
||||||
|
setBackgroundColor(Color.TRANSPARENT)
|
||||||
|
if (mPaint.getColor() == 0) {
|
||||||
|
mPaint.setColor(Color.BLUE)
|
||||||
|
}
|
||||||
|
|
||||||
|
setLayerType(LAYER_TYPE_SOFTWARE, null)
|
||||||
|
|
||||||
|
canvas?.drawArc(mRect, 270f, arcAngle, true, mPaint)
|
||||||
|
canvas?.drawOval(mRect2, paint2)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setPaintColor(color: Int) {
|
||||||
|
mPaint.setColor(color)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setThickness(thickness: Int) {
|
||||||
|
this.thinkness = thickness
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getArcAngle(): Float {
|
||||||
|
return arcAngle
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setArcAngle(arcAngle: Float) {
|
||||||
|
this.arcAngle = arcAngle
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.DialogInterface
|
||||||
|
import android.graphics.Typeface
|
||||||
|
import android.os.Build
|
||||||
|
import android.view.View
|
||||||
|
import android.view.animation.AnimationUtils
|
||||||
|
import android.widget.DatePicker
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import kotlinx.android.synthetic.main.date_selector_dialog.*
|
||||||
|
import kotlinx.android.synthetic.main.date_selector_dialog.view.*
|
||||||
|
import java.text.DecimalFormat
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class CustomDialog(context: Context): AlertDialog(context){
|
||||||
|
companion object{
|
||||||
|
lateinit var dateSelectionFrom:String
|
||||||
|
lateinit var dateSelectionTo:String
|
||||||
|
}
|
||||||
|
|
||||||
|
lateinit var currentTag:String
|
||||||
|
|
||||||
|
init {
|
||||||
|
init()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun init(){
|
||||||
|
setTitle("Select Dates:")
|
||||||
|
val dialogView = View.inflate(context, R.layout.date_selector_dialog, null)
|
||||||
|
//get date picker
|
||||||
|
val datePicker = dialogView.date_picker
|
||||||
|
//set onclick listener
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
datePicker.setOnDateChangedListener(dateChangedListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleTextButtons(true)
|
||||||
|
|
||||||
|
from_date.setOnClickListener(onClickListener)
|
||||||
|
to_date.setOnClickListener(onClickListener)
|
||||||
|
|
||||||
|
val calendar = Calendar.getInstance()
|
||||||
|
val dateString = retrieveDateString(
|
||||||
|
calendar.get(Calendar.YEAR),
|
||||||
|
calendar.get(Calendar.MONTH) + 1,
|
||||||
|
calendar.get(Calendar.DAY_OF_MONTH)
|
||||||
|
)
|
||||||
|
|
||||||
|
dateSelectionFrom = dateString
|
||||||
|
dateSelectionTo = dateString
|
||||||
|
|
||||||
|
create()
|
||||||
|
}
|
||||||
|
|
||||||
|
internal var dateChangedListener: DatePicker.OnDateChangedListener =
|
||||||
|
DatePicker.OnDateChangedListener { view, year, monthOfYear, dayOfMonth ->
|
||||||
|
var monthOfYear = monthOfYear
|
||||||
|
monthOfYear = monthOfYear + 1
|
||||||
|
if (currentTag == "from") {
|
||||||
|
dateSelectionFrom = retrieveDateString(year, monthOfYear, dayOfMonth)
|
||||||
|
} else {
|
||||||
|
dateSelectionTo = retrieveDateString(year, monthOfYear, dayOfMonth)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal var onClickListener: View.OnClickListener = View.OnClickListener { v ->
|
||||||
|
currentTag = v.tag as String
|
||||||
|
|
||||||
|
if (currentTag == "from") {
|
||||||
|
toggleTextButtons(true)
|
||||||
|
setDateOnDatePicker(dateSelectionFrom, v as DatePicker)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
toggleTextButtons(false)
|
||||||
|
setDateOnDatePicker(dateSelectionTo,v as DatePicker)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun retrieveDateString(year: Int, monthOfYear: Int, dayOfMonth: Int): String {
|
||||||
|
val mFormat = DecimalFormat("00")
|
||||||
|
|
||||||
|
val monthString = mFormat.format(monthOfYear.toLong())
|
||||||
|
val dayString = mFormat.format(dayOfMonth.toLong())
|
||||||
|
|
||||||
|
return "$year-$monthString-$dayString"
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setDateOnDatePicker(dateString: String, datePicker: DatePicker) {
|
||||||
|
/* 2019-06-04 */
|
||||||
|
val year = Integer.parseInt(dateString.substring(0, 4))
|
||||||
|
val month = Integer.parseInt(dateString.substring(5, 7)) - 1
|
||||||
|
val day = Integer.parseInt(dateString.substring(8))
|
||||||
|
|
||||||
|
datePicker.init(year, month, day, dateChangedListener)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun toggleTextButtons(top: Boolean) {
|
||||||
|
setFadeAnimation(from_date)
|
||||||
|
setFadeAnimation(to_date)
|
||||||
|
|
||||||
|
if (top) {
|
||||||
|
from_date.setTypeface(null, Typeface.BOLD)
|
||||||
|
to_date.setTypeface(null, Typeface.NORMAL)
|
||||||
|
|
||||||
|
from_date.setBackgroundColor(context?.getColor(R.color.one)!!)
|
||||||
|
to_date.setBackgroundColor(context?.getColor(android.R.color.white)!!)
|
||||||
|
} else {
|
||||||
|
to_date.setTypeface(null, Typeface.BOLD)
|
||||||
|
from_date.setTypeface(null, Typeface.NORMAL)
|
||||||
|
|
||||||
|
to_date.setBackgroundColor(context?.getColor(R.color.one)!!)
|
||||||
|
from_date.setBackgroundColor(context?.getColor(android.R.color.white)!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setFadeAnimation(view: View) {
|
||||||
|
val bottomUp = AnimationUtils.loadAnimation(
|
||||||
|
context,
|
||||||
|
R.anim.fade_in
|
||||||
|
)
|
||||||
|
|
||||||
|
view.animation = bottomUp
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.app.DatePickerDialog
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Build
|
||||||
|
import android.text.TextUtils
|
||||||
|
import android.util.Log
|
||||||
|
import android.widget.DatePicker
|
||||||
|
import android.widget.EditText
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.annotation.RequiresApi
|
||||||
|
import kotlinx.android.synthetic.main.activity_add_shift.*
|
||||||
|
import java.text.ParseException
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
|
class DateDialog(editText: EditText, context: Context) : DatePickerDialog(context) {
|
||||||
|
|
||||||
|
internal var mYear: Int = 0
|
||||||
|
internal var mMonth: Int = 0
|
||||||
|
internal var mDay: Int = 0
|
||||||
|
|
||||||
|
init {
|
||||||
|
val dateString = editText.text.toString()
|
||||||
|
|
||||||
|
var javaDate: Date? = null
|
||||||
|
|
||||||
|
if (dateString.isNotBlank()) {
|
||||||
|
val calendar = Calendar.getInstance()
|
||||||
|
mYear = calendar.get(Calendar.YEAR)
|
||||||
|
mMonth = calendar.get(Calendar.MONTH)
|
||||||
|
mDay = calendar.get(Calendar.DAY_OF_MONTH)
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
val sdfrmt = SimpleDateFormat("dd/MM/yyyy")
|
||||||
|
sdfrmt.isLenient = false
|
||||||
|
javaDate = sdfrmt.parse(dateString)
|
||||||
|
} catch (e: ParseException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
} finally {
|
||||||
|
if (javaDate != null) {
|
||||||
|
mYear = Integer.parseInt(dateString.substring(6, dateString.length))
|
||||||
|
mMonth = Integer.parseInt(dateString.substring(3, 5)) - 1
|
||||||
|
mDay = Integer.parseInt(dateString.substring(0, 2))
|
||||||
|
} else {
|
||||||
|
val calendar = Calendar.getInstance()
|
||||||
|
mYear = calendar.get(Calendar.YEAR)
|
||||||
|
mMonth = calendar.get(Calendar.MONTH)
|
||||||
|
mDay = calendar.get(Calendar.DAY_OF_MONTH)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.i(
|
||||||
|
this.javaClass.simpleName, "init: year =" + mYear +
|
||||||
|
"month = " + mMonth +
|
||||||
|
"day = " + mDay
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
updateDate(mYear, mMonth, mDay)
|
||||||
|
|
||||||
|
setOnDateSetListener{ view, year, month, dayOfMonth ->
|
||||||
|
mYear = year
|
||||||
|
mMonth = month + 1
|
||||||
|
mDay = dayOfMonth
|
||||||
|
|
||||||
|
val dateString = mYear.toString() + "-" + String.format("%02d", mMonth) + "-" + String.format("%02d", mDay)
|
||||||
|
|
||||||
|
Toast.makeText(context,dateString,Toast.LENGTH_SHORT).show()
|
||||||
|
editText.setText(dateString)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setTitle(getContext().getString(R.string.set_date))
|
||||||
|
this.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.ArrayAdapter
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Objects.TaskObject
|
||||||
|
import kotlinx.android.synthetic.main.task_list_item.*
|
||||||
|
import kotlinx.android.synthetic.main.task_list_item.view.*
|
||||||
|
|
||||||
|
class DialogListAdapter(context: Context, objects: MutableList<TaskObject>) :
|
||||||
|
ArrayAdapter<TaskObject>(context, 0, objects){
|
||||||
|
|
||||||
|
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
||||||
|
var view: View? = convertView
|
||||||
|
if (view == null) {
|
||||||
|
view = LayoutInflater.from(context).inflate(R.layout.task_list_item, parent, false)!!
|
||||||
|
}
|
||||||
|
|
||||||
|
val currentTask = getItem(position)
|
||||||
|
|
||||||
|
view.task.text = currentTask?.task
|
||||||
|
var summary = currentTask?.workType + " - $" + currentTask?.rate + " /"
|
||||||
|
|
||||||
|
if (currentTask?.workType.equals("Piece Rate")) {
|
||||||
|
summary = "$summary Unit"
|
||||||
|
view.task_image.setImageResource(R.drawable.piece)
|
||||||
|
} else if(currentTask?.workType.equals("Hourly")){
|
||||||
|
summary = "$summary Hour"
|
||||||
|
view.task_image.setImageResource(R.drawable.task)
|
||||||
|
}
|
||||||
|
|
||||||
|
view.task_summary.setText(summary)
|
||||||
|
|
||||||
|
return view
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.TextView
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Objects.ShiftObject
|
||||||
|
import com.firebase.ui.database.FirebaseListAdapter
|
||||||
|
import com.google.firebase.database.Query
|
||||||
|
import kotlinx.android.synthetic.main.list_item.view.*
|
||||||
|
import kotlinx.android.synthetic.main.list_item.*
|
||||||
|
|
||||||
|
class FireAdapter(activity: Activity?, modelClass: Class<ShiftObject>?, modelLayout: Int, ref: Query?) :
|
||||||
|
FirebaseListAdapter<ShiftObject>(activity, modelClass, modelLayout, ref) {
|
||||||
|
|
||||||
|
override fun populateView(v: View?, model: ShiftObject?, position: Int) {
|
||||||
|
v?.farm_name?.text = model?.abnObject?.abn
|
||||||
|
v?.date?.text = model?.shiftDate
|
||||||
|
v?.task_name?.text = model?.taskObject?.task
|
||||||
|
v?.type?.text = model?.taskObject?.workType
|
||||||
|
val locationString:String = model?.abnObject?.state + " - " + model?.abnObject?.postCode
|
||||||
|
v?.location?.text = locationString
|
||||||
|
|
||||||
|
v?.farm_name?.text = model?.abnObject?.companyName
|
||||||
|
|
||||||
|
var s = model?.taskObject?.workType + " - $" + model?.taskObject?.rate + "/"
|
||||||
|
|
||||||
|
if (model?.taskObject?.workType == FirebaseClass.HOURLY){
|
||||||
|
s = "$s Hour"
|
||||||
|
v?.time_holder?.visibility = View.VISIBLE
|
||||||
|
v?.units_holder?.visibility = View.GONE
|
||||||
|
|
||||||
|
val time = model.timeObject?.timeIn + " - " + model.timeObject!!.timeOut
|
||||||
|
v?.time?.text = time
|
||||||
|
|
||||||
|
model.timeObject!!.breakEpoch.let { mins ->
|
||||||
|
val breakHolder = v?.break_holder
|
||||||
|
if (mins > 0){
|
||||||
|
breakHolder?.visibility = View.VISIBLE
|
||||||
|
v?.break_time?.text = getBreakTimeString(model.timeObject!!.breakEpoch)
|
||||||
|
}else{
|
||||||
|
breakHolder?.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
s = "$s Unit"
|
||||||
|
v?.time_holder?.visibility = View.GONE
|
||||||
|
v?.units_holder?.visibility = View.VISIBLE
|
||||||
|
|
||||||
|
v?.units?.text = model?.unitsCount.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
v?.type?.text = s
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getBreakTimeString(breakMins: Int): String {
|
||||||
|
val hoursFloat = (breakMins / 60).toFloat()
|
||||||
|
|
||||||
|
val hoursInt = Math.floor(hoursFloat.toDouble()).toInt()
|
||||||
|
val minsInt = breakMins - hoursInt * 60
|
||||||
|
|
||||||
|
var s = ""
|
||||||
|
if (hoursInt > 0) {
|
||||||
|
s = "$hoursInt h "
|
||||||
|
}
|
||||||
|
|
||||||
|
if (minsInt > 0) {
|
||||||
|
s = "$s$minsInt m"
|
||||||
|
}
|
||||||
|
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getId(i: Int): String? {
|
||||||
|
return getRef(i).key
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import com.google.firebase.auth.FirebaseAuth
|
||||||
|
import com.google.firebase.database.DatabaseReference
|
||||||
|
import com.google.firebase.database.FirebaseDatabase
|
||||||
|
|
||||||
|
class FirebaseClass {
|
||||||
|
companion object {
|
||||||
|
val mDatabase: DatabaseReference = FirebaseDatabase.getInstance().getReference()
|
||||||
|
var auth: FirebaseAuth = FirebaseAuth.getInstance()
|
||||||
|
|
||||||
|
val USER_FIREBASE = "users"
|
||||||
|
val EMPLOYER_FIREBASE = "employers"
|
||||||
|
val SHIFT_FIREBASE = "shifts"
|
||||||
|
val TASK_FIREBASE = "taskList"
|
||||||
|
|
||||||
|
val SHIFT_ID = "shift_id"
|
||||||
|
|
||||||
|
val PIECE = "Piece Rate"
|
||||||
|
val HOURLY = "Hourly"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,235 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.app.AlertDialog
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.DialogInterface
|
||||||
|
import android.content.DialogInterface.BUTTON_POSITIVE
|
||||||
|
import android.content.Intent
|
||||||
|
import android.graphics.Typeface
|
||||||
|
import android.net.Uri
|
||||||
|
import android.os.Build
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.*
|
||||||
|
import android.view.animation.AnimationUtils
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.widget.AdapterView
|
||||||
|
import android.widget.DatePicker
|
||||||
|
import android.widget.TextView
|
||||||
|
import android.widget.Toast
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.CustomDialog.Companion.dateSelectionFrom
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.CustomDialog.Companion.dateSelectionTo
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.SHIFT_FIREBASE
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.SHIFT_ID
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.USER_FIREBASE
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.auth
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.mDatabase
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Objects.AbnObject
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Objects.ShiftObject
|
||||||
|
import com.google.firebase.database.DatabaseReference
|
||||||
|
import com.google.firebase.database.FirebaseDatabase
|
||||||
|
import com.google.firebase.database.Query
|
||||||
|
import kotlinx.android.synthetic.main.date_selector_dialog.*
|
||||||
|
import kotlinx.android.synthetic.main.date_selector_dialog.view.*
|
||||||
|
import kotlinx.android.synthetic.main.dialog_previous_abns_used.*
|
||||||
|
import kotlinx.android.synthetic.main.dialog_previous_abns_used.view.*
|
||||||
|
import kotlinx.android.synthetic.main.dialog_search_employer.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_list.*
|
||||||
|
import java.lang.ref.PhantomReference
|
||||||
|
import java.text.DecimalFormat
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
|
class FragmentList : androidx.fragment.app.Fragment() {
|
||||||
|
|
||||||
|
|
||||||
|
lateinit var reference : DatabaseReference
|
||||||
|
lateinit var fireAdapter:FireAdapter
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
reference = mDatabase.child(USER_FIREBASE).child(auth.uid!!).child(SHIFT_FIREBASE)
|
||||||
|
reference.keepSynced(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
return inflater.inflate(R.layout.fragment_list, container, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
|
super.onActivityCreated(savedInstanceState)
|
||||||
|
|
||||||
|
//set custom firebase adapter on listview
|
||||||
|
fireAdapter = FireAdapter(activity, ShiftObject::class.java,R.layout.list_item,reference)
|
||||||
|
page_two_list.adapter = fireAdapter
|
||||||
|
|
||||||
|
page_two_list.setOnItemClickListener(object : AdapterView.OnItemClickListener{
|
||||||
|
override fun onItemClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||||
|
val refId = fireAdapter.getId(position)
|
||||||
|
val intent = Intent(activity, AddShiftActivity::class.java)
|
||||||
|
intent.putExtra(SHIFT_ID, refId)
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
page_two_list.setOnItemLongClickListener(object : AdapterView.OnItemLongClickListener{
|
||||||
|
override fun onItemLongClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long): Boolean {
|
||||||
|
val builder = AlertDialog.Builder(context)
|
||||||
|
builder.setTitle("Are you sure you want to delete?")
|
||||||
|
builder.setNegativeButton(android.R.string.no, null)
|
||||||
|
builder.setPositiveButton(
|
||||||
|
android.R.string.yes
|
||||||
|
) { dialog, which ->
|
||||||
|
|
||||||
|
fireAdapter.getRef(position).removeValue()
|
||||||
|
}
|
||||||
|
builder.create().show()
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) {
|
||||||
|
super.onCreateOptionsMenu(menu, inflater)
|
||||||
|
inflater?.inflate(R.menu.menu_list_fragment, menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
|
||||||
|
when (item?.getItemId()) {
|
||||||
|
R.id.app_bar_filter -> {
|
||||||
|
filterData()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
R.id.app_bar_soft -> {
|
||||||
|
sortData()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun sortData() {
|
||||||
|
val grpname = arrayOf("Name", "Date Added", "Date of shift")
|
||||||
|
val checkedItem = -1
|
||||||
|
|
||||||
|
val alt_bld = AlertDialog.Builder(context)
|
||||||
|
alt_bld.setTitle("Sort by:")
|
||||||
|
alt_bld.setSingleChoiceItems(grpname, checkedItem) { dialog, item ->
|
||||||
|
when (item) {
|
||||||
|
0 -> {
|
||||||
|
val q1 = reference.orderByChild("abnObject/companyName").equalTo("GREEN CLOUD NURSERY")
|
||||||
|
fireAdapter = FireAdapter(activity, ShiftObject::class.java, R.layout.list_item, q1)
|
||||||
|
}
|
||||||
|
1 -> fireAdapter = FireAdapter(
|
||||||
|
activity,
|
||||||
|
ShiftObject::class.java,
|
||||||
|
R.layout.list_item,
|
||||||
|
reference.orderByChild("dateTimeAdded")
|
||||||
|
)
|
||||||
|
2 -> fireAdapter = FireAdapter(
|
||||||
|
activity,
|
||||||
|
ShiftObject::class.java,
|
||||||
|
R.layout.list_item,
|
||||||
|
reference.orderByChild("shiftDate")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
page_two_list.adapter = fireAdapter
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
|
alt_bld.create().show()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun filterData(){
|
||||||
|
val groupName = arrayOf("Name", "Date Added", "Shift Type")
|
||||||
|
val checkedItem = -1
|
||||||
|
|
||||||
|
val builder = AlertDialog.Builder(context)
|
||||||
|
builder.setTitle("Filter by:")
|
||||||
|
builder.setSingleChoiceItems(groupName,checkedItem, DialogInterface.OnClickListener{dialog, item ->
|
||||||
|
dialog.dismiss()
|
||||||
|
|
||||||
|
when(item) {
|
||||||
|
0 -> {
|
||||||
|
val dialogBuilder = AlertDialog.Builder(context)
|
||||||
|
dialogBuilder.setTitle("Select Employer:")
|
||||||
|
//get layout
|
||||||
|
val dialogView = View.inflate(context, R.layout.dialog_previous_abns_used, null)
|
||||||
|
//hide button
|
||||||
|
dialogView.button_list_dialog.visibility = View.GONE
|
||||||
|
//get listview
|
||||||
|
val listView = dialogView.list_item_list_dialog
|
||||||
|
//get unique abn objects
|
||||||
|
val uniqueAbnObjects= turnToUniqueAbnObject(MainActivity.shiftList)
|
||||||
|
//populate list in view
|
||||||
|
listView.adapter = AbnListAdapter(context!!,uniqueAbnObjects as MutableList<AbnObject>)
|
||||||
|
//on item click listener
|
||||||
|
listView.setOnItemClickListener(AdapterView.OnItemClickListener{parent, view, position, id ->
|
||||||
|
applyFilter(uniqueAbnObjects[position].abn!!,null)
|
||||||
|
})
|
||||||
|
//set view on dialog
|
||||||
|
dialogBuilder.setView(dialogView)
|
||||||
|
|
||||||
|
dialogBuilder.create().show()
|
||||||
|
|
||||||
|
}
|
||||||
|
1 -> {
|
||||||
|
val customDialog = CustomDialog(context!!)
|
||||||
|
|
||||||
|
customDialog.setButton(BUTTON_POSITIVE, getContext()?.getString(android.R.string.yes),
|
||||||
|
DialogInterface.OnClickListener{ dialogNew, which ->
|
||||||
|
//interface results back
|
||||||
|
if (dateSelectionFrom != dateSelectionTo) {
|
||||||
|
applyFilter(dateSelectionFrom, dateSelectionTo)
|
||||||
|
}
|
||||||
|
|
||||||
|
customDialog.dismiss()
|
||||||
|
})
|
||||||
|
|
||||||
|
customDialog.create()
|
||||||
|
}
|
||||||
|
2 -> {
|
||||||
|
val typeDialog = AlertDialog.Builder(context)
|
||||||
|
val typeString = arrayOf("Hourly", "Piece Rate")
|
||||||
|
|
||||||
|
typeDialog.setSingleChoiceItems(
|
||||||
|
arrayOf("Hourly", "Piece Rate"), -1
|
||||||
|
) { dialog, which ->
|
||||||
|
val q1 = reference.orderByChild("taskObject/workType").equalTo(typeString[which])
|
||||||
|
|
||||||
|
fireAdapter = FireAdapter(activity, ShiftObject::class.java, R.layout.list_item, q1)
|
||||||
|
page_two_list.adapter = fireAdapter
|
||||||
|
}
|
||||||
|
typeDialog.create().show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun turnToUniqueAbnObject(shifts : ArrayList<ShiftObject>): List<AbnObject>{
|
||||||
|
val abnList = mutableListOf<AbnObject>()
|
||||||
|
|
||||||
|
shifts.forEach{shiftObject ->
|
||||||
|
shiftObject.abnObject?.let { abnList.add(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
return abnList.distinct()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun applyFilter(arg1: String, arg2: String?) {
|
||||||
|
val q1: Query
|
||||||
|
if (arg2 == null) {
|
||||||
|
q1 = reference.orderByChild("abnObject/abn").equalTo(arg1)
|
||||||
|
} else {
|
||||||
|
q1 = reference.orderByChild("shiftDate").startAt(arg1).endAt(arg2)
|
||||||
|
}
|
||||||
|
|
||||||
|
fireAdapter = FireAdapter(activity, ShiftObject::class.java, R.layout.list_item, q1)
|
||||||
|
page_two_list.adapter = fireAdapter
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,190 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
|
import android.app.ProgressDialog
|
||||||
|
import android.content.ActivityNotFoundException
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.pm.PackageManager
|
||||||
|
import android.os.AsyncTask
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.os.Environment
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.ProgressBar
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.core.app.ActivityCompat
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.content.ContextCompat.checkSelfPermission
|
||||||
|
import androidx.core.content.FileProvider
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.auth
|
||||||
|
import com.google.android.gms.tasks.Continuation
|
||||||
|
import com.google.android.gms.tasks.OnCompleteListener
|
||||||
|
import com.google.android.gms.tasks.Task
|
||||||
|
import com.google.firebase.functions.FirebaseFunctions
|
||||||
|
import com.google.firebase.functions.FirebaseFunctionsException
|
||||||
|
import com.google.firebase.functions.HttpsCallableResult
|
||||||
|
import com.google.firebase.storage.FirebaseStorage
|
||||||
|
import kotlinx.android.synthetic.main.fragment_tools.*
|
||||||
|
import java.io.File
|
||||||
|
import java.net.URL
|
||||||
|
import java.util.HashMap
|
||||||
|
|
||||||
|
class FragmentTools : Fragment() {
|
||||||
|
|
||||||
|
private val TAG = "FragmentTools"
|
||||||
|
|
||||||
|
val mFunctions = FirebaseFunctions.getInstance()
|
||||||
|
val storage = FirebaseStorage.getInstance()
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
return inflater.inflate(R.layout.fragment_tools, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
|
super.onActivityCreated(savedInstanceState)
|
||||||
|
|
||||||
|
compile.setOnClickListener(onClickListener)
|
||||||
|
|
||||||
|
summary_button.setOnClickListener(onClickListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal val onClickListener = View.OnClickListener { view ->
|
||||||
|
requestPermissions().let {
|
||||||
|
if (it) {
|
||||||
|
if (view.id == R.id.compile){
|
||||||
|
writeToExcel().addOnCompleteListener(complete)
|
||||||
|
}else if(view.id == R.id.summary_button){
|
||||||
|
writeToExcelVisa().addOnCompleteListener(complete)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
internal val complete = OnCompleteListener<String>{task ->
|
||||||
|
if (!task.isSuccessful) {
|
||||||
|
val e = task.exception
|
||||||
|
if (e is FirebaseFunctionsException) {
|
||||||
|
val ffe = e as FirebaseFunctionsException?
|
||||||
|
val code = ffe!!.code
|
||||||
|
val details = ffe.details
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.w(TAG, "addMessage:onFailure", e)
|
||||||
|
Toast.makeText(context, "An error occurred.", Toast.LENGTH_SHORT).show()
|
||||||
|
|
||||||
|
}else{
|
||||||
|
// [START_EXCLUDE]
|
||||||
|
val result = task.result as String
|
||||||
|
Log.i(TAG, "onComplete: $result")
|
||||||
|
|
||||||
|
val strings = result.split("/").toTypedArray()
|
||||||
|
|
||||||
|
val fbstore = storage.reference.child(result)
|
||||||
|
|
||||||
|
val savePath = Environment.getExternalStorageDirectory().toString() + "/DaysLeftTemp"
|
||||||
|
val file = File(savePath)
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.mkdirs()
|
||||||
|
}
|
||||||
|
|
||||||
|
val myFile = File(savePath, strings.last())
|
||||||
|
|
||||||
|
fbstore.getFile(myFile).addOnSuccessListener {
|
||||||
|
// Local temp file has been created
|
||||||
|
val data =
|
||||||
|
FileProvider.getUriForFile(context!!, BuildConfig.APPLICATION_ID + ".provider", myFile)
|
||||||
|
activity?.grantUriPermission(
|
||||||
|
activity?.getPackageName(),
|
||||||
|
data,
|
||||||
|
Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||||
|
)
|
||||||
|
val intent1 = Intent(Intent.ACTION_VIEW)
|
||||||
|
.setDataAndType(data, "application/vnd.ms-excel")
|
||||||
|
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||||
|
|
||||||
|
try {
|
||||||
|
activity?.startActivity(intent1)
|
||||||
|
} catch (e: ActivityNotFoundException) {
|
||||||
|
Toast.makeText(activity, "No Application Available to View Excel", Toast.LENGTH_SHORT)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}.addOnFailureListener {
|
||||||
|
// Handle any errors
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun writeToExcel(): Task<String> {
|
||||||
|
// Create the arguments to the callable function.
|
||||||
|
val data = HashMap<String, Any>()
|
||||||
|
data["push"] = true
|
||||||
|
|
||||||
|
return mFunctions
|
||||||
|
.getHttpsCallable("writeFireToExcel")
|
||||||
|
.call(data)
|
||||||
|
.continueWith{ task ->
|
||||||
|
// This continuation runs on either success or failure, but if the task
|
||||||
|
// has failed then getResult() will throw an Exception which will be
|
||||||
|
// propagated down.
|
||||||
|
|
||||||
|
val result = task.result?.data as String
|
||||||
|
|
||||||
|
Log.i(TAG, "then: " + result)
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun writeToExcelVisa(): Task<String> {
|
||||||
|
// Create the arguments to the callable function.
|
||||||
|
val data = HashMap<String, Any>()
|
||||||
|
data["push"] = true
|
||||||
|
|
||||||
|
return mFunctions
|
||||||
|
.getHttpsCallable("writeFireToExcelVisa")
|
||||||
|
.call(data)
|
||||||
|
.continueWith{ task ->
|
||||||
|
// This continuation runs on either success or failure, but if the task
|
||||||
|
// has failed then getResult() will throw an Exception which will be
|
||||||
|
// propagated down.
|
||||||
|
//todo: change to file
|
||||||
|
val result = task.result?.data as String
|
||||||
|
|
||||||
|
Log.i(TAG, "then: " + result)
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun requestPermissions() : Boolean{
|
||||||
|
if (checkSelfPermission(context!!, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||||
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
|
Toast.makeText(context,"not granted",Toast.LENGTH_SHORT).show()
|
||||||
|
|
||||||
|
requestPermissions(
|
||||||
|
arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
|
||||||
|
443)
|
||||||
|
|
||||||
|
return false
|
||||||
|
}else{
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.net.Uri
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import kotlinx.android.synthetic.main.fragment_home.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_home.view.*
|
||||||
|
|
||||||
|
|
||||||
|
class HomeFragment : androidx.fragment.app.Fragment() {
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
val view : View = inflater.inflate(R.layout.fragment_home, container, false)
|
||||||
|
|
||||||
|
view.recycler.adapter = context?.let { RecAdapter(it,MainActivity.shiftList) }
|
||||||
|
|
||||||
|
view.recycler.setLayoutManager(LinearLayoutManager(context))
|
||||||
|
view.recycler.setHasFixedSize(true)
|
||||||
|
|
||||||
|
return view
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin.Login
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.Toast
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Login.FullscreenActivity.Companion.fragmentManagerLogin
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.R
|
||||||
|
import com.google.firebase.auth.FirebaseAuth
|
||||||
|
import kotlinx.android.synthetic.main.fragment_forgot_password.*
|
||||||
|
|
||||||
|
|
||||||
|
class ForgotPassword : Fragment() {
|
||||||
|
|
||||||
|
internal var TAG = "forgotPasswordFragment"
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
return inflater.inflate(R.layout.fragment_forgot_password, container, false)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
|
super.onActivityCreated(savedInstanceState)
|
||||||
|
|
||||||
|
reset_pw_sign_up.setOnClickListener{
|
||||||
|
resetPassword(reset_pw.text.toString().trim())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun resetPassword(emailAddress: String) {
|
||||||
|
val auth = FirebaseAuth.getInstance()
|
||||||
|
|
||||||
|
auth.sendPasswordResetEmail(emailAddress)
|
||||||
|
.addOnCompleteListener { task ->
|
||||||
|
if (task.isSuccessful) {
|
||||||
|
Log.d(TAG, "Email sent.")
|
||||||
|
|
||||||
|
fragmentManagerLogin.popBackStack()
|
||||||
|
} else {
|
||||||
|
Toast.makeText(context, "Could not reset Password", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin.Login
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.fragment.app.FragmentManager
|
||||||
|
import androidx.fragment.app.FragmentTransaction
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.auth
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.R
|
||||||
|
import com.google.firebase.auth.FirebaseAuth
|
||||||
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
|
class FullscreenActivity : AppCompatActivity() {
|
||||||
|
companion object {
|
||||||
|
lateinit var fragmentManagerLogin : FragmentManager
|
||||||
|
|
||||||
|
fun isPasswordValid(password: String, context:Context): Boolean {
|
||||||
|
var validityScore = 0
|
||||||
|
var str = ""
|
||||||
|
|
||||||
|
if (password.length > 6){
|
||||||
|
validityScore = validityScore + 1
|
||||||
|
}else{
|
||||||
|
str = str + "more than 6 characters, "
|
||||||
|
}
|
||||||
|
|
||||||
|
if (password.toLowerCase() == password){
|
||||||
|
validityScore = validityScore + 1
|
||||||
|
}else{
|
||||||
|
str = str + "uppercase character, "
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Pattern.compile( "[0-9]" ).matcher( password ).find()){
|
||||||
|
validityScore = validityScore + 1
|
||||||
|
}else{
|
||||||
|
str = str + "number"
|
||||||
|
}
|
||||||
|
|
||||||
|
if(validityScore == 3){
|
||||||
|
return true
|
||||||
|
}else{
|
||||||
|
Toast.makeText(context,"Password Requires : $str", Toast.LENGTH_SHORT).show()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.activity_fullscreen)
|
||||||
|
|
||||||
|
auth = FirebaseAuth.getInstance()
|
||||||
|
|
||||||
|
fragmentManagerLogin = supportFragmentManager
|
||||||
|
|
||||||
|
fragmentManagerLogin.beginTransaction().replace(
|
||||||
|
R.id.container,
|
||||||
|
SplashFragment()
|
||||||
|
).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
|
||||||
|
.commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed() {
|
||||||
|
super.onBackPressed()
|
||||||
|
if (fragmentManagerLogin.fragments.size > 1) {
|
||||||
|
fragmentManagerLogin.popBackStack()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin.Login
|
||||||
|
|
||||||
|
import android.animation.Animator
|
||||||
|
import android.animation.AnimatorListenerAdapter
|
||||||
|
import android.annotation.TargetApi
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
|
import android.os.Build
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.text.TextUtils
|
||||||
|
import android.view.KeyEvent
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.view.inputmethod.EditorInfo
|
||||||
|
import android.widget.TextView
|
||||||
|
import android.widget.Toast
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.auth
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Login.FullscreenActivity.Companion.fragmentManagerLogin
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Login.FullscreenActivity.Companion.isPasswordValid
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.MainActivity
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.R
|
||||||
|
import com.google.android.gms.tasks.OnCompleteListener
|
||||||
|
import com.google.firebase.auth.AuthResult
|
||||||
|
import com.google.firebase.auth.FirebaseAuth
|
||||||
|
import kotlinx.android.synthetic.main.fragment_login.*
|
||||||
|
|
||||||
|
|
||||||
|
class LoginFragment : Fragment() {
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
return inflater.inflate(R.layout.fragment_login, container, false)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
|
super.onActivityCreated(savedInstanceState)
|
||||||
|
|
||||||
|
password.setOnEditorActionListener(TextView.OnEditorActionListener { textView, id, keyEvent ->
|
||||||
|
if (id == EditorInfo.IME_ACTION_DONE || id == EditorInfo.IME_NULL) {
|
||||||
|
attemptLogin()
|
||||||
|
return@OnEditorActionListener true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
})
|
||||||
|
|
||||||
|
forgot.setOnClickListener{
|
||||||
|
fragmentManagerLogin.beginTransaction()
|
||||||
|
.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_in)
|
||||||
|
.replace(R.id.container, ForgotPassword())
|
||||||
|
.addToBackStack("forgot_pw").commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
register_button.setOnClickListener {
|
||||||
|
fragmentManagerLogin.beginTransaction()
|
||||||
|
.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_in)
|
||||||
|
.replace(R.id.container, Register())
|
||||||
|
.addToBackStack("register")
|
||||||
|
.commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
email_sign_in_button.setOnClickListener{
|
||||||
|
attemptLogin()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun attemptLogin() {
|
||||||
|
|
||||||
|
// Reset errors.
|
||||||
|
email.setError(null)
|
||||||
|
password.setError(null)
|
||||||
|
|
||||||
|
// Store values at the time of the login attempt.
|
||||||
|
var cancel = false
|
||||||
|
var focusView: View? = null
|
||||||
|
|
||||||
|
// Check for a valid password, if the user entered one.
|
||||||
|
// if (!TextUtils.isEmpty(password.text)) {
|
||||||
|
// password.setError(getString(R.string.error_invalid_password))
|
||||||
|
// focusView = password
|
||||||
|
// cancel = true
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Check for a valid email address.
|
||||||
|
// if (!isPasswordValid(email.text.toString(), context!!)) {
|
||||||
|
// email.setError(getString(R.string.error_field_required))
|
||||||
|
// focusView = email
|
||||||
|
// cancel = true
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (cancel) {
|
||||||
|
// There was an error; don't attempt login and focus the first
|
||||||
|
// form field with an error.
|
||||||
|
focusView!!.requestFocus()
|
||||||
|
} else {
|
||||||
|
// Show a progress spinner, and kick off a background task to
|
||||||
|
// perform the user login attempt.
|
||||||
|
login_progress.visibility = View.VISIBLE
|
||||||
|
auth.signInWithEmailAndPassword(email.text.toString(), password.text.toString())
|
||||||
|
.addOnCompleteListener{ task ->
|
||||||
|
login_progress.visibility = View.GONE
|
||||||
|
if (task.isSuccessful) {
|
||||||
|
val intent = Intent(context, MainActivity::class.java)
|
||||||
|
startActivity(intent)
|
||||||
|
activity?.finish()
|
||||||
|
} else {
|
||||||
|
Toast.makeText(context, getString(R.string.login_failed), Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin.Login
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.text.TextUtils
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.Toast
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.auth
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Login.FullscreenActivity.Companion.isPasswordValid
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.MainActivity
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.R
|
||||||
|
import kotlinx.android.synthetic.main.fragment_login.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_register.*
|
||||||
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
|
|
||||||
|
class Register : Fragment() {
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
return inflater.inflate(R.layout.fragment_register, container, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
|
super.onActivityCreated(savedInstanceState)
|
||||||
|
|
||||||
|
email_sign_up.setOnClickListener{
|
||||||
|
var cancel = false
|
||||||
|
var focusView: View? = null
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(name_register.text)) {
|
||||||
|
name_register.setError(getString(R.string.error_field_required))
|
||||||
|
focusView = name_register
|
||||||
|
cancel = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(email_register.text)) {
|
||||||
|
email_register.setError(getString(R.string.error_field_required))
|
||||||
|
focusView = email
|
||||||
|
cancel = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(password_top.text)) {
|
||||||
|
password_top.setError(getString(R.string.error_field_required))
|
||||||
|
focusView = password_top
|
||||||
|
cancel = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(password_bottom.text)) {
|
||||||
|
password_bottom.setError(getString(R.string.error_field_required))
|
||||||
|
focusView = password_bottom
|
||||||
|
cancel = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!TextUtils.isEmpty(password_top.text) && !isPasswordValid(password_top.text.toString(), this.context!!)) {
|
||||||
|
password_top.setError(getString(R.string.error_invalid_password))
|
||||||
|
focusView = password_top
|
||||||
|
cancel = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (password_top.text != password_bottom.text) {
|
||||||
|
password_bottom.setError(getString(R.string.no_match_password))
|
||||||
|
focusView = password_bottom
|
||||||
|
cancel = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cancel) {
|
||||||
|
// There was an error; don't attempt login and focus the first
|
||||||
|
// form field with an error.
|
||||||
|
focusView!!.requestFocus()
|
||||||
|
} else {
|
||||||
|
pb.visibility = View.VISIBLE
|
||||||
|
//create user
|
||||||
|
auth.createUserWithEmailAndPassword(email.text.toString(), password_top.text.toString())
|
||||||
|
.addOnCompleteListener{task ->
|
||||||
|
pb.visibility = View.GONE
|
||||||
|
if (!task.isSuccessful) {
|
||||||
|
Toast.makeText(context, "Authentication failed." + task.exception!!,
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
} else {
|
||||||
|
val intent = Intent(context, MainActivity::class.java)
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||||
|
startActivity(intent)
|
||||||
|
activity?.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin.Login
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.os.Handler
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.auth
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Login.FullscreenActivity.Companion.fragmentManagerLogin
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.MainActivity
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.R
|
||||||
|
|
||||||
|
|
||||||
|
class SplashFragment : Fragment() {
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
return inflater.inflate(R.layout.fragment_blank, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
|
super.onActivityCreated(savedInstanceState)
|
||||||
|
|
||||||
|
val handler = Handler()
|
||||||
|
handler.postDelayed({
|
||||||
|
//check if logged in
|
||||||
|
val user = auth.getCurrentUser()
|
||||||
|
|
||||||
|
if (user == null) {
|
||||||
|
|
||||||
|
fragmentManagerLogin
|
||||||
|
.beginTransaction()
|
||||||
|
.replace(R.id.container, LoginFragment())
|
||||||
|
.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)
|
||||||
|
.commit()
|
||||||
|
|
||||||
|
} else {
|
||||||
|
val intent = Intent(context, MainActivity::class.java)
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||||
|
startActivity(intent)
|
||||||
|
activity!!.finish()
|
||||||
|
}
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,193 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.ProgressBar
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.appcompat.app.ActionBarDrawerToggle
|
||||||
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
|
import androidx.fragment.app.FragmentManager
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.view.GravityCompat
|
||||||
|
import androidx.drawerlayout.widget.DrawerLayout
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.SHIFT_FIREBASE
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.USER_FIREBASE
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.auth
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.FirebaseClass.Companion.mDatabase
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Login.FullscreenActivity
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Objects.AbnObject
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Objects.ShiftObject
|
||||||
|
import com.google.android.material.navigation.NavigationView
|
||||||
|
import com.google.firebase.database.DataSnapshot
|
||||||
|
import com.google.firebase.database.DatabaseError
|
||||||
|
import com.google.firebase.database.ValueEventListener
|
||||||
|
import com.squareup.picasso.Picasso
|
||||||
|
import kotlinx.android.synthetic.main.activity_drawer_main.*
|
||||||
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
|
import kotlinx.android.synthetic.main.nav_header_main.view.*
|
||||||
|
|
||||||
|
class MainActivity : AppCompatActivity() {
|
||||||
|
companion object{
|
||||||
|
var shiftList = ArrayList<ShiftObject>()
|
||||||
|
}
|
||||||
|
|
||||||
|
lateinit var fragmentManager: FragmentManager
|
||||||
|
lateinit var progBar: ProgressBar
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.activity_drawer_main)
|
||||||
|
//initialising views as val
|
||||||
|
|
||||||
|
val toolBar: androidx.appcompat.widget.Toolbar = toolbar
|
||||||
|
progBar = progressBar2
|
||||||
|
|
||||||
|
//setup backstack change listener
|
||||||
|
fragmentManager = supportFragmentManager
|
||||||
|
fragmentManager.addOnBackStackChangedListener(backStackChangedListener)
|
||||||
|
|
||||||
|
//set toolbar
|
||||||
|
setSupportActionBar(toolBar)
|
||||||
|
|
||||||
|
//setup fab
|
||||||
|
fab.setOnClickListener{
|
||||||
|
val intent = Intent(this, AddShiftActivity::class.java)
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
|
||||||
|
//setup drawer layout
|
||||||
|
val drawer: DrawerLayout = drawer_layout
|
||||||
|
val toggle = ActionBarDrawerToggle(this,drawer,toolBar,R.string.navigation_drawer_open, R.string.navigation_drawer_close)
|
||||||
|
drawer.addDrawerListener(toggle)
|
||||||
|
toggle.syncState()
|
||||||
|
|
||||||
|
//setup naviation view
|
||||||
|
val navigationView: NavigationView = nav_view
|
||||||
|
navigationView.setNavigationItemSelectedListener { menuItem ->
|
||||||
|
|
||||||
|
menuItem.itemId.let { id ->
|
||||||
|
if (id == R.id.nav_camera){
|
||||||
|
val intent = Intent(this,ChangeUserDetailsActivity::class.java)
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
drawer.closeDrawer(GravityCompat.START)
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
//Setup drawer
|
||||||
|
SetupDrawer(navigationView)
|
||||||
|
|
||||||
|
//initialise data for fragments
|
||||||
|
initiateFragment()
|
||||||
|
}
|
||||||
|
|
||||||
|
private val onNavigationItemSelectedListener = BottomNavigationView.OnNavigationItemSelectedListener { item ->
|
||||||
|
when (item.itemId) {
|
||||||
|
R.id.navigation_home -> {
|
||||||
|
fragmentManager.beginTransaction().replace(R.id.container,HomeFragment()).commit()
|
||||||
|
return@OnNavigationItemSelectedListener true
|
||||||
|
}
|
||||||
|
R.id.navigation_list -> {
|
||||||
|
fragmentManager.beginTransaction().replace(R.id.container,FragmentList()).commit()
|
||||||
|
return@OnNavigationItemSelectedListener true
|
||||||
|
}
|
||||||
|
R.id.navigation_tools -> {
|
||||||
|
fragmentManager.beginTransaction().replace(R.id.container,FragmentTools()).commit()
|
||||||
|
return@OnNavigationItemSelectedListener true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
private val backStackChangedListener = FragmentManager.OnBackStackChangedListener {
|
||||||
|
fragmentManager.fragments.get(0).javaClass.simpleName.let {fragmentName ->
|
||||||
|
lateinit var name:String
|
||||||
|
|
||||||
|
when (fragmentName){
|
||||||
|
"HomeFragment" -> {
|
||||||
|
name = "Home"
|
||||||
|
}
|
||||||
|
"ListFragment" -> {
|
||||||
|
name = "List"
|
||||||
|
}
|
||||||
|
"ToolsFragment" -> {
|
||||||
|
name = "Tools"
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
name = getString(R.string.app_name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setTitle(name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setTitle(title: CharSequence?) {
|
||||||
|
toolbar.setTitle(title)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun SetupDrawer(navigationView: NavigationView){
|
||||||
|
val header: View = navigationView.getHeaderView(0)
|
||||||
|
|
||||||
|
checkNotNull(auth).currentUser.let { user ->
|
||||||
|
checkNotNull(user?.email).let {email ->
|
||||||
|
header.driver_email.setText(email)
|
||||||
|
}
|
||||||
|
checkNotNull(user?.displayName).let {name ->
|
||||||
|
header.driver_name.setText(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
Picasso.get().load(user?.photoUrl).placeholder(R.mipmap.ic_launcher_round)
|
||||||
|
.into(header.profileImage)
|
||||||
|
}
|
||||||
|
|
||||||
|
logout.setOnClickListener{
|
||||||
|
auth.signOut()
|
||||||
|
val intent = Intent(this, FullscreenActivity::class.java)
|
||||||
|
startActivity(intent)
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun initiateFragment(){
|
||||||
|
val uid = auth.uid as String
|
||||||
|
progBar.visibility = View.VISIBLE
|
||||||
|
|
||||||
|
mDatabase.child(USER_FIREBASE).child(uid).child(SHIFT_FIREBASE).addValueEventListener(object : ValueEventListener {
|
||||||
|
override fun onCancelled(p0: DatabaseError) {
|
||||||
|
progBar.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDataChange(p0: DataSnapshot) {
|
||||||
|
progBar.visibility = View.GONE
|
||||||
|
|
||||||
|
if(shiftList.isNotEmpty()){
|
||||||
|
shiftList.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
for(postSnapshot in p0.children){
|
||||||
|
shiftList.add(postSnapshot.getValue(ShiftObject::class.java)!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.i("firebase", "shiftlist count = " + shiftList.size)
|
||||||
|
|
||||||
|
if (shiftList.size > 0){
|
||||||
|
//apply navigation listener on bottom bar navigation view
|
||||||
|
navigation.setOnNavigationItemSelectedListener(onNavigationItemSelectedListener)
|
||||||
|
//add first fragment
|
||||||
|
fragmentManager.beginTransaction().replace(R.id.container,HomeFragment()).commit()
|
||||||
|
navigation.setSelectedItemId(R.id.navigation_home)
|
||||||
|
}else{
|
||||||
|
Toast.makeText(getBaseContext() , "Cannot load data", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin.Objects
|
||||||
|
|
||||||
|
data class AbnObject(
|
||||||
|
var abn: String? = "",
|
||||||
|
var companyName: String? = "",
|
||||||
|
var postCode: Int = 0,
|
||||||
|
var state: String? = ""
|
||||||
|
)
|
||||||
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin.Objects
|
||||||
|
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
|
data class ShiftObject(
|
||||||
|
var shiftDate: String = "",
|
||||||
|
var dateTimeAdded: String = "",
|
||||||
|
var abnObject: AbnObject? = AbnObject(),
|
||||||
|
var taskObject: TaskObject? = TaskObject(),
|
||||||
|
var unitsCount: Float? = 0f,
|
||||||
|
var timeObject: TimeObject? = TimeObject()
|
||||||
|
)
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin.Objects
|
||||||
|
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
|
data class TaskObject (
|
||||||
|
var workType: String? = "",
|
||||||
|
var rate: Float = 0.toFloat(),
|
||||||
|
var task: String? = ""
|
||||||
|
) : Serializable
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin.Objects
|
||||||
|
|
||||||
|
data class TimeObject(
|
||||||
|
var timeIn: String? = null,
|
||||||
|
var timeOut: String? = null,
|
||||||
|
var breakEpoch: Int = 0,
|
||||||
|
var hours: Float = 0f
|
||||||
|
)
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.widget.ProgressBar
|
||||||
|
import com.google.firebase.database.DataSnapshot
|
||||||
|
import com.google.firebase.database.DatabaseError
|
||||||
|
import com.google.firebase.database.ValueEventListener
|
||||||
|
|
||||||
|
class PreviouslyUsedItemsClass(progressBar: ProgressBar, activity: Activity) : ValueEventListener {
|
||||||
|
|
||||||
|
override fun onCancelled(p0: DatabaseError) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDataChange(p0: DataSnapshot) {
|
||||||
|
p0.key
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,289 @@
|
|||||||
|
package com.appttude.h_mal.days_left_kotlin
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Build
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.view.ViewTreeObserver
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.appttude.h_mal.days_left_kotlin.Objects.ShiftObject
|
||||||
|
import java.util.HashSet
|
||||||
|
|
||||||
|
class RecAdapter(val context: Context, val shiftList : List<ShiftObject>) : RecyclerView.Adapter<RecyclerView.ViewHolder>(){
|
||||||
|
|
||||||
|
var uniqueEntries: Int = 0
|
||||||
|
var typeCount: IntArray
|
||||||
|
|
||||||
|
init {
|
||||||
|
uniqueEntries = countDistinct()
|
||||||
|
typeCount = countShiftType()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||||
|
when (viewType) {
|
||||||
|
1 -> {
|
||||||
|
val itemOne = LayoutInflater.from(context).inflate(R.layout.item_one, parent, false)
|
||||||
|
return ItemOne(itemOne)
|
||||||
|
}
|
||||||
|
2 -> {
|
||||||
|
val itemTwo = LayoutInflater.from(context).inflate(R.layout.item_two, parent, false)
|
||||||
|
return ItemTwo(itemTwo)
|
||||||
|
}
|
||||||
|
3 -> {
|
||||||
|
val itemThree =
|
||||||
|
LayoutInflater.from(context).inflate(R.layout.item_three, parent, false)
|
||||||
|
return ItemThree(itemThree)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
val itemThree =
|
||||||
|
LayoutInflater.from(context).inflate(R.layout.item_three, parent, false)
|
||||||
|
return ItemThree(itemThree)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount(): Int {
|
||||||
|
return 5
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||||
|
when (holder.itemViewType) {
|
||||||
|
1 -> {
|
||||||
|
val viewHolderCurrent = holder as ItemOne
|
||||||
|
|
||||||
|
val arcView = viewHolderCurrent.arc
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
arcView.setPaintColor(context.getColor(R.color.two))
|
||||||
|
}
|
||||||
|
|
||||||
|
val days = uniqueEntries
|
||||||
|
|
||||||
|
val complete = 360 * days / 88
|
||||||
|
|
||||||
|
viewHolderCurrent.days.text = days.toString()
|
||||||
|
|
||||||
|
val animation = ArcAnimation(arcView, complete.toFloat())
|
||||||
|
animation.setDuration(600)
|
||||||
|
arcView.startAnimation(animation)
|
||||||
|
}
|
||||||
|
2 -> {
|
||||||
|
val viewTwo = holder as ItemTwo
|
||||||
|
|
||||||
|
val barView = viewTwo.barView
|
||||||
|
val linearLayout = viewTwo.linearLayout
|
||||||
|
|
||||||
|
val cover = typeCount[1].toFloat() / shiftList.size
|
||||||
|
|
||||||
|
barView.setCover(cover)
|
||||||
|
|
||||||
|
barView.setColourOne(context.getColor(R.color.four))
|
||||||
|
barView.setColourTwo(context.getColor(R.color.three))
|
||||||
|
|
||||||
|
viewTwo.pcText.text = typeCount[1].toString()
|
||||||
|
viewTwo.hrText.text = typeCount[0].toString()
|
||||||
|
|
||||||
|
// viewTwo.textholder.setPadding(60,0,60,0);
|
||||||
|
// viewTwo.bottomTextholder.setPadding(60,0,60,0);
|
||||||
|
|
||||||
|
linearLayout.viewTreeObserver.addOnGlobalLayoutListener(object :
|
||||||
|
ViewTreeObserver.OnGlobalLayoutListener {
|
||||||
|
override fun onGlobalLayout() {
|
||||||
|
|
||||||
|
val barAnimation = BarAnimation(barView, linearLayout.width, 0)
|
||||||
|
barAnimation.setDuration(600)
|
||||||
|
barView.setAnimation(barAnimation)
|
||||||
|
linearLayout.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
3 -> {
|
||||||
|
val viewCounting = holder as ItemThree
|
||||||
|
|
||||||
|
val cardTitle = viewCounting.cardTitle
|
||||||
|
val cardIcon = viewCounting.cardIcon
|
||||||
|
val units = viewCounting.units
|
||||||
|
val totalEarned = viewCounting.totalEarned
|
||||||
|
val top = viewCounting.textholderTop
|
||||||
|
val bottom = viewCounting.textholderBottom
|
||||||
|
|
||||||
|
// top.setPadding(60,0,60,0);
|
||||||
|
// bottom.setPadding(60,0,60,0);
|
||||||
|
// cardIcon.setPadding(0,0,10,0);
|
||||||
|
|
||||||
|
if (position == 2) {
|
||||||
|
cardTitle.text = "Hourly"
|
||||||
|
cardIcon.setImageResource(R.drawable.clock_icon)
|
||||||
|
val hours = String.format("%.2f", calculateHours())
|
||||||
|
units.text = "$hours Hours"
|
||||||
|
|
||||||
|
val total = String.format("%.2f", calculateAccumulatedPay(0))
|
||||||
|
totalEarned.text = "$$total"
|
||||||
|
}
|
||||||
|
if (position == 3) {
|
||||||
|
cardTitle.text = "Piece"
|
||||||
|
cardTitle.setTextColor(context.resources.getColor(R.color.three))
|
||||||
|
cardIcon.setImageResource(R.drawable.piece)
|
||||||
|
cardIcon.rotation = 270f
|
||||||
|
val pieces = String.format("%.2f", calculateUnits())
|
||||||
|
units.text = "$pieces Units"
|
||||||
|
val total = String.format("%.2f", calculateAccumulatedPay(1))
|
||||||
|
totalEarned.text = "$$total"
|
||||||
|
}
|
||||||
|
if (position == 4) {
|
||||||
|
cardTitle.visibility = View.GONE
|
||||||
|
cardIcon.visibility = View.GONE
|
||||||
|
|
||||||
|
val total = String.format("%.2f", calculateAccumulatedPay(3))
|
||||||
|
totalEarned.text = "$$total"
|
||||||
|
|
||||||
|
viewCounting.textholderTop.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemViewType(position: Int): Int {
|
||||||
|
when (position) {
|
||||||
|
0 -> return 1
|
||||||
|
1 -> return 2
|
||||||
|
2 -> return 3
|
||||||
|
3 -> return 3
|
||||||
|
4 -> return 3
|
||||||
|
else -> {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal inner class ItemOne(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||||
|
|
||||||
|
var arc: CircleView
|
||||||
|
var days: TextView
|
||||||
|
|
||||||
|
init {
|
||||||
|
arc = itemView.findViewById<View>(R.id.arc_view) as CircleView
|
||||||
|
days = itemView.findViewById(R.id.days_completed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal inner class ItemTwo (itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||||
|
|
||||||
|
var barView: BarView
|
||||||
|
var linearLayout: LinearLayout
|
||||||
|
var pcText: TextView
|
||||||
|
var hrText: TextView
|
||||||
|
|
||||||
|
init {
|
||||||
|
barView = itemView.findViewById(R.id.bar) as BarView
|
||||||
|
linearLayout = itemView.findViewById(R.id.lin)
|
||||||
|
pcText = itemView.findViewById(R.id.pc_amount_text)
|
||||||
|
hrText = itemView.findViewById(R.id.hr_amount_text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal inner class ItemThree(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||||
|
|
||||||
|
val cardTitle: TextView
|
||||||
|
val cardIcon: ImageView
|
||||||
|
val units: TextView
|
||||||
|
val totalEarned: TextView
|
||||||
|
val textholderTop: LinearLayout
|
||||||
|
val textholderBottom: LinearLayout
|
||||||
|
|
||||||
|
init {
|
||||||
|
cardTitle = itemView.findViewById(R.id.card_title)
|
||||||
|
cardIcon = itemView.findViewById(R.id.card_icon)
|
||||||
|
units = itemView.findViewById(R.id.units)
|
||||||
|
totalEarned = itemView.findViewById(R.id.total_earned)
|
||||||
|
textholderTop = itemView.findViewById(R.id.text_holder)
|
||||||
|
textholderBottom = itemView.findViewById(R.id.text_holder_two)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun calculateHours(): Float {
|
||||||
|
var hours = 0f
|
||||||
|
for (shiftObject in shiftList) {
|
||||||
|
if (shiftObject.taskObject?.workType.equals("Hourly")) {
|
||||||
|
hours = hours + shiftObject.timeObject!!.hours - shiftObject.timeObject!!.breakEpoch
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return hours
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun calculateUnits(): Float {
|
||||||
|
var units = 0f
|
||||||
|
for (shiftObject in shiftList) {
|
||||||
|
if (shiftObject.taskObject?.workType.equals("Piece Rate")) {
|
||||||
|
units += + shiftObject.unitsCount!!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return units
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun calculateAccumulatedPay(type: Int): Float {
|
||||||
|
var pay = 0f
|
||||||
|
|
||||||
|
for (shiftObject in shiftList) {
|
||||||
|
when (type){
|
||||||
|
0 -> {
|
||||||
|
if (shiftObject.taskObject?.workType == "Hourly") {
|
||||||
|
pay += shiftObject.taskObject?.rate?.times((shiftObject.timeObject!!.hours - shiftObject.timeObject!!.breakEpoch))
|
||||||
|
?: pay
|
||||||
|
}
|
||||||
|
}
|
||||||
|
1 -> {
|
||||||
|
if (shiftObject.taskObject?.workType == "Piece Rate") {
|
||||||
|
pay += shiftObject.taskObject?.rate?.times(shiftObject.unitsCount!!) ?: pay
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
if (shiftObject.taskObject?.workType == "Hourly") {
|
||||||
|
pay += shiftObject.taskObject?.rate?.times((shiftObject.timeObject!!.hours - shiftObject.timeObject!!.breakEpoch))
|
||||||
|
?: pay
|
||||||
|
} else {
|
||||||
|
pay += shiftObject.taskObject?.rate?.times(shiftObject.unitsCount!!) ?: pay
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return pay
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun countDistinct(): Int {
|
||||||
|
val hs = HashSet<String>()
|
||||||
|
|
||||||
|
for (i in shiftList.indices) {
|
||||||
|
|
||||||
|
hs.add(shiftList.get(i).shiftDate)
|
||||||
|
}
|
||||||
|
|
||||||
|
return hs.size
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun countShiftType(): IntArray {
|
||||||
|
var i = 0
|
||||||
|
var j = 0
|
||||||
|
|
||||||
|
for (shiftObject in shiftList) {
|
||||||
|
if (shiftObject.taskObject?.workType.equals("Hourly")) {
|
||||||
|
i++
|
||||||
|
} else {
|
||||||
|
j++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return intArrayOf(i, j)
|
||||||
|
}
|
||||||
|
}
|
||||||
14
app/src/main/res/anim/activity_open_enter.xml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<rotate
|
||||||
|
android:fromDegrees="90" android:toDegrees="0"
|
||||||
|
android:pivotX="0%" android:pivotY="0%"
|
||||||
|
android:fillEnabled="true"
|
||||||
|
android:fillBefore="true" android:fillAfter="true"
|
||||||
|
android:duration="500" />
|
||||||
|
<alpha
|
||||||
|
android:fromAlpha="0.0" android:toAlpha="1.0"
|
||||||
|
android:fillEnabled="true"
|
||||||
|
android:fillBefore="true" android:fillAfter="true"
|
||||||
|
android:duration="500" />
|
||||||
|
</set>
|
||||||
14
app/src/main/res/anim/activity_open_exit.xml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<rotate
|
||||||
|
android:fromDegrees="0" android:toDegrees="-90"
|
||||||
|
android:pivotX="0%" android:pivotY="0%"
|
||||||
|
android:fillEnabled="true"
|
||||||
|
android:fillBefore="true" android:fillAfter="true"
|
||||||
|
android:duration="500" />
|
||||||
|
<alpha
|
||||||
|
android:fromAlpha="1.0" android:toAlpha="0.0"
|
||||||
|
android:fillEnabled="true"
|
||||||
|
android:fillBefore="true" android:fillAfter="true"
|
||||||
|
android:duration="500" />
|
||||||
|
</set>
|
||||||
4
app/src/main/res/anim/fade_in.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:fromAlpha="0.5" android:toAlpha="1.0"
|
||||||
|
android:duration="200" />
|
||||||
|
After Width: | Height: | Size: 2.6 MiB |
BIN
app/src/main/res/drawable-hdpi/splash.png
Normal file
|
After Width: | Height: | Size: 4.5 MiB |
|
After Width: | Height: | Size: 1.3 MiB |
BIN
app/src/main/res/drawable-mdpi/splash.png
Normal file
|
After Width: | Height: | Size: 2.1 MiB |
7
app/src/main/res/drawable-v24/cardviewoutline.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="@android:color/transparent"/>
|
||||||
|
<stroke android:width="2dip" android:color="#03a9f4" />
|
||||||
|
<corners android:radius="22dip"/>
|
||||||
|
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
|
||||||
|
</shape>
|
||||||
34
app/src/main/res/drawable-v24/ic_launcher_foreground.xml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:aapt="http://schemas.android.com/aapt"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillType="evenOdd"
|
||||||
|
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:strokeColor="#00000000">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
|
<gradient
|
||||||
|
android:endX="78.5885"
|
||||||
|
android:endY="90.9159"
|
||||||
|
android:startX="48.7653"
|
||||||
|
android:startY="61.0927"
|
||||||
|
android:type="linear">
|
||||||
|
<item
|
||||||
|
android:color="#44000000"
|
||||||
|
android:offset="0.0" />
|
||||||
|
<item
|
||||||
|
android:color="#00000000"
|
||||||
|
android:offset="1.0" />
|
||||||
|
</gradient>
|
||||||
|
</aapt:attr>
|
||||||
|
</path>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:fillType="nonZero"
|
||||||
|
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:strokeColor="#00000000" />
|
||||||
|
</vector>
|
||||||
9
app/src/main/res/drawable-v24/side_nav_bar.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<gradient
|
||||||
|
android:angle="135"
|
||||||
|
android:centerColor="@color/one"
|
||||||
|
android:endColor="@color/three"
|
||||||
|
android:startColor="@color/two"
|
||||||
|
android:type="linear" />
|
||||||
|
</shape>
|
||||||
|
After Width: | Height: | Size: 4.9 MiB |
6
app/src/main/res/drawable-xhdpi/search_button.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="@color/two"/>
|
||||||
|
<stroke android:width="1dip" android:color="@color/one" />
|
||||||
|
<corners android:radius="@dimen/rounding_radius"/>
|
||||||
|
</shape>
|
||||||
BIN
app/src/main/res/drawable-xhdpi/splash.png
Normal file
|
After Width: | Height: | Size: 7.2 MiB |
|
After Width: | Height: | Size: 8.3 MiB |
BIN
app/src/main/res/drawable-xxhdpi/splash.png
Normal file
|
After Width: | Height: | Size: 15 MiB |
|
After Width: | Height: | Size: 12 MiB |
BIN
app/src/main/res/drawable-xxxhdpi/splash.png
Normal file
|
After Width: | Height: | Size: 24 MiB |
BIN
app/src/main/res/drawable/box_icon.png
Normal file
|
After Width: | Height: | Size: 861 B |
BIN
app/src/main/res/drawable/break_time.png
Normal file
|
After Width: | Height: | Size: 928 B |
7
app/src/main/res/drawable/cardviewoutline.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="@android:color/transparent"/>
|
||||||
|
<stroke android:width="2dip" android:color="#03a9f4" />
|
||||||
|
<corners android:radius="@dimen/rounding_radius"/>
|
||||||
|
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
|
||||||
|
</shape>
|
||||||
BIN
app/src/main/res/drawable/checkmark.png
Normal file
|
After Width: | Height: | Size: 429 B |
BIN
app/src/main/res/drawable/clock_icon.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
11
app/src/main/res/drawable/gradient_background.xml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle"
|
||||||
|
android:useLevel="false">
|
||||||
|
<gradient
|
||||||
|
android:angle="45"
|
||||||
|
android:centerColor="#dce7f1"
|
||||||
|
android:endColor="#cafdbb"
|
||||||
|
android:startColor="#89b784"
|
||||||
|
android:useLevel="false" />
|
||||||
|
</shape>
|
||||||
9
app/src/main/res/drawable/ic_dashboard_black_24dp.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M3,13h8L11,3L3,3v10zM3,21h8v-6L3,15v6zM13,21h8L21,11h-8v10zM13,3v6h8L21,3h-8z" />
|
||||||
|
</vector>
|
||||||
5
app/src/main/res/drawable/ic_filter_list_black_24dp.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||||
|
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#FF000000" android:pathData="M10,18h4v-2h-4v2zM3,6v2h18L21,6L3,6zM6,13h12v-2L6,11v2z"/>
|
||||||
|
</vector>
|
||||||
9
app/src/main/res/drawable/ic_home_black_24dp.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z" />
|
||||||
|
</vector>
|
||||||
170
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillColor="#008577"
|
||||||
|
android:pathData="M0,0h108v108h-108z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M9,0L9,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,0L19,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,0L29,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,0L39,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,0L49,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,0L59,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,0L69,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,0L79,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M89,0L89,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M99,0L99,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,9L108,9"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,19L108,19"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,29L108,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,39L108,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,49L108,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,59L108,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,69L108,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,79L108,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,89L108,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,99L108,99"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,29L89,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,39L89,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,49L89,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,59L89,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,69L89,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,79L89,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,19L29,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,19L39,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,19L49,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,19L59,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,19L69,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,19L79,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
</vector>
|
||||||
9
app/src/main/res/drawable/ic_list_black_24dp.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M3,13h2v-2L3,11v2zM3,17h2v-2L3,15v2zM3,9h2L5,7L3,7v2zM7,13h14v-2L7,11v2zM7,17h14v-2L7,15v2zM7,7v2h14L21,7L7,7z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.89,2 2,2zM18,16v-5c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2z" />
|
||||||
|
</vector>
|
||||||
9
app/src/main/res/drawable/ic_search_black_24dp.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM19,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.11,0 2,-0.9 2,-2L21,5c0,-1.1 -0.89,-2 -2,-2zM17.25,12c0,0.23 -0.02,0.46 -0.05,0.68l1.48,1.16c0.13,0.11 0.17,0.3 0.08,0.45l-1.4,2.42c-0.09,0.15 -0.27,0.21 -0.43,0.15l-1.74,-0.7c-0.36,0.28 -0.76,0.51 -1.18,0.69l-0.26,1.85c-0.03,0.17 -0.18,0.3 -0.35,0.3h-2.8c-0.17,0 -0.32,-0.13 -0.35,-0.29l-0.26,-1.85c-0.43,-0.18 -0.82,-0.41 -1.18,-0.69l-1.74,0.7c-0.16,0.06 -0.34,0 -0.43,-0.15l-1.4,-2.42c-0.09,-0.15 -0.05,-0.34 0.08,-0.45l1.48,-1.16c-0.03,-0.23 -0.05,-0.46 -0.05,-0.69 0,-0.23 0.02,-0.46 0.05,-0.68l-1.48,-1.16c-0.13,-0.11 -0.17,-0.3 -0.08,-0.45l1.4,-2.42c0.09,-0.15 0.27,-0.21 0.43,-0.15l1.74,0.7c0.36,-0.28 0.76,-0.51 1.18,-0.69l0.26,-1.85c0.03,-0.17 0.18,-0.3 0.35,-0.3h2.8c0.17,0 0.32,0.13 0.35,0.29l0.26,1.85c0.43,0.18 0.82,0.41 1.18,0.69l1.74,-0.7c0.16,-0.06 0.34,0 0.43,0.15l1.4,2.42c0.09,0.15 0.05,0.34 -0.08,0.45l-1.48,1.16c0.03,0.23 0.05,0.46 0.05,0.69z"/>
|
||||||
|
</vector>
|
||||||
5
app/src/main/res/drawable/ic_sort_black_24dp.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||||
|
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#FF000000" android:pathData="M3,18h6v-2L3,16v2zM3,6v2h18L21,6L3,6zM3,13h12v-2L3,11v2z"/>
|
||||||
|
</vector>
|
||||||
BIN
app/src/main/res/drawable/marker.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
app/src/main/res/drawable/piece.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
7
app/src/main/res/drawable/round_edit_text.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle" android:padding="10dp">
|
||||||
|
<solid android:color="@color/two" />
|
||||||
|
<corners
|
||||||
|
android:radius="@dimen/rounding_radius" />
|
||||||
|
</shape>
|
||||||
7
app/src/main/res/drawable/secondcardview.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="@color/one"/>
|
||||||
|
<stroke android:width="2dip" android:color="@color/two" />
|
||||||
|
<corners android:radius="@dimen/rounding_radius"/>
|
||||||
|
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
|
||||||
|
</shape>
|
||||||
6
app/src/main/res/drawable/spash_drawable.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:src="@drawable/splash"
|
||||||
|
android:gravity="center"
|
||||||
|
android:tint="#da000000"
|
||||||
|
android:tintMode="src_over"/>
|
||||||
BIN
app/src/main/res/drawable/task.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
6
app/src/main/res/drawable/yes_button.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="@color/three"/>
|
||||||
|
<stroke android:width="1dip" android:color="@color/four" />
|
||||||
|
<corners android:radius="@dimen/rounding_radius"/>
|
||||||
|
</shape>
|
||||||
92
app/src/main/res/layout/abn_list_item.xml
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:layout_marginTop="6dp"
|
||||||
|
android:layout_marginRight="12dp"
|
||||||
|
android:layout_marginBottom="6dp"
|
||||||
|
app:cardCornerRadius="@dimen/card_radius">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/farm_name"
|
||||||
|
style="@style/title_card"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:textColor="@color/three"
|
||||||
|
tools:text="W and L farms" />
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/text_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/text_major"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="left|center"
|
||||||
|
android:text="ABN : " />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/abn_text"
|
||||||
|
style="@style/text_minor"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="2"
|
||||||
|
tools:text="75642358411" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/text_holder_two"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/text_major"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="left|center"
|
||||||
|
android:text="Postcode : " />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/postcode_text"
|
||||||
|
style="@style/text_minor"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:text="QLD 4670" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
46
app/src/main/res/layout/activity_add_item.xml
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context="com.appttude.h_mal.days_left.MainActivity">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:id="@+id/appbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="@dimen/appbar_padding_top"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
app:layout_scrollFlags="scroll|enterAlways"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||||
|
app:title="@string/app_name">
|
||||||
|
|
||||||
|
</androidx.appcompat.widget.Toolbar>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_below="@id/appbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_above="@id/navigation"
|
||||||
|
android:id="@+id/container"></FrameLayout>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar2"
|
||||||
|
style="?android:attr/progressBarStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
291
app/src/main/res/layout/activity_add_shift.xml
Normal file
@@ -0,0 +1,291 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout 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:orientation="vertical"
|
||||||
|
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
tools:context=".AddItems.AddEmployerFragment">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/progress_bar"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:id="@+id/centre_view">
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:id="@+id/select_employer_card"
|
||||||
|
style="@style/cardview_theme"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="16sp"
|
||||||
|
app:cardBackgroundColor="@color/two">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/employer_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/cardviewoutline"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/employer_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="2dp"
|
||||||
|
android:alpha="0.65"
|
||||||
|
android:textColor="@color/one"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:text="W and L farms" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:alpha="0.56"
|
||||||
|
android:src="@drawable/marker" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/employer_location"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
tools:text="Bundaberg" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/lable_1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:text="Select Employer"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:id="@+id/select_task_card"
|
||||||
|
style="@style/cardview_theme"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="16sp"
|
||||||
|
app:cardBackgroundColor="@color/two">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/task_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/cardviewoutline"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/task"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="2dp"
|
||||||
|
android:alpha="0.65"
|
||||||
|
android:textColor="@color/three"
|
||||||
|
android:textSize="16sp"
|
||||||
|
tools:text="Packing Tomatoes" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:alpha="0.56"
|
||||||
|
android:src="@drawable/task" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/task_summary"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
tools:text="Bundaberg" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/lable_2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:text="Select Task"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:id="@+id/select_times_card"
|
||||||
|
style="@style/cardview_theme"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="16sp"
|
||||||
|
app:cardBackgroundColor="@color/two">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/time_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/cardviewoutline"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/time"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="2dp"
|
||||||
|
android:alpha="0.65"
|
||||||
|
android:textColor="@color/three"
|
||||||
|
android:textSize="16sp"
|
||||||
|
tools:text="11H 30m" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:alpha="0.56"
|
||||||
|
android:src="@drawable/clock_icon" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/time_summary"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
tools:text="11:30 - 18:30" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/break_holder"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="16dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:alpha="0.56"
|
||||||
|
android:src="@drawable/break_time" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/break_summary"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
tools:text="30 minutes" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/lable_3"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:text="insert times"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:visibility="visible" />
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/units"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:background="@drawable/round_edit_text"
|
||||||
|
android:hint="Insert units/time"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:textColorHighlight="#608d91" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/date"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/round_edit_text"
|
||||||
|
android:hint="Select date"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
|
android:focusable="false"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:textColorHighlight="#608d91" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/search_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:background="@drawable/yes_button"
|
||||||
|
android:paddingLeft="15dp"
|
||||||
|
android:paddingRight="15dp"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:src="@drawable/checkmark"
|
||||||
|
android:tint="#2b452d" />
|
||||||
|
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
82
app/src/main/res/layout/activity_change_user_details.xml
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout 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:orientation="vertical"
|
||||||
|
tools:context=".Login.ChangeUserDetailsActivity">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/ph_view_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:layout_centerInParent="true">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/change_profile_name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
|
android:background="@drawable/round_edit_text"
|
||||||
|
android:ems="10"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="Change Profile Name"
|
||||||
|
android:textColorHighlight="#608d91" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/change_email"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
|
android:background="@drawable/round_edit_text"
|
||||||
|
android:ems="10"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="Change Email Address"
|
||||||
|
android:textColorHighlight="#608d91" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/change_pw"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
|
android:background="@drawable/round_edit_text"
|
||||||
|
android:ems="10"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="Change Password"
|
||||||
|
android:textColorHighlight="#608d91" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/submit_profile"
|
||||||
|
style="?android:attr/borderlessButtonStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:layout_marginEnd="12dp"
|
||||||
|
android:layout_marginRight="12dp"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
|
android:background="@drawable/cardviewoutline"
|
||||||
|
android:text="@string/submit"
|
||||||
|
android:textColor="@android:color/black"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
43
app/src/main/res/layout/activity_drawer_main.xml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.drawerlayout.widget.DrawerLayout 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:id="@+id/drawer_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
tools:openDrawer="start">
|
||||||
|
|
||||||
|
<include
|
||||||
|
layout="@layout/activity_main"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<com.google.android.material.navigation.NavigationView
|
||||||
|
android:id="@+id/nav_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
app:headerLayout="@layout/nav_header_main"
|
||||||
|
app:menu="@menu/activity_main_drawer" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:clickable="true"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/logout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Logout"
|
||||||
|
android:textColor="@color/colorPrimary"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
</com.google.android.material.navigation.NavigationView>
|
||||||
|
|
||||||
|
</androidx.drawerlayout.widget.DrawerLayout>
|
||||||
14
app/src/main/res/layout/activity_fullscreen.xml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout 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="com.appttude.h_mal.days_left.Login.FullscreenActivity">
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/container">
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
78
app/src/main/res/layout/activity_login.xml
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?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:id="@+id/container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
tools:context=".Login.ui.login.LoginActivity">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/username"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="24dp"
|
||||||
|
android:layout_marginTop="96dp"
|
||||||
|
android:layout_marginEnd="24dp"
|
||||||
|
|
||||||
|
android:hint="@string/prompt_email"
|
||||||
|
android:inputType="textEmailAddress"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/password"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="24dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginEnd="24dp"
|
||||||
|
|
||||||
|
android:hint="@string/prompt_password"
|
||||||
|
android:imeActionLabel="@string/action_sign_in_short"
|
||||||
|
android:imeOptions="actionDone"
|
||||||
|
android:inputType="textPassword"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/username" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/login"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:layout_marginStart="48dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginEnd="48dp"
|
||||||
|
android:layout_marginBottom="64dp"
|
||||||
|
android:enabled="false"
|
||||||
|
android:text="@string/action_sign_in"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/password"
|
||||||
|
app:layout_constraintVertical_bias="0.2" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/loading"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginStart="32dp"
|
||||||
|
android:layout_marginTop="64dp"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
android:layout_marginBottom="64dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="@+id/password"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/password"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0.3" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
63
app/src/main/res/layout/activity_main.xml
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context="com.appttude.h_mal.days_left_kotlin.MainActivity">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:id="@+id/appbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="@dimen/appbar_padding_top"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
app:layout_scrollFlags="scroll|enterAlways"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||||
|
app:title="@string/app_name">
|
||||||
|
|
||||||
|
</androidx.appcompat.widget.Toolbar>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_below="@id/appbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_above="@id/navigation"
|
||||||
|
android:id="@+id/container">
|
||||||
|
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/fab"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_margin="@dimen/fab_margin"
|
||||||
|
android:src="@android:drawable/ic_input_add"
|
||||||
|
android:tint="@android:color/white" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar2"
|
||||||
|
style="?android:attr/progressBarStyle"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
|
android:id="@+id/navigation"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:background="?android:attr/windowBackground"
|
||||||
|
app:menu="@menu/navigation" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
49
app/src/main/res/layout/date_selector_dialog.xml
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout 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="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/button_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/from_date"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="@android:dimen/app_icon_size"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:tag="from"
|
||||||
|
android:text="From" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/to_date"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="@android:dimen/app_icon_size"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:tag="to"
|
||||||
|
android:text="To" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<DatePicker
|
||||||
|
android:id="@+id/date_picker"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:headerBackground="@color/colorPrimaryDark"
|
||||||
|
android:numbersSelectorColor="@color/colorPrimary">
|
||||||
|
|
||||||
|
</DatePicker>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
109
app/src/main/res/layout/dialog_add_employer.xml
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout 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:orientation="vertical"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
tools:context=".AddItems.AddEmployerFragment">
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:id="@+id/Search"
|
||||||
|
style="@style/cardview_theme"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="16sp">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignBottom="@id/title"
|
||||||
|
android:background="@drawable/cardviewoutline" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:text="Search via Name/ABN"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:id="@+id/idk"
|
||||||
|
style="@style/cardview_theme"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:cardBackgroundColor="@color/two">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/cardviewoutline"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="2dp"
|
||||||
|
android:alpha="0.65"
|
||||||
|
android:textColor="@color/three"
|
||||||
|
android:textSize="16sp"
|
||||||
|
tools:text="Packing Tomatoes" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:alpha="0.56"
|
||||||
|
android:src="@drawable/task" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
tools:text="Bundaberg" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:text="I dont know yet"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
92
app/src/main/res/layout/dialog_add_times.xml
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout 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:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/button_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/from_date"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="@android:dimen/app_icon_size"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Start" />
|
||||||
|
|
||||||
|
<!--<ImageView-->
|
||||||
|
<!--android:layout_width="1dp"-->
|
||||||
|
<!--android:background="#8aa4bf"-->
|
||||||
|
<!--android:layout_height="match_parent"-->
|
||||||
|
<!--android:layout_margin="4dp"/>-->
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/to_date"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="@android:dimen/app_icon_size"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Finish" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TimePicker
|
||||||
|
android:id="@+id/time_picker"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:headerBackground="@color/colorPrimaryDark"
|
||||||
|
android:numbersSelectorColor="@color/colorPrimary">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="right|bottom">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Break (in minutes) : " />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/breaktime"
|
||||||
|
android:layout_width="60dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:maxLength="3"
|
||||||
|
android:inputType="number" />
|
||||||
|
</LinearLayout>
|
||||||
|
</TimePicker>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/end"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="@android:dimen/app_icon_size"
|
||||||
|
android:layout_weight="2" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/ok"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="@android:dimen/app_icon_size"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="OK"
|
||||||
|
android:textColor="@color/colorPrimaryDark"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
24
app/src/main/res/layout/dialog_previous_abns_used.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/list_item_list_dialog"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_above="@+id/button_list_dialog">
|
||||||
|
|
||||||
|
</ListView>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button_list_dialog"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:text="+"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
33
app/src/main/res/layout/dialog_search_employer.xml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout 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:orientation="vertical"
|
||||||
|
tools:context=".AddItems.AddEmployerFragment">
|
||||||
|
|
||||||
|
<com.google.android.material.tabs.TabLayout
|
||||||
|
android:id="@+id/tab_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<com.google.android.material.tabs.TabItem
|
||||||
|
android:id="@+id/abn"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="A.B.N" />
|
||||||
|
|
||||||
|
<com.google.android.material.tabs.TabItem
|
||||||
|
android:id="@+id/name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Name" />
|
||||||
|
</com.google.android.material.tabs.TabLayout>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/search_edittext"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
29
app/src/main/res/layout/dialog_search_layout.xml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/progress_bar"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/search_listview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
<Button
|
||||||
|
android:id="@+id/add_new_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/search_button" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
67
app/src/main/res/layout/fragment_add_employer.xml
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout 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:orientation="vertical"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
tools:context="AddEmployerFragment">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/spinning_pb"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/empty_list"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/marker" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/empty_line_one"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/empty_line_two"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/search_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_above="@id/search_button"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/list_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
|
</ListView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
121
app/src/main/res/layout/fragment_add_task.xml
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout 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:orientation="vertical"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
tools:context="AddTaskFragment">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:id="@+id/centre_view">
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:id="@+id/card_one"
|
||||||
|
style="@style/cardview_theme"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="16sp"
|
||||||
|
app:cardBackgroundColor="@color/two">
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/spinner_one"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:popupBackground="@color/two"
|
||||||
|
tools:listitem="@android:layout/test_list_item">
|
||||||
|
|
||||||
|
</Spinner>
|
||||||
|
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:id="@+id/card_two"
|
||||||
|
style="@style/cardview_theme"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="16sp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
|
android:text="$" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/pay_rate"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
|
android:hint="Insert Pay Rate"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingBottom="12dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/unit_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
tools:text="per hour" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:id="@+id/card_three"
|
||||||
|
style="@style/cardview_theme"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:cardBackgroundColor="@color/two">
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/spinner_Two"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:popupBackground="@color/two"
|
||||||
|
tools:listitem="@android:layout/test_list_item">
|
||||||
|
|
||||||
|
</Spinner>
|
||||||
|
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/search_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:background="@drawable/yes_button"
|
||||||
|
android:paddingLeft="15dp"
|
||||||
|
android:paddingRight="15dp"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:src="@drawable/checkmark"
|
||||||
|
android:tint="#2b452d" />
|
||||||
|
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||