mirror of
https://github.com/hmalik144/DaysLeft.git
synced 2025-12-10 03:05:29 +00:00
## Migrated to kotlin
# migrated to androidx - update to mvvm - creation of viewmodels and factories - dependency injection with kodein - app class created with modules - creation of firebase/live data class (put out fires from migration)
This commit is contained in:
BIN
.idea/caches/gradle_models.ser
generated
BIN
.idea/caches/gradle_models.ser
generated
Binary file not shown.
122
.idea/codeStyles/Project.xml
generated
Normal file
122
.idea/codeStyles/Project.xml
generated
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<code_scheme name="Project" version="173">
|
||||||
|
<JetCodeStyleSettings>
|
||||||
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
|
</JetCodeStyleSettings>
|
||||||
|
<codeStyleSettings language="XML">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
</indentOptions>
|
||||||
|
<arrangement>
|
||||||
|
<rules>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>xmlns:android</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>xmlns:.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:id</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:name</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>name</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>style</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<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_ATTRIBUTE />
|
||||||
|
<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
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>
|
||||||
5
.idea/gradle.xml
generated
5
.idea/gradle.xml
generated
@@ -1,11 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<compositeConfiguration>
|
<option name="testRunner" value="PLATFORM" />
|
||||||
<compositeBuild compositeDefinitionSource="SCRIPT" />
|
|
||||||
</compositeConfiguration>
|
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
|
|||||||
35
.idea/jarRepositories.xml
generated
Normal file
35
.idea/jarRepositories.xml
generated
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="BintrayJCenter" />
|
||||||
|
<option name="name" value="BintrayJCenter" />
|
||||||
|
<option name="url" value="https://jcenter.bintray.com/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven" />
|
||||||
|
<option name="name" value="maven" />
|
||||||
|
<option name="url" value="https://jitpack.io" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="Google" />
|
||||||
|
<option name="name" value="Google" />
|
||||||
|
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="MavenRepo" />
|
||||||
|
<option name="name" value="MavenRepo" />
|
||||||
|
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
10
.idea/misc.xml
generated
10
.idea/misc.xml
generated
@@ -5,7 +5,7 @@
|
|||||||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
||||||
<option name="myNullables">
|
<option name="myNullables">
|
||||||
<value>
|
<value>
|
||||||
<list size="10">
|
<list size="12">
|
||||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||||
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
||||||
@@ -16,12 +16,14 @@
|
|||||||
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
|
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
|
||||||
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
|
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
|
||||||
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
|
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
|
||||||
|
<item index="10" class="java.lang.String" itemvalue="android.annotation.Nullable" />
|
||||||
|
<item index="11" class="java.lang.String" itemvalue="com.android.annotations.Nullable" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
<option name="myNotNulls">
|
<option name="myNotNulls">
|
||||||
<value>
|
<value>
|
||||||
<list size="9">
|
<list size="11">
|
||||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||||
@@ -31,11 +33,13 @@
|
|||||||
<item index="6" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
|
<item index="6" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
|
||||||
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
|
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
|
||||||
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
|
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
|
||||||
|
<item index="9" class="java.lang.String" itemvalue="android.annotation.NonNull" />
|
||||||
|
<item index="10" class="java.lang.String" itemvalue="com.android.annotations.NonNull" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<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" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|||||||
@@ -1,14 +1,24 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
apply plugin: 'kotlin-android-extensions'
|
||||||
|
|
||||||
|
// kotlin kapt
|
||||||
|
apply plugin: 'kotlin-kapt'
|
||||||
|
|
||||||
|
// google services
|
||||||
|
apply plugin: 'com.google.gms.google-services'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 29
|
||||||
|
buildToolsVersion "29.0.3"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.appttude.h_mal.days_left"
|
applicationId "com.appttude.h_mal.days_left"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 28
|
targetSdkVersion 29
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
@@ -16,31 +26,64 @@ android {
|
|||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To inline the bytecode built with JVM target 1.8 into
|
||||||
|
// bytecode that is being built with JVM target 1.6. (e.g. navArgs)
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "1.8"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
implementation 'com.android.support:design:28.0.0'
|
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
implementation 'androidx.core:core-ktx:1.3.0'
|
||||||
implementation 'com.android.support:support-vector-drawable:28.0.0'
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
implementation 'com.android.support:support-v4:28.0.0'
|
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
||||||
|
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
|
||||||
|
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0"
|
||||||
|
// implementation "androidx.activity:activity-ktx:1.3.0-alpha05"
|
||||||
|
implementation "androidx.fragment:fragment-ktx:1.3.0-alpha05"
|
||||||
|
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
|
||||||
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
|
implementation 'androidx.cardview:cardview:1.0.0'
|
||||||
|
implementation 'androidx.exifinterface:exifinterface:1.2.0'
|
||||||
|
implementation 'com.google.android.material:material:1.1.0'
|
||||||
|
|
||||||
|
// Testing
|
||||||
|
testImplementation 'junit:junit:4.13'
|
||||||
|
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||||
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||||
|
// Gson
|
||||||
implementation 'com.google.code.gson:gson:2.3.1'
|
implementation 'com.google.code.gson:gson:2.3.1'
|
||||||
implementation 'com.android.support:exifinterface:28.0.0'
|
// Google Play Services
|
||||||
implementation 'com.android.support:cardview-v7:28.0.0'
|
|
||||||
implementation 'com.google.android.gms:play-services-auth:16.0.1'
|
implementation 'com.google.android.gms:play-services-auth:16.0.1'
|
||||||
|
// Firebase
|
||||||
implementation 'com.google.firebase:firebase-core:16.0.1'
|
implementation 'com.google.firebase:firebase-core:16.0.1'
|
||||||
implementation 'com.google.firebase:firebase-auth:16.2.1'
|
implementation 'com.google.firebase:firebase-auth:16.2.1'
|
||||||
implementation 'com.google.firebase:firebase-storage:16.0.1'
|
implementation 'com.google.firebase:firebase-storage:16.0.1'
|
||||||
implementation 'com.google.firebase:firebase-database:16.0.1'
|
implementation 'com.google.firebase:firebase-database:16.0.1'
|
||||||
implementation 'com.firebaseui:firebase-ui-database:1.1.1'
|
implementation 'com.firebaseui:firebase-ui-database:1.1.1'
|
||||||
implementation 'com.google.firebase:firebase-functions:16.2.0'
|
implementation 'com.google.firebase:firebase-functions:16.2.0'
|
||||||
implementation 'com.github.chrisbanes:PhotoView:2.1.0'
|
//Picasso - load images
|
||||||
implementation 'com.squareup.picasso:picasso:2.71828'
|
implementation 'com.squareup.picasso:picasso:2.71828'
|
||||||
|
// Zoomable Image view
|
||||||
|
implementation 'com.github.chrisbanes:PhotoView:2.1.0'
|
||||||
|
//Kodein Dependency Injection
|
||||||
|
implementation "org.kodein.di:kodein-di-generic-jvm:6.2.1"
|
||||||
|
implementation "org.kodein.di:kodein-di-framework-android-x:6.2.1"
|
||||||
|
|
||||||
|
// Excel (legacy)
|
||||||
implementation "com.github.SUPERCILEX.poi-android:poi:3.17"
|
implementation "com.github.SUPERCILEX.poi-android:poi:3.17"
|
||||||
testImplementation 'junit:junit:4.12'
|
|
||||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
|
||||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'com.google.gms.google-services'
|
apply plugin: 'com.google.gms.google-services'
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.appttude.h_mal.days_left;
|
package com.appttude.h_mal.days_left;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.test.InstrumentationRegistry;
|
import androidx.test.platform.app.InstrumentationRegistry;
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|||||||
@@ -14,13 +14,11 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
|
android:name=".application.AppClass"
|
||||||
android:theme="@style/AppTheme.NoActionBar">
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
|
<activity android:name=".AddItemActivity"></activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name="com.appttude.h_mal.days_left.ui.login.FullscreenActivity"
|
||||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
|
||||||
android:label="@string/app_name" />
|
|
||||||
<activity
|
|
||||||
android:name=".Login.FullscreenActivity"
|
|
||||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||||
android:label="@string/app_name">
|
android:label="@string/app_name">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
@@ -30,11 +28,14 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".AddItems.AddItemActivity" />
|
<activity android:name=".ChangeUserDetailsActivity" />
|
||||||
<activity android:name=".AddItems.AddShiftActivity" />
|
<activity android:name=".AddShiftActivity" />
|
||||||
<activity android:name=".Login.ChangeUserDetailsActivity"></activity>
|
<activity
|
||||||
|
android:name=".ui.main.MainActivity"
|
||||||
|
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||||
|
android:label="@string/app_name" />
|
||||||
<provider
|
<provider
|
||||||
android:name="android.support.v4.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="${applicationId}.provider"
|
android:authorities="${applicationId}.provider"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:grantUriPermissions="true">
|
android:grantUriPermissions="true">
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.Abn;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.zip.Inflater;
|
|
||||||
|
|
||||||
public class AbnListAdapter extends ArrayAdapter<AbnObject> {
|
|
||||||
|
|
||||||
private Context context;
|
|
||||||
|
|
||||||
public AbnListAdapter(@NonNull Context context, @NonNull List<AbnObject> objects) {
|
|
||||||
super(context, 0, objects);
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
|
||||||
View view = convertView;
|
|
||||||
if (view == null){
|
|
||||||
view = LayoutInflater.from(context).inflate(R.layout.abn_list_item,parent, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
AbnObject currentFarm = getItem(position);
|
|
||||||
|
|
||||||
TextView farmNameTextView = view.findViewById(R.id.farm_name);
|
|
||||||
TextView abnTextview = view.findViewById(R.id.abn_text);
|
|
||||||
TextView postCodeTextView = view.findViewById(R.id.postcode_text);
|
|
||||||
|
|
||||||
farmNameTextView.setText(currentFarm.getCompanyName());
|
|
||||||
abnTextview.setText(currentFarm.getAbn());
|
|
||||||
postCodeTextView.setText(currentFarm.getState() + " " + currentFarm.getPostCode());
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,124 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.Abn;
|
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
|
|
||||||
public class AbnObject implements Parcelable {
|
|
||||||
|
|
||||||
private String abn;
|
|
||||||
private String companyName;
|
|
||||||
private int postCode;
|
|
||||||
private String state;
|
|
||||||
private String dateAdded;
|
|
||||||
private String addedById;
|
|
||||||
private Boolean fromAbnSearch;
|
|
||||||
|
|
||||||
public AbnObject(String abn, String companyName, int postCode, String state, @Nullable String dateAdded, @Nullable String addedById, Boolean fromAbnSearch) {
|
|
||||||
this.abn = abn;
|
|
||||||
this.companyName = companyName;
|
|
||||||
this.postCode = postCode;
|
|
||||||
this.state = state;
|
|
||||||
this.dateAdded = dateAdded;
|
|
||||||
this.addedById = addedById;
|
|
||||||
this.fromAbnSearch = fromAbnSearch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AbnObject() {
|
|
||||||
}
|
|
||||||
|
|
||||||
protected AbnObject(Parcel in) {
|
|
||||||
abn = in.readString();
|
|
||||||
companyName = in.readString();
|
|
||||||
postCode = in.readInt();
|
|
||||||
state = in.readString();
|
|
||||||
dateAdded = in.readString();
|
|
||||||
addedById = in.readString();
|
|
||||||
byte tmpFromAbnSearch = in.readByte();
|
|
||||||
fromAbnSearch = tmpFromAbnSearch == 0 ? null : tmpFromAbnSearch == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Creator<AbnObject> CREATOR = new Creator<AbnObject>() {
|
|
||||||
@Override
|
|
||||||
public AbnObject createFromParcel(Parcel in) {
|
|
||||||
return new AbnObject(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AbnObject[] newArray(int size) {
|
|
||||||
return new AbnObject[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public String getAbn() {
|
|
||||||
return abn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAbn(String abn) {
|
|
||||||
this.abn = abn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCompanyName() {
|
|
||||||
return companyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCompanyName(String companyName) {
|
|
||||||
this.companyName = companyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPostCode() {
|
|
||||||
return postCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPostCode(int postCode) {
|
|
||||||
this.postCode = postCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getState() {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setState(String state) {
|
|
||||||
this.state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDateAdded() {
|
|
||||||
return dateAdded;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDateAdded(String dateAdded) {
|
|
||||||
this.dateAdded = dateAdded;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAddedById() {
|
|
||||||
return addedById;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAddedById(String addedById) {
|
|
||||||
this.addedById = addedById;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getFromAbnSearch() {
|
|
||||||
return fromAbnSearch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFromAbnSearch(Boolean fromAbnSearch) {
|
|
||||||
this.fromAbnSearch = fromAbnSearch;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
dest.writeString(abn);
|
|
||||||
dest.writeString(companyName);
|
|
||||||
dest.writeInt(postCode);
|
|
||||||
dest.writeString(state);
|
|
||||||
dest.writeString(dateAdded);
|
|
||||||
dest.writeString(addedById);
|
|
||||||
dest.writeByte((byte) (fromAbnSearch == null ? 0 : fromAbnSearch ? 1 : 2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.Abn;
|
|
||||||
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SearchAbnRecords {
|
|
||||||
|
|
||||||
private String URL = "https://abr.business.gov.au/json/";
|
|
||||||
|
|
||||||
private final static String key = "aaca3f35-d6ac-42a3-bed2-733e7f21a0fc";
|
|
||||||
|
|
||||||
private final static String TAG = "SearchAbnRecords";
|
|
||||||
|
|
||||||
public SearchAbnRecords() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public URL searchViaAbn(String searchTerm){
|
|
||||||
Uri baseUri = Uri.parse(URL);
|
|
||||||
Uri.Builder builder = baseUri.buildUpon();
|
|
||||||
builder.appendPath("AbnDetails.aspx")
|
|
||||||
.appendQueryParameter("abn",searchTerm)
|
|
||||||
.appendQueryParameter("callback","callback")
|
|
||||||
.appendQueryParameter("guid",key);
|
|
||||||
|
|
||||||
return createUrl(builder.build().toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public URL searchViaName(String searchTerm){
|
|
||||||
Uri baseUri = Uri.parse(URL);
|
|
||||||
Uri.Builder builder = baseUri.buildUpon();
|
|
||||||
builder.appendPath("MatchingNames.aspx")
|
|
||||||
.appendQueryParameter("name",searchTerm)
|
|
||||||
.appendQueryParameter("callback","callback")
|
|
||||||
.appendQueryParameter("guid",key);
|
|
||||||
|
|
||||||
return createUrl(builder.build().toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
static java.net.URL createUrl(String stringUrl) {
|
|
||||||
URL url = null;
|
|
||||||
try {
|
|
||||||
url = new URL(stringUrl);
|
|
||||||
} catch (MalformedURLException e) {
|
|
||||||
Log.e(TAG, "Error with creating URL ", e);
|
|
||||||
}
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static String makeHttpRequest(URL url) throws IOException {
|
|
||||||
String jsonResponse = "";
|
|
||||||
|
|
||||||
if (url == null) {
|
|
||||||
return jsonResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
HttpURLConnection urlConnection = null;
|
|
||||||
InputStream inputStream = null;
|
|
||||||
try {
|
|
||||||
urlConnection = (HttpURLConnection) url.openConnection();
|
|
||||||
urlConnection.setReadTimeout(30000);
|
|
||||||
urlConnection.setConnectTimeout(30000);
|
|
||||||
urlConnection.setRequestMethod("GET");
|
|
||||||
urlConnection.connect();
|
|
||||||
|
|
||||||
if (urlConnection.getResponseCode() == 200) {
|
|
||||||
inputStream = urlConnection.getInputStream();
|
|
||||||
jsonResponse = readFromStream(inputStream);
|
|
||||||
} else {
|
|
||||||
Log.e(TAG, "Error response code: " + urlConnection.getResponseCode());
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e(TAG, "Problem retrieving the JSON results.", e);
|
|
||||||
} finally {
|
|
||||||
if (urlConnection != null) {
|
|
||||||
urlConnection.disconnect();
|
|
||||||
}
|
|
||||||
if (inputStream != null) {
|
|
||||||
inputStream.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return jsonResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String readFromStream(InputStream inputStream) throws IOException {
|
|
||||||
StringBuilder output = new StringBuilder();
|
|
||||||
if (inputStream != null) {
|
|
||||||
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, Charset.forName("UTF-8"));
|
|
||||||
BufferedReader reader = new BufferedReader(inputStreamReader);
|
|
||||||
String line = "";
|
|
||||||
while (line != null) {
|
|
||||||
output.append(line);
|
|
||||||
line = reader.readLine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Log.d(TAG, output.toString());
|
|
||||||
return output.toString();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<AbnObject> ExtractFeatureFromAbnJson(String json){
|
|
||||||
List<AbnObject> abnObjectArrayList = new ArrayList<>();
|
|
||||||
|
|
||||||
Log.i(TAG, "ExtractFeatureFromAbnJson: " + json);
|
|
||||||
|
|
||||||
if (TextUtils.isEmpty(json)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (json.contains("callback")){
|
|
||||||
json = json.replace("callback(","");
|
|
||||||
json.substring(0,json.length()-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
JSONObject jObject = new JSONObject(json);
|
|
||||||
AbnObject abnObject = new AbnObject(jObject.getString("Abn"),jObject.getString("EntityName")
|
|
||||||
,jObject.getInt("AddressPostcode"),jObject.getString("AddressState"),null,null,true);
|
|
||||||
abnObjectArrayList.add(abnObject);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
Log.e("SearchAbn", "Problem parsing the JSON results", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return abnObjectArrayList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<AbnObject> ExtractFeatureFromNameJson(String json){
|
|
||||||
List<AbnObject> abnObjectArrayList = new ArrayList<>();
|
|
||||||
|
|
||||||
if (TextUtils.isEmpty(json)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
JSONObject jObject = new JSONObject(json);
|
|
||||||
JSONArray employersList = jObject.getJSONArray("Names");
|
|
||||||
|
|
||||||
for (int i = 0; i < employersList.length(); i++){
|
|
||||||
JSONObject current = employersList.getJSONObject(i);
|
|
||||||
|
|
||||||
Log.i(TAG, "ExtractFeatureFromNameJson: " + current.get("Abn"));
|
|
||||||
|
|
||||||
String abn = current.getString("Abn");
|
|
||||||
String name = current.getString("Name");
|
|
||||||
int postcode = current.getInt("Postcode");
|
|
||||||
String state = current.getString("State");
|
|
||||||
|
|
||||||
AbnObject abnObject = new AbnObject(abn,name,postcode,state,null,null,false);
|
|
||||||
|
|
||||||
abnObjectArrayList.add(abnObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (JSONException e) {
|
|
||||||
Log.e("SearchAbnRecords", "Problem parsing the JSON results", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return abnObjectArrayList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,171 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.AddItems;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.SearchManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.text.InputFilter;
|
|
||||||
import android.text.InputType;
|
|
||||||
import android.text.LoginFilter;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.SearchView;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.Abn.AbnListAdapter;
|
|
||||||
import com.appttude.h_mal.days_left.Abn.AbnObject;
|
|
||||||
import com.appttude.h_mal.days_left.Abn.SearchAbnRecords;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static com.appttude.h_mal.days_left.Abn.SearchAbnRecords.ExtractFeatureFromAbnJson;
|
|
||||||
import static com.appttude.h_mal.days_left.Abn.SearchAbnRecords.ExtractFeatureFromNameJson;
|
|
||||||
import static com.appttude.h_mal.days_left.Abn.SearchAbnRecords.makeHttpRequest;
|
|
||||||
|
|
||||||
|
|
||||||
public class AddEmployerFragment extends Fragment {
|
|
||||||
|
|
||||||
int selected;
|
|
||||||
private SearchView searchView;
|
|
||||||
private boolean abn;
|
|
||||||
private ListView listView;
|
|
||||||
private ProgressBar progressBar;
|
|
||||||
private LinearLayout emptyView;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
// Inflate the layout for this fragment
|
|
||||||
View view = inflater.inflate(R.layout.fragment_add_employer, container, false);
|
|
||||||
|
|
||||||
listView = view.findViewById(R.id.list_view);
|
|
||||||
progressBar = view.findViewById(R.id.spinning_pb);
|
|
||||||
emptyView = view.findViewById(R.id.empty_list);
|
|
||||||
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
inflater.inflate(R.menu.menu_search, menu);
|
|
||||||
MenuItem searchItem = menu.findItem(R.id.app_bar_search);
|
|
||||||
|
|
||||||
searchView = (SearchView) searchItem.getActionView();
|
|
||||||
searchView.setOnQueryTextListener(onQueryTextListener);
|
|
||||||
searchView.setOnSearchClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
createDialog();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createDialog(){
|
|
||||||
final String[] grpname = {"A.B.N","Company Name"};
|
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
|
||||||
builder.setTitle("Search by:")
|
|
||||||
.setSingleChoiceItems(grpname, selected, new DialogInterface
|
|
||||||
.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int item) {
|
|
||||||
switch (item) {
|
|
||||||
case 0:
|
|
||||||
searchView.setQueryHint("Search via A.B.N");
|
|
||||||
searchView.setInputType(InputType.TYPE_CLASS_NUMBER);
|
|
||||||
abn = true;
|
|
||||||
setupSearchbar(dialog);
|
|
||||||
return;
|
|
||||||
case 1:
|
|
||||||
searchView.setQueryHint("Search via Name");
|
|
||||||
searchView.setInputType(InputType.TYPE_CLASS_TEXT);
|
|
||||||
abn = false;
|
|
||||||
setupSearchbar(dialog);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
}).setOnCancelListener(new DialogInterface.OnCancelListener() {
|
|
||||||
@Override
|
|
||||||
public void onCancel(DialogInterface dialog) {
|
|
||||||
if (!searchView.isIconified()) {
|
|
||||||
searchView.setIconified(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).create().show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupSearchbar(DialogInterface dialog){
|
|
||||||
searchView.requestFocus();
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SearchView.OnQueryTextListener onQueryTextListener = new SearchView.OnQueryTextListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onQueryTextSubmit(String query) {
|
|
||||||
String searchTerm = query.trim();
|
|
||||||
SearchAbnRecords abnRecords = new SearchAbnRecords();
|
|
||||||
|
|
||||||
URL callUrl;
|
|
||||||
|
|
||||||
if (abn){
|
|
||||||
if (query.length() > 11){
|
|
||||||
searchTerm = searchTerm.substring(0,11);
|
|
||||||
}
|
|
||||||
callUrl = abnRecords.searchViaAbn(searchTerm);
|
|
||||||
}else {
|
|
||||||
callUrl = abnRecords.searchViaName(searchTerm);
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.i("URL", "onQueryTextSubmit: " + callUrl.toString());
|
|
||||||
|
|
||||||
SearchAsyncTask asyncTask = new SearchAsyncTask(getActivity(),listView,emptyView,progressBar,abn);
|
|
||||||
asyncTask.execute(callUrl);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onQueryTextChange(String newText) {
|
|
||||||
if (abn){
|
|
||||||
if(newText.length()>11){
|
|
||||||
System.out.println("Text character is more than 11");
|
|
||||||
searchView.setQuery(newText.substring(0,11), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.AddItems;
|
|
||||||
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.app.FragmentManager;
|
|
||||||
import android.support.v4.app.FragmentTransaction;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.Objects.TaskObject;
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
|
|
||||||
import static com.appttude.h_mal.days_left.AddItems.AddShiftActivity.EMPLOYERREQUEST;
|
|
||||||
import static com.appttude.h_mal.days_left.AddItems.AddShiftActivity.REQUEST;
|
|
||||||
import static com.appttude.h_mal.days_left.AddItems.AddShiftActivity.TASK_CONSTANT;
|
|
||||||
|
|
||||||
public class AddItemActivity extends AppCompatActivity {
|
|
||||||
|
|
||||||
public static FragmentManager fragmentManager;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_add_item);
|
|
||||||
|
|
||||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
|
||||||
setSupportActionBar(toolbar);
|
|
||||||
|
|
||||||
fragmentManager = getSupportFragmentManager();
|
|
||||||
|
|
||||||
int requestCode = getIntent().getIntExtra(REQUEST,EMPLOYERREQUEST);
|
|
||||||
|
|
||||||
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
|
||||||
|
|
||||||
if (requestCode == EMPLOYERREQUEST){
|
|
||||||
fragmentTransaction.replace(R.id.container,new AddEmployerFragment()).addToBackStack("Employer").commit();
|
|
||||||
}else {
|
|
||||||
TaskObject taskObject = getIntent().getParcelableExtra(TASK_CONSTANT);
|
|
||||||
Fragment addTaskFragment = new AddTaskFragment();
|
|
||||||
if (taskObject != null){
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putParcelable(TASK_CONSTANT,taskObject);
|
|
||||||
|
|
||||||
addTaskFragment.setArguments(bundle);
|
|
||||||
}
|
|
||||||
fragmentTransaction.replace(R.id.container,addTaskFragment).addToBackStack("Task").commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
ProgressBar progressBar = findViewById(R.id.progressBar2);
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
fragmentManager.addOnBackStackChangedListener(backStackChangedListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
FragmentManager.OnBackStackChangedListener backStackChangedListener = new FragmentManager.OnBackStackChangedListener() {
|
|
||||||
@Override
|
|
||||||
public void onBackStackChanged() {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
if (fragmentManager.getBackStackEntryCount() > 1) {
|
|
||||||
fragmentManager.popBackStack();
|
|
||||||
}else{
|
|
||||||
new AlertDialog.Builder(this)
|
|
||||||
.setTitle("Leave?")
|
|
||||||
.setMessage("Are you sure you return to previous?")
|
|
||||||
.setNegativeButton(android.R.string.no, null)
|
|
||||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface arg0, int arg1) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}).create().show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,620 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.AddItems;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
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 android.os.Bundle;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.support.v7.widget.CardView;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.animation.Animation;
|
|
||||||
import android.view.animation.AnimationUtils;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.TimePicker;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.Abn.AbnObject;
|
|
||||||
import com.appttude.h_mal.days_left.Global.DateDialog;
|
|
||||||
import com.appttude.h_mal.days_left.Global.FirebaseClass;
|
|
||||||
import com.appttude.h_mal.days_left.Objects.ShiftObject;
|
|
||||||
import com.appttude.h_mal.days_left.Objects.TaskObject;
|
|
||||||
import com.appttude.h_mal.days_left.Objects.TimeObject;
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
import com.google.android.gms.tasks.OnCompleteListener;
|
|
||||||
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 java.util.Calendar;
|
|
||||||
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.EMPLOYER_FIREBASE;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.PIECE;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.SHIFT_FIREBASE;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.SHIFT_ID;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.TASK_FIREBASE;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.USER_FIREBASE;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.auth;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.getDateTimeString;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.mDatabase;
|
|
||||||
|
|
||||||
|
|
||||||
public class AddShiftActivity extends AppCompatActivity {
|
|
||||||
|
|
||||||
public static final int EMPLOYERREQUEST = 339;
|
|
||||||
public static final int TASKREQUEST = 445;
|
|
||||||
public static final String REQUEST = "request";
|
|
||||||
public static final String EMPLOYER_CONSTANT = "employer";
|
|
||||||
public static final String TASK_CONSTANT = "task";
|
|
||||||
|
|
||||||
private TextView lableOne;
|
|
||||||
private LinearLayout employerLayout;
|
|
||||||
private LinearLayout taskLayout;
|
|
||||||
private TextView lableTwo;
|
|
||||||
private CardView employerCard;
|
|
||||||
private TextView employerName;
|
|
||||||
private TextView employerLocation;
|
|
||||||
private CardView taskCard;
|
|
||||||
private TextView taskName;
|
|
||||||
private TextView taskSummary;
|
|
||||||
private EditText units;
|
|
||||||
private EditText date;
|
|
||||||
|
|
||||||
private CardView selectTimesCardView;
|
|
||||||
private LinearLayout timeLayoutLinearLayout;
|
|
||||||
private TextView timeTextView;
|
|
||||||
private TextView timeSummaryTextView;
|
|
||||||
private LinearLayout breakHolderLinearLayout;
|
|
||||||
private TextView breakSummaryTextView;
|
|
||||||
private TextView lable3TextView;
|
|
||||||
|
|
||||||
private TimeObject timeObject = new TimeObject();
|
|
||||||
public AbnObject abnObject;
|
|
||||||
public TaskObject taskObject;
|
|
||||||
private FirebaseClass firebaseClass;
|
|
||||||
private ProgressBar progressBar;
|
|
||||||
private String ShiftID;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_add_shift);
|
|
||||||
|
|
||||||
employerCard = findViewById(R.id.select_employer_card);
|
|
||||||
employerLayout = findViewById(R.id.employer_layout);
|
|
||||||
employerName = findViewById(R.id.employer_name);
|
|
||||||
employerLocation = findViewById(R.id.employer_location);
|
|
||||||
lableOne = findViewById(R.id.lable_1);
|
|
||||||
|
|
||||||
employerCard.setOnClickListener(employerListener);
|
|
||||||
|
|
||||||
taskCard = findViewById(R.id.select_task_card);
|
|
||||||
taskLayout = findViewById(R.id.task_layout);
|
|
||||||
taskName = findViewById(R.id.task);
|
|
||||||
taskSummary = findViewById(R.id.task_summary);
|
|
||||||
lableTwo = findViewById(R.id.lable_2);
|
|
||||||
|
|
||||||
taskCard.setOnClickListener(taskListener);
|
|
||||||
|
|
||||||
selectTimesCardView = findViewById(R.id.select_times_card);
|
|
||||||
timeLayoutLinearLayout = findViewById(R.id.time_layout);
|
|
||||||
timeTextView = findViewById(R.id.time);
|
|
||||||
timeSummaryTextView = findViewById(R.id.time_summary);
|
|
||||||
breakHolderLinearLayout = findViewById(R.id.break_holder);
|
|
||||||
breakSummaryTextView = findViewById(R.id.break_summary);
|
|
||||||
lable3TextView = findViewById(R.id.lable_3);
|
|
||||||
|
|
||||||
units = findViewById(R.id.units);
|
|
||||||
date = findViewById(R.id.date);
|
|
||||||
|
|
||||||
ImageButton submit = findViewById(R.id.search_button);
|
|
||||||
submit.setOnClickListener(submitListener);
|
|
||||||
|
|
||||||
Intent intent = getIntent();
|
|
||||||
ShiftID = intent.getStringExtra(SHIFT_ID);
|
|
||||||
if (ShiftID != null){
|
|
||||||
DatabaseReference reference = mDatabase.child(USER_FIREBASE).child(auth.getUid()).child(SHIFT_FIREBASE).child(ShiftID);
|
|
||||||
|
|
||||||
reference.addListenerForSingleValueEvent(new ValueEventListener() {
|
|
||||||
@Override
|
|
||||||
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
|
|
||||||
ShiftObject shiftObject = dataSnapshot.getValue(ShiftObject.class);
|
|
||||||
abnObject = shiftObject.getAbnObject();
|
|
||||||
taskObject = shiftObject.getTaskObject();
|
|
||||||
if (shiftObject.timeObject != null){
|
|
||||||
timeObject = shiftObject.getTimeObject();
|
|
||||||
setTimeSummary();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shiftObject.getTaskObject().getWorkType().equals(PIECE)){
|
|
||||||
units.setText(String.valueOf(shiftObject.getUnitsCount()));
|
|
||||||
}
|
|
||||||
setTaskCard();
|
|
||||||
setEmployerCard();
|
|
||||||
date.setText(shiftObject.getShiftDate());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCancelled(@NonNull DatabaseError databaseError) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
progressBar = findViewById(R.id.progress_bar);
|
|
||||||
|
|
||||||
Log.i("DateTime", "onCreate: " + getDateTimeString());
|
|
||||||
|
|
||||||
selectTimesCardView.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
TimeDialogClass timeDialogClass = new TimeDialogClass(AddShiftActivity.this);
|
|
||||||
timeDialogClass.create().show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
date.setFocusable(false);
|
|
||||||
date.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
DateDialog dateDialog;
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
|
||||||
dateDialog = new DateDialog(AddShiftActivity.this);
|
|
||||||
}else {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
final int selectedYear = calendar.get(Calendar.YEAR);
|
|
||||||
final int selectedMonth = calendar.get(Calendar.MONTH);
|
|
||||||
final int selectedDay = calendar.get(Calendar.DAY_OF_MONTH);
|
|
||||||
|
|
||||||
dateDialog = new DateDialog(AddShiftActivity.this,
|
|
||||||
null,
|
|
||||||
selectedYear,
|
|
||||||
selectedMonth,
|
|
||||||
selectedDay);
|
|
||||||
}
|
|
||||||
dateDialog.init(date);
|
|
||||||
dateDialog.show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
firebaseClass = new FirebaseClass();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
View.OnClickListener submitListener = new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
String dateString = date.getText().toString();
|
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
if (abnObject != null && taskObject != null && !TextUtils.isEmpty(dateString)){
|
|
||||||
String workType = taskObject.getWorkType();
|
|
||||||
ShiftObject shiftObject = null;
|
|
||||||
|
|
||||||
if (workType.equals("Piece Rate")){
|
|
||||||
String unitString = units.getText().toString();
|
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(unitString)){
|
|
||||||
float unitFloat = Float.parseFloat(unitString);
|
|
||||||
shiftObject = new ShiftObject(dateString,getDateTimeString(),abnObject,taskObject,unitFloat,timeObject);
|
|
||||||
}else {
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
Toast.makeText(AddShiftActivity.this, "Mandatory information missing", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
}else if(workType.equals("Hourly")){
|
|
||||||
shiftObject = new ShiftObject(dateString,getDateTimeString(),abnObject,taskObject,null,timeObject);
|
|
||||||
}else {
|
|
||||||
Toast.makeText(AddShiftActivity.this, "Insert Times", Toast.LENGTH_SHORT).show();
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shiftObject != null){
|
|
||||||
DatabaseReference shiftReference;
|
|
||||||
|
|
||||||
if (ShiftID != null){
|
|
||||||
shiftReference = mDatabase.child(USER_FIREBASE).child(auth.getUid()).child(SHIFT_FIREBASE).child(ShiftID);
|
|
||||||
//Updating a shift
|
|
||||||
}else {
|
|
||||||
shiftReference = mDatabase.child(USER_FIREBASE).child(auth.getUid()).child(SHIFT_FIREBASE).push();
|
|
||||||
//Pushing a brand new shift
|
|
||||||
}
|
|
||||||
|
|
||||||
shiftReference.setValue(shiftObject).addOnCompleteListener(new OnCompleteListener<Void>() {
|
|
||||||
@Override
|
|
||||||
public void onComplete(@NonNull Task<Void> task) {
|
|
||||||
Log.i("Firebase", "onComplete: " + task.getResult());
|
|
||||||
if (task.isSuccessful()){
|
|
||||||
|
|
||||||
|
|
||||||
firebaseClass.UpdateListOfPreviouslyUsedAbns(abnObject.getAbn(), new FirebaseClass.Complete() {
|
|
||||||
@Override
|
|
||||||
public void taskCompleted(Boolean success) {
|
|
||||||
if (success){
|
|
||||||
firebaseClass.PushAbnObject(abnObject,taskObject,progressBar,AddShiftActivity.this);
|
|
||||||
Log.i("PushPhase", "taskCompleted: UpdateListOfPreviouslyUsedAbns");
|
|
||||||
}else {
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
Toast.makeText(AddShiftActivity.this, "Could not upload Task", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}else {
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
Toast.makeText(AddShiftActivity.this, "Could not publish shift", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}else {
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
Toast.makeText(AddShiftActivity.this, "Could not publish shift", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}else {
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
Toast.makeText(AddShiftActivity.this, "Mandatory information missing", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
View.OnClickListener employerListener = new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
PreviouslyUsedItemsClass previouslyUsedItemsClass = new PreviouslyUsedItemsClass(progressBar,AddShiftActivity.this);
|
|
||||||
DatabaseReference databaseReference = mDatabase.child(USER_FIREBASE).child(auth.getUid()).child("recent"+EMPLOYER_FIREBASE);
|
|
||||||
|
|
||||||
databaseReference.addListenerForSingleValueEvent(previouslyUsedItemsClass);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
View.OnClickListener taskListener = new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
if (abnObject != null){
|
|
||||||
String abn = abnObject.getAbn();
|
|
||||||
AssociatedTasksClass associatedTasks = new AssociatedTasksClass(AddShiftActivity.this, progressBar);
|
|
||||||
DatabaseReference taskReference = mDatabase.child(EMPLOYER_FIREBASE).child(abn).child(TASK_FIREBASE);
|
|
||||||
taskReference.addListenerForSingleValueEvent(associatedTasks);
|
|
||||||
|
|
||||||
}else {
|
|
||||||
Intent intent = new Intent(AddShiftActivity.this,AddItemActivity.class);
|
|
||||||
intent.putExtra(REQUEST,TASKREQUEST);
|
|
||||||
if (taskObject != null){
|
|
||||||
intent.putExtra(TASK_CONSTANT,taskObject);
|
|
||||||
}
|
|
||||||
startActivityForResult(intent,TASKREQUEST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private void setTimeSummary(){
|
|
||||||
if (lable3TextView.getVisibility() == View.VISIBLE){
|
|
||||||
toggleViewVisibility(selectTimesCardView);
|
|
||||||
}
|
|
||||||
|
|
||||||
timeSummaryTextView.setText(timeObject.getTimeIn() + " - " + timeObject.getTimeOut());
|
|
||||||
if (timeObject.getBreakEpoch() > 0){
|
|
||||||
breakHolderLinearLayout.setVisibility(View.VISIBLE);
|
|
||||||
breakSummaryTextView.setText(timeObject.getBreakEpoch() + " minutes");
|
|
||||||
}else {
|
|
||||||
breakHolderLinearLayout.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
timeTextView.setText(convertTimeFloat(timeObject.getHours()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
|
||||||
|
|
||||||
if (requestCode == EMPLOYERREQUEST) {
|
|
||||||
if(resultCode == Activity.RESULT_OK){
|
|
||||||
abnObject = data.getParcelableExtra("AbnObject");
|
|
||||||
setEmployerCard();
|
|
||||||
|
|
||||||
TaskObject taskObjectRel = data.getParcelableExtra("TaskObject");
|
|
||||||
|
|
||||||
if(taskObjectRel != null){
|
|
||||||
taskObject = taskObjectRel;
|
|
||||||
|
|
||||||
setTaskCard();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (resultCode == Activity.RESULT_CANCELED) {
|
|
||||||
//Write your code if there's no result
|
|
||||||
}
|
|
||||||
}else if (requestCode == TASKREQUEST) {
|
|
||||||
if(resultCode == Activity.RESULT_OK){
|
|
||||||
taskObject = data.getParcelableExtra("TaskObject");
|
|
||||||
setTaskCard();
|
|
||||||
}
|
|
||||||
if (resultCode == Activity.RESULT_CANCELED) {
|
|
||||||
//Write your code if there's no result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEmployerCard(){
|
|
||||||
if (lableOne.getVisibility() == View.VISIBLE){
|
|
||||||
toggleViewVisibility(employerCard);
|
|
||||||
}
|
|
||||||
|
|
||||||
employerName.setText(abnObject.getCompanyName());
|
|
||||||
employerLocation.setText(abnObject.getState() + " " + abnObject.getPostCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTaskCard(){
|
|
||||||
if (lableTwo.getVisibility() == View.VISIBLE){
|
|
||||||
toggleViewVisibility(taskCard);
|
|
||||||
}
|
|
||||||
|
|
||||||
taskName.setText(taskObject.getTask());
|
|
||||||
|
|
||||||
String summary = taskObject.getWorkType() + " - $" + taskObject.getRate()+ " /" ;
|
|
||||||
if (taskObject.getWorkType().equals("Piece Rate")){
|
|
||||||
summary = summary + "Unit";
|
|
||||||
|
|
||||||
units.setVisibility(View.VISIBLE);
|
|
||||||
selectTimesCardView.setVisibility(View.VISIBLE);
|
|
||||||
}else {
|
|
||||||
summary = summary + "Hour";
|
|
||||||
|
|
||||||
units.setVisibility(View.GONE);
|
|
||||||
selectTimesCardView.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
taskSummary.setText(summary);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void toggleViewVisibility(CardView cardView){
|
|
||||||
switch (cardView.getId()){
|
|
||||||
case R.id.select_employer_card:
|
|
||||||
setVisibility(employerLayout);
|
|
||||||
setVisibility(lableOne);
|
|
||||||
break;
|
|
||||||
case R.id.select_task_card:
|
|
||||||
setVisibility(taskLayout);
|
|
||||||
setVisibility(lableTwo);
|
|
||||||
break;
|
|
||||||
case R.id.select_times_card:
|
|
||||||
setVisibility(timeLayoutLinearLayout);
|
|
||||||
setVisibility(lable3TextView);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setVisibility(View view){
|
|
||||||
int vis;
|
|
||||||
if (view.getVisibility() == View.VISIBLE){
|
|
||||||
vis = View.GONE;
|
|
||||||
}else{
|
|
||||||
vis = View.VISIBLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
view.setVisibility(vis);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String convertTimeFloat(float timeIn){
|
|
||||||
int hour = (int) timeIn;
|
|
||||||
int minutes = (int) (timeIn - hour)*60;
|
|
||||||
|
|
||||||
return hour + "hours " + minutes + "mins";
|
|
||||||
}
|
|
||||||
|
|
||||||
class TimeDialogClass extends AlertDialog.Builder{
|
|
||||||
|
|
||||||
private TimePicker timePickerTimePicker;
|
|
||||||
private TextView startTimeTextView;
|
|
||||||
private TextView finishTimeTextView;
|
|
||||||
private EditText breakEditText;
|
|
||||||
|
|
||||||
private String currentTag;
|
|
||||||
private AlertDialog alertDialog;
|
|
||||||
private int breakInt;
|
|
||||||
|
|
||||||
public TimeDialogClass(Context context) {
|
|
||||||
super(context);
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TimeDialogClass(Context context, int themeResId) {
|
|
||||||
super(context, themeResId);
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init(){
|
|
||||||
setView(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AlertDialog.Builder setView(View view) {
|
|
||||||
view = View.inflate(getContext(),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);
|
|
||||||
TextView okText = view.findViewById(R.id.ok);
|
|
||||||
|
|
||||||
timePickerTimePicker.setIs24HourView(true);
|
|
||||||
|
|
||||||
okText.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (timeObject.getTimeIn() != null && timeObject.getTimeOut() != null){
|
|
||||||
timeObject.setHours(calculateDuration());
|
|
||||||
timeObject.setBreakEpoch(breakInt);
|
|
||||||
|
|
||||||
|
|
||||||
if (lable3TextView.getVisibility() == View.VISIBLE){
|
|
||||||
toggleViewVisibility(selectTimesCardView);
|
|
||||||
}
|
|
||||||
|
|
||||||
timeTextView.setText(convertTimeFloat(timeObject.getHours()));
|
|
||||||
|
|
||||||
setTimeSummary();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
alertDialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
startTimeTextView.setTag("start");
|
|
||||||
finishTimeTextView.setTag("finish");
|
|
||||||
|
|
||||||
startTimeTextView.setOnClickListener(timeSelect);
|
|
||||||
finishTimeTextView.setOnClickListener(timeSelect);
|
|
||||||
|
|
||||||
timePickerTimePicker.setOnTimeChangedListener(timeChangedListener);
|
|
||||||
toggleTextButtons(true);
|
|
||||||
|
|
||||||
return super.setView(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TimePicker.OnTimeChangedListener timeChangedListener = new TimePicker.OnTimeChangedListener() {
|
|
||||||
@Override
|
|
||||||
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
|
|
||||||
String ddTime = String.format("%02d", hourOfDay) + ":" + String.format("%02d", minute);
|
|
||||||
if (currentTag.equals("start")){
|
|
||||||
timeObject.setTimeIn(ddTime);
|
|
||||||
}else {
|
|
||||||
timeObject.setTimeOut(ddTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
View.OnClickListener timeSelect = new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
currentTag = (String) v.getTag();
|
|
||||||
String timeString;
|
|
||||||
|
|
||||||
if (currentTag.equals("start")){
|
|
||||||
timeString = timeObject.getTimeIn();
|
|
||||||
toggleTextButtons(true);
|
|
||||||
|
|
||||||
}else {
|
|
||||||
timeString = timeObject.getTimeOut();
|
|
||||||
toggleTextButtons(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (timeString != null){
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
timePickerTimePicker.setHour(getTime(timeString)[0]);
|
|
||||||
timePickerTimePicker.setMinute(getTime(timeString)[1]);
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
timePickerTimePicker.setHour(calendar.get(Calendar.HOUR_OF_DAY));
|
|
||||||
timePickerTimePicker.setMinute(calendar.get(Calendar.MINUTE));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AlertDialog create() {
|
|
||||||
alertDialog = super.create();
|
|
||||||
|
|
||||||
return alertDialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AlertDialog.Builder setNegativeButton(int textId, DialogInterface.OnClickListener listener) {
|
|
||||||
return super.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private int[] getTime(String s){
|
|
||||||
|
|
||||||
return new int[]{Integer.parseInt(s.split(":")[0]),Integer.parseInt(s.split(":")[1])};
|
|
||||||
}
|
|
||||||
|
|
||||||
private float calculateDuration(){
|
|
||||||
String startTime = timeObject.getTimeIn();
|
|
||||||
String finishTime = timeObject.getTimeOut();
|
|
||||||
String breakText = breakEditText.getText().toString().trim();
|
|
||||||
|
|
||||||
int hoursIn = getTime(startTime)[0];
|
|
||||||
int hoursOut = getTime(finishTime)[0];
|
|
||||||
int minutesIn = getTime(startTime)[1];
|
|
||||||
int minutesOut = getTime(finishTime)[1];
|
|
||||||
|
|
||||||
breakInt = 0;
|
|
||||||
if (!TextUtils.isEmpty(breakText)){
|
|
||||||
breakInt = Integer.parseInt(breakText);
|
|
||||||
}
|
|
||||||
float duration;
|
|
||||||
|
|
||||||
if (hoursOut > hoursIn){
|
|
||||||
duration = (((float)hoursOut + ((float)minutesOut/60)) - ((float) hoursIn + ((float)minutesIn/60))) - ((float) breakInt / 60);
|
|
||||||
}else{
|
|
||||||
duration = ((((float)hoursOut + ((float)minutesOut/60)) - ((float)hoursIn + ((float)minutesIn/60))) - ((float) breakInt / 60) + 24);
|
|
||||||
}
|
|
||||||
|
|
||||||
String s = String.format("%.2f",duration);
|
|
||||||
return Float.parseFloat(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void toggleTextButtons(boolean top){
|
|
||||||
setFadeAnimation(startTimeTextView);
|
|
||||||
setFadeAnimation(finishTimeTextView);
|
|
||||||
|
|
||||||
if (top){
|
|
||||||
startTimeTextView.setTypeface(null, Typeface.BOLD);
|
|
||||||
finishTimeTextView.setTypeface(null, Typeface.NORMAL);
|
|
||||||
|
|
||||||
startTimeTextView.setBackgroundColor(getContext().getResources().getColor(R.color.one));
|
|
||||||
finishTimeTextView.setBackgroundColor(getContext().getResources().getColor(android.R.color.white));
|
|
||||||
}else {
|
|
||||||
finishTimeTextView.setTypeface(null, Typeface.BOLD);
|
|
||||||
startTimeTextView.setTypeface(null, Typeface.NORMAL);
|
|
||||||
|
|
||||||
finishTimeTextView.setBackgroundColor(getContext().getResources().getColor(R.color.one));
|
|
||||||
startTimeTextView.setBackgroundColor(getContext().getResources().getColor(android.R.color.white));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setFadeAnimation(View view){
|
|
||||||
Animation bottomUp = AnimationUtils.loadAnimation(getContext(),
|
|
||||||
R.anim.fade_in);
|
|
||||||
|
|
||||||
view.setAnimation(bottomUp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,328 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.AddItems;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v7.widget.CardView;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.Spinner;
|
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.Objects.TaskObject;
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
|
|
||||||
import static com.appttude.h_mal.days_left.AddItems.AddShiftActivity.TASK_CONSTANT;
|
|
||||||
|
|
||||||
public class AddTaskFragment extends Fragment {
|
|
||||||
|
|
||||||
private CardView cardoneCardView;
|
|
||||||
private CardView cardtwoCardView;
|
|
||||||
private CardView cardthreeCardView;
|
|
||||||
private Spinner spinneroneSpinner;
|
|
||||||
private Spinner spinnerTwoSpinner;
|
|
||||||
private EditText payrateEditText;
|
|
||||||
private TextView unittextTextView;
|
|
||||||
private ImageButton searchbuttonImageButton;
|
|
||||||
private Boolean dialogActive = false;
|
|
||||||
|
|
||||||
private String product = "";
|
|
||||||
String[] strings;
|
|
||||||
|
|
||||||
String TAG = "AddTaskFragment";
|
|
||||||
private String[] taskList;
|
|
||||||
private String[] workTypeArray;
|
|
||||||
private String current;
|
|
||||||
private String previous;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
initialiseArrayString();
|
|
||||||
previous = taskList[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
// Inflate the layout for this fragment
|
|
||||||
View view = inflater.inflate(R.layout.fragment_add_task, container, false);
|
|
||||||
|
|
||||||
cardoneCardView = view.findViewById(R.id.card_one);
|
|
||||||
cardtwoCardView = view.findViewById(R.id.card_two);
|
|
||||||
cardthreeCardView = view.findViewById(R.id.card_three);
|
|
||||||
|
|
||||||
spinneroneSpinner = view.findViewById(R.id.spinner_one);
|
|
||||||
spinnerTwoSpinner = view.findViewById(R.id.spinner_Two);
|
|
||||||
|
|
||||||
payrateEditText = view.findViewById(R.id.pay_rate);
|
|
||||||
unittextTextView = view.findViewById(R.id.unit_text);
|
|
||||||
|
|
||||||
searchbuttonImageButton = view.findViewById(R.id.search_button);
|
|
||||||
searchbuttonImageButton.setOnClickListener(submit);
|
|
||||||
|
|
||||||
if (getArguments() != null){
|
|
||||||
Bundle bundle = getArguments();
|
|
||||||
TaskObject taskObject = bundle.getParcelable(TASK_CONSTANT);
|
|
||||||
spinneroneSpinner.setSelection(getSpinnerOneSelection(taskObject.getWorkType()));
|
|
||||||
payrateEditText.setText(String.valueOf(taskObject.getRate()));
|
|
||||||
spinnerTwoSpinner.setSelection(getSpinnerTwoSelection(taskObject.getTask()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
|
||||||
super.onViewCreated(view, savedInstanceState);
|
|
||||||
setupSpinnerOne();
|
|
||||||
setupSpinnerTwo();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getSpinnerOneSelection(String s){
|
|
||||||
switch (s){
|
|
||||||
case "Hourly":
|
|
||||||
return 1;
|
|
||||||
case "Piece Rate":
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getSpinnerTwoSelection(String s){
|
|
||||||
String[] strings = getContext().getResources().getStringArray(R.array.task_list);
|
|
||||||
int i = 1;
|
|
||||||
for (String string: strings){
|
|
||||||
|
|
||||||
if (s.contains(string)){
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
View.OnClickListener submit = new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
String workType = (String) spinneroneSpinner.getSelectedItem();
|
|
||||||
String rate = payrateEditText.getText().toString().trim();
|
|
||||||
String task = (String) spinnerTwoSpinner.getSelectedItem();
|
|
||||||
if (!workType.equals(strings[0]) &&
|
|
||||||
!TextUtils.isEmpty(rate) &&
|
|
||||||
!task.equals(taskList[0])){
|
|
||||||
if (((String) spinnerTwoSpinner.getSelectedItem()).contains(workTypeArray[1]) && task.equals(workTypeArray[1])){
|
|
||||||
Toast.makeText(getContext(), "Insert A product Harvested", Toast.LENGTH_SHORT).show();
|
|
||||||
}else {
|
|
||||||
rate = String.format("%.2f",Float.valueOf(rate));
|
|
||||||
TaskObject taskObject = new TaskObject(workType,Float.valueOf(rate),task,null,null);
|
|
||||||
|
|
||||||
Intent returnIntent = new Intent();
|
|
||||||
returnIntent.putExtra("TaskObject",taskObject);
|
|
||||||
getActivity().setResult(Activity.RESULT_OK,returnIntent);
|
|
||||||
getActivity().finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
}else {
|
|
||||||
Toast.makeText(getContext(), "Insert All Required data", Toast.LENGTH_SHORT).show();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private void setupSpinnerOne(){
|
|
||||||
workTypeArray = getContext().getResources().getStringArray(R.array.work_type);
|
|
||||||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>
|
|
||||||
(getContext(), android.R.layout.simple_spinner_item,
|
|
||||||
workTypeArray){
|
|
||||||
@Override
|
|
||||||
public boolean isEnabled(int position) {
|
|
||||||
if(position == 0)
|
|
||||||
{
|
|
||||||
// Disable the first item from Spinner
|
|
||||||
// First item will be use for hint
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
|
||||||
View view = super.getDropDownView(position, convertView, parent);
|
|
||||||
TextView tv = (TextView) view;
|
|
||||||
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);
|
|
||||||
spinneroneSpinner.setAdapter(spinnerArrayAdapter);
|
|
||||||
spinneroneSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
switch (position){
|
|
||||||
case 1:
|
|
||||||
unittextTextView.setText("per Unit");
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
unittextTextView.setText("per Hour");
|
|
||||||
default:
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupSpinnerTwo(){
|
|
||||||
final ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>
|
|
||||||
(getContext(), android.R.layout.simple_spinner_item,
|
|
||||||
strings) {
|
|
||||||
@Override
|
|
||||||
public boolean isEnabled(int position) {
|
|
||||||
if(position == 0) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
|
||||||
View view = super.getDropDownView(position, convertView, parent);
|
|
||||||
TextView tv = (TextView) view;
|
|
||||||
if(position == 0){
|
|
||||||
tv.setTextColor(Color.GRAY);
|
|
||||||
} else {
|
|
||||||
tv.setTextColor(Color.BLACK);
|
|
||||||
}
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spinnerArrayAdapter.setDropDownViewResource(android.R.layout
|
|
||||||
.simple_spinner_dropdown_item);
|
|
||||||
spinnerTwoSpinner.setAdapter(spinnerArrayAdapter);
|
|
||||||
|
|
||||||
SpinnerInteractionListener listener = new SpinnerInteractionListener();
|
|
||||||
|
|
||||||
spinnerTwoSpinner.setOnItemSelectedListener(listener);
|
|
||||||
spinnerTwoSpinner.setOnTouchListener(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initialiseArrayString(){
|
|
||||||
taskList = getContext().getResources().getStringArray(R.array.task_list);
|
|
||||||
strings = new String[]{taskList[0], taskList[1]+product, taskList[2], taskList[3]};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public class SpinnerInteractionListener implements AdapterView.OnItemSelectedListener, View.OnTouchListener {
|
|
||||||
|
|
||||||
boolean userSelect = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
|
||||||
userSelect = true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
|
||||||
if (userSelect) {
|
|
||||||
Toast.makeText(getContext(), "current = " + pos, Toast.LENGTH_SHORT).show();
|
|
||||||
|
|
||||||
previous = current;
|
|
||||||
current = (String) parent.getItemAtPosition(pos);
|
|
||||||
|
|
||||||
if (pos == 1){
|
|
||||||
final EditText edittext = new EditText(getContext());
|
|
||||||
edittext.setHint("Product Harvested?");
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
|
||||||
builder.setView(edittext);
|
|
||||||
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
spinnerTwoSpinner.setSelection(getPosition(previous));
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
}).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
String text = edittext.getText().toString();
|
|
||||||
if (!TextUtils.isEmpty(text)){
|
|
||||||
product = " " + text;
|
|
||||||
initialiseArrayString();
|
|
||||||
setupSpinnerTwo();
|
|
||||||
spinnerTwoSpinner.setSelection(1);
|
|
||||||
}
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
}).setOnCancelListener(new DialogInterface.OnCancelListener() {
|
|
||||||
@Override
|
|
||||||
public void onCancel(DialogInterface dialog) {
|
|
||||||
dialogActive = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setCancelable(false).create().show();
|
|
||||||
}
|
|
||||||
|
|
||||||
userSelect = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getPosition(String previous){
|
|
||||||
int i = 0;
|
|
||||||
if (previous != null){
|
|
||||||
for (String s: strings){
|
|
||||||
if (previous.contains(s)){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.AddItems;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.Abn.AbnListAdapter;
|
|
||||||
import com.appttude.h_mal.days_left.Objects.TaskObject;
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
import com.google.android.gms.tasks.Task;
|
|
||||||
import com.google.firebase.database.DataSnapshot;
|
|
||||||
import com.google.firebase.database.DatabaseError;
|
|
||||||
import com.google.firebase.database.ValueEventListener;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import static com.appttude.h_mal.days_left.AddItems.AddShiftActivity.REQUEST;
|
|
||||||
import static com.appttude.h_mal.days_left.AddItems.AddShiftActivity.TASKREQUEST;
|
|
||||||
|
|
||||||
public class AssociatedTasksClass implements ValueEventListener {
|
|
||||||
|
|
||||||
private AddShiftActivity activity;
|
|
||||||
private ProgressBar progressBar;
|
|
||||||
|
|
||||||
public AssociatedTasksClass(AddShiftActivity activity, ProgressBar progressBar) {
|
|
||||||
this.activity = activity;
|
|
||||||
this.progressBar = progressBar;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
|
|
||||||
final ArrayList<TaskObject> taskObjects = new ArrayList<>();
|
|
||||||
|
|
||||||
for (DataSnapshot currentTask : dataSnapshot.getChildren()){
|
|
||||||
taskObjects.add(currentTask.getValue(TaskObject.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taskObjects.size() > 0){
|
|
||||||
|
|
||||||
LayoutInflater factory = LayoutInflater.from(activity);
|
|
||||||
final View dialogView = factory.inflate(R.layout.dialog_previous_abns_used, null);
|
|
||||||
|
|
||||||
ListView listView = dialogView.findViewById(R.id.list_item_list_dialog);
|
|
||||||
Button button = dialogView.findViewById(R.id.button_list_dialog);
|
|
||||||
|
|
||||||
DialogListAdapter dialogListAdapter = new DialogListAdapter(activity,taskObjects);
|
|
||||||
listView.setAdapter(dialogListAdapter);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
|
||||||
builder.setView(dialogView);
|
|
||||||
|
|
||||||
final AlertDialog alertDialog = builder.create();
|
|
||||||
alertDialog.show();
|
|
||||||
|
|
||||||
button.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
startActivity();
|
|
||||||
alertDialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
activity.taskObject = taskObjects.get(position);
|
|
||||||
activity.setTaskCard();
|
|
||||||
alertDialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
}else {
|
|
||||||
startActivity();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCancelled(@NonNull DatabaseError databaseError) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startActivity(){
|
|
||||||
Intent intent = new Intent(activity,AddItemActivity.class);
|
|
||||||
intent.putExtra(REQUEST,TASKREQUEST);
|
|
||||||
activity.startActivityForResult(intent,TASKREQUEST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.AddItems;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.media.Image;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.Abn.AbnObject;
|
|
||||||
import com.appttude.h_mal.days_left.Objects.TaskObject;
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class DialogListAdapter extends ArrayAdapter<TaskObject> {
|
|
||||||
|
|
||||||
public DialogListAdapter(@NonNull Context context, @NonNull List<TaskObject> objects) {
|
|
||||||
super(context, 0, objects);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
|
||||||
View view = convertView;
|
|
||||||
if (view == null){
|
|
||||||
view = LayoutInflater.from(getContext()).inflate(R.layout.task_list_item,parent, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
TaskObject currentTask = getItem(position);
|
|
||||||
|
|
||||||
TextView taskTextView = view.findViewById(R.id.task);
|
|
||||||
TextView summaryTextview = view.findViewById(R.id.task_summary);
|
|
||||||
ImageView taskImageView = view.findViewById(R.id.task_image);
|
|
||||||
|
|
||||||
taskTextView.setText(currentTask.getTask());
|
|
||||||
|
|
||||||
String summary = currentTask.getWorkType() + " - $" + currentTask.getRate()+ " /" ;
|
|
||||||
if (currentTask.getWorkType().equals("Piece Rate")){
|
|
||||||
summary = summary + "Unit";
|
|
||||||
taskImageView.setImageResource(R.drawable.piece);
|
|
||||||
}else {
|
|
||||||
summary = summary + "Hour";
|
|
||||||
taskImageView.setImageResource(R.drawable.task);
|
|
||||||
}
|
|
||||||
|
|
||||||
summaryTextview.setText(summary);
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.AddItems;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.TimePicker;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.Objects.TimeObject;
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
|
|
||||||
public class InsertTimeDialog{
|
|
||||||
|
|
||||||
Context context;
|
|
||||||
TimeObject timeObject;
|
|
||||||
OnDialogClickListener listener;
|
|
||||||
|
|
||||||
public interface OnDialogClickListener {
|
|
||||||
void onDialogImageRunClick(TimeObject timeObject);
|
|
||||||
|
|
||||||
void onClick(DialogInterface dialog, int which);
|
|
||||||
}
|
|
||||||
|
|
||||||
public InsertTimeDialog(Context context, @Nullable TimeObject timeObject, OnDialogClickListener listener) {
|
|
||||||
this.context = context;
|
|
||||||
this.timeObject = timeObject;
|
|
||||||
this.listener = listener;
|
|
||||||
|
|
||||||
DialogTime dialogTime = new DialogTime(context);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class DialogTime extends AlertDialog.Builder{
|
|
||||||
|
|
||||||
|
|
||||||
private TimePicker timePickerTimePicker;
|
|
||||||
private TextView startTimeTextView;
|
|
||||||
private TextView finishTimeTextView;
|
|
||||||
private EditText breakEditText;
|
|
||||||
|
|
||||||
public DialogTime(Context context) {
|
|
||||||
super(context);
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public DialogTime(Context context, int themeResId) {
|
|
||||||
super(context, themeResId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init(){
|
|
||||||
setView(null);
|
|
||||||
setNegativeButton(null,null);
|
|
||||||
setPositiveButton(null,null);
|
|
||||||
|
|
||||||
|
|
||||||
AlertDialog alertDialog = create();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AlertDialog.Builder setView(View view) {
|
|
||||||
view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_search_employer, null);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
startTimeTextView.setTag("start");
|
|
||||||
finishTimeTextView.setTag("finish");
|
|
||||||
|
|
||||||
startTimeTextView.setOnClickListener(timeSelect);
|
|
||||||
finishTimeTextView.setOnClickListener(timeSelect);
|
|
||||||
|
|
||||||
return super.setView(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
View.OnClickListener timeSelect = new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
String currentTag = (String) v.getTag();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AlertDialog create() {
|
|
||||||
return super.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AlertDialog.Builder setNegativeButton(int textId, DialogInterface.OnClickListener listener) {
|
|
||||||
return super.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AlertDialog.Builder setPositiveButton(CharSequence text, final DialogInterface.OnClickListener listener) {
|
|
||||||
return super.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.AddItems;
|
|
||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.arch.lifecycle.ViewModelProvider;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.text.Layout;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.Abn.AbnListAdapter;
|
|
||||||
import com.appttude.h_mal.days_left.Abn.AbnObject;
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
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 java.util.ArrayList;
|
|
||||||
|
|
||||||
import static com.appttude.h_mal.days_left.AddItems.AddShiftActivity.EMPLOYERREQUEST;
|
|
||||||
import static com.appttude.h_mal.days_left.AddItems.AddShiftActivity.REQUEST;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.EMPLOYER_FIREBASE;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.USER_FIREBASE;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.auth;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.mDatabase;
|
|
||||||
|
|
||||||
public class PreviouslyUsedItemsClass implements ValueEventListener {
|
|
||||||
|
|
||||||
private ProgressBar progressBar;
|
|
||||||
private AddShiftActivity activity;
|
|
||||||
|
|
||||||
public PreviouslyUsedItemsClass(ProgressBar progressBar, AddShiftActivity activity) {
|
|
||||||
this.progressBar = progressBar;
|
|
||||||
this.activity = activity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
|
|
||||||
final ArrayList<String> strings = new ArrayList<>();
|
|
||||||
final ArrayList<AbnObject> abnObjectArrayList = new ArrayList<>();
|
|
||||||
|
|
||||||
for (DataSnapshot currentItem : dataSnapshot.getChildren()){
|
|
||||||
strings.add(currentItem.getKey());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
DatabaseReference abnListRef = mDatabase.child(EMPLOYER_FIREBASE);
|
|
||||||
abnListRef.addListenerForSingleValueEvent(new ValueEventListener() {
|
|
||||||
@Override
|
|
||||||
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
|
|
||||||
for (DataSnapshot currentItem : dataSnapshot.getChildren()){
|
|
||||||
AbnObject currentAbnObject = currentItem.getValue(AbnObject.class);
|
|
||||||
abnObjectArrayList.add(currentAbnObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (abnObjectArrayList.size() > 0){
|
|
||||||
|
|
||||||
LayoutInflater factory = LayoutInflater.from(activity);
|
|
||||||
final View dialogView = factory.inflate(R.layout.dialog_previous_abns_used, null);
|
|
||||||
|
|
||||||
ListView listView = dialogView.findViewById(R.id.list_item_list_dialog);
|
|
||||||
Button button = dialogView.findViewById(R.id.button_list_dialog);
|
|
||||||
|
|
||||||
AbnListAdapter abnListAdapter = new AbnListAdapter(activity,abnObjectArrayList);
|
|
||||||
listView.setAdapter(abnListAdapter);
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
|
||||||
builder.setView(dialogView);
|
|
||||||
|
|
||||||
final AlertDialog alertDialog = builder.create();
|
|
||||||
alertDialog.show();
|
|
||||||
|
|
||||||
button.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
startActivity();
|
|
||||||
alertDialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
activity.abnObject = abnObjectArrayList.get(position);
|
|
||||||
activity.setEmployerCard();
|
|
||||||
alertDialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
}else {
|
|
||||||
startActivity();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCancelled(@NonNull DatabaseError databaseError) {
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCancelled(@NonNull DatabaseError databaseError) {
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
Toast.makeText(activity, "Could not load ", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startActivity(){
|
|
||||||
Intent intent = new Intent(activity,AddItemActivity.class);
|
|
||||||
intent.putExtra(REQUEST,EMPLOYERREQUEST);
|
|
||||||
activity.startActivityForResult(intent,EMPLOYERREQUEST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,144 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.AddItems;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.Abn.AbnListAdapter;
|
|
||||||
import com.appttude.h_mal.days_left.Abn.AbnObject;
|
|
||||||
import com.appttude.h_mal.days_left.Global.FirebaseClass;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static com.appttude.h_mal.days_left.Abn.SearchAbnRecords.ExtractFeatureFromAbnJson;
|
|
||||||
import static com.appttude.h_mal.days_left.Abn.SearchAbnRecords.ExtractFeatureFromNameJson;
|
|
||||||
import static com.appttude.h_mal.days_left.Abn.SearchAbnRecords.makeHttpRequest;
|
|
||||||
|
|
||||||
public class SearchAsyncTask extends AsyncTask<URL,Void,String>{
|
|
||||||
|
|
||||||
private Activity activity;
|
|
||||||
|
|
||||||
private ListView listView;
|
|
||||||
private LinearLayout linearLayout;
|
|
||||||
private ProgressBar progressBar;
|
|
||||||
private boolean abn;
|
|
||||||
|
|
||||||
OnTaskCompleted onTaskCompleted;
|
|
||||||
|
|
||||||
public interface OnTaskCompleted{
|
|
||||||
void onTaskCompleted(String s);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SearchAsyncTask(Activity activity, ListView listView, LinearLayout linearLayout, ProgressBar progressBar, boolean abn) {
|
|
||||||
this.activity = activity;
|
|
||||||
this.listView = listView;
|
|
||||||
this.linearLayout = linearLayout;
|
|
||||||
this.progressBar = progressBar;
|
|
||||||
this.abn = abn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SearchAsyncTask(OnTaskCompleted onTaskCompleted) {
|
|
||||||
this.onTaskCompleted = onTaskCompleted;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPreExecute() {
|
|
||||||
super.onPreExecute();
|
|
||||||
if (progressBar != null){
|
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
|
||||||
linearLayout.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String doInBackground(URL... urls) {
|
|
||||||
String jsonResponse = null;
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
jsonResponse = makeHttpRequest(urls[0]);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return jsonResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPostExecute(String s) {
|
|
||||||
super.onPostExecute(s);
|
|
||||||
if (progressBar != null){
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
final List<AbnObject> abnObjectArrayList;
|
|
||||||
|
|
||||||
if (s.contains("callback")){
|
|
||||||
s = s.replace("callback(","");
|
|
||||||
s.substring(0,s.length()-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.i("URL", "onPostExecute: " + s);
|
|
||||||
|
|
||||||
if (abn){
|
|
||||||
abnObjectArrayList = ExtractFeatureFromAbnJson(s);
|
|
||||||
}else {
|
|
||||||
abnObjectArrayList = ExtractFeatureFromNameJson(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (abnObjectArrayList != null && abnObjectArrayList.size() > 0){
|
|
||||||
linearLayout.setVisibility(View.GONE);
|
|
||||||
listView.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
Log.i("URL", "onPostExecute: executed");
|
|
||||||
listView.setAdapter(new AbnListAdapter(activity,abnObjectArrayList));
|
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
AbnObject currentAbnObject = abnObjectArrayList.get(position);
|
|
||||||
|
|
||||||
Toast.makeText(activity, "AHHHHHHH", Toast.LENGTH_SHORT).show();
|
|
||||||
|
|
||||||
final Intent returnIntent = new Intent();
|
|
||||||
returnIntent.putExtra("AbnObject",currentAbnObject);
|
|
||||||
new FirebaseClass().newAbnEntry(currentAbnObject.getAbn(), new FirebaseClass.matchListener() {
|
|
||||||
@Override
|
|
||||||
public void abnMatch(Boolean confirm) {
|
|
||||||
if (!confirm){
|
|
||||||
//push to server
|
|
||||||
activity.setResult(Activity.RESULT_OK,returnIntent);
|
|
||||||
activity.finish();
|
|
||||||
}else {
|
|
||||||
activity.setResult(Activity.RESULT_OK,returnIntent);
|
|
||||||
activity.finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}else if (abnObjectArrayList == null){
|
|
||||||
linearLayout.setVisibility(View.VISIBLE);
|
|
||||||
listView.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
onTaskCompleted.onTaskCompleted(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.AddItems;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.support.design.widget.TabLayout;
|
|
||||||
import android.support.v4.app.DialogFragment;
|
|
||||||
import android.text.InputFilter;
|
|
||||||
import android.text.InputType;
|
|
||||||
import android.text.Layout;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.view.animation.AnimationUtils;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.ListView;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.Abn.AbnListAdapter;
|
|
||||||
import com.appttude.h_mal.days_left.Abn.AbnObject;
|
|
||||||
import com.appttude.h_mal.days_left.Abn.SearchAbnRecords;
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.zip.Inflater;
|
|
||||||
|
|
||||||
import static android.content.DialogInterface.BUTTON_NEGATIVE;
|
|
||||||
import static android.content.DialogInterface.BUTTON_POSITIVE;
|
|
||||||
import static com.appttude.h_mal.days_left.Abn.SearchAbnRecords.ExtractFeatureFromAbnJson;
|
|
||||||
import static com.appttude.h_mal.days_left.Abn.SearchAbnRecords.ExtractFeatureFromNameJson;
|
|
||||||
import static com.appttude.h_mal.days_left.Abn.SearchAbnRecords.makeHttpRequest;
|
|
||||||
|
|
||||||
public class SearchEmployerDialogFragment extends DialogFragment implements DialogInterface.OnClickListener {
|
|
||||||
|
|
||||||
private String TAG = this.getClass().getSimpleName();
|
|
||||||
|
|
||||||
private EditText searchText;
|
|
||||||
private TabLayout tableLayout;
|
|
||||||
private static Boolean abn;
|
|
||||||
private SearchAbnRecords abnRecords;
|
|
||||||
private ListView listView;
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LayoutInflater Inflater = getActivity().getLayoutInflater();
|
|
||||||
View view = Inflater.inflate(R.layout.dialog_search_employer, null);
|
|
||||||
|
|
||||||
tableLayout = view.findViewById(R.id.tab_layout);
|
|
||||||
tableLayout.addOnTabSelectedListener(tabSelectedListener);
|
|
||||||
searchText = view.findViewById(R.id.search_edittext);
|
|
||||||
|
|
||||||
abnRecords = new SearchAbnRecords();
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
|
||||||
builder.setView(view);
|
|
||||||
builder.setNegativeButton(android.R.string.cancel,this);
|
|
||||||
builder.setPositiveButton(android.R.string.ok,this);
|
|
||||||
builder.setTitle("Search via:");
|
|
||||||
|
|
||||||
AlertDialog alertDialog = builder.create();
|
|
||||||
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
|
||||||
|
|
||||||
return builder.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
if (which == BUTTON_POSITIVE){
|
|
||||||
String searchTerm = searchText.getText().toString().trim();
|
|
||||||
|
|
||||||
URL callUrl;
|
|
||||||
|
|
||||||
if (abn){
|
|
||||||
callUrl = abnRecords.searchViaAbn(searchTerm);
|
|
||||||
}else {
|
|
||||||
callUrl = abnRecords.searchViaName(searchTerm);
|
|
||||||
}
|
|
||||||
|
|
||||||
GetCompanies task = new GetCompanies(getContext(),listView);
|
|
||||||
task.execute(callUrl);
|
|
||||||
|
|
||||||
}else{
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TabLayout.OnTabSelectedListener tabSelectedListener = new TabLayout.OnTabSelectedListener() {
|
|
||||||
@Override
|
|
||||||
public void onTabSelected(TabLayout.Tab tab) {
|
|
||||||
Log.i(TAG, "onTabSelected: " + tab.getText());
|
|
||||||
if (tab.getText() == "A.B.N"){
|
|
||||||
searchText.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.fade_in));
|
|
||||||
searchText.setHint("Search via A.B.N");
|
|
||||||
searchText.setInputType(InputType.TYPE_NUMBER_VARIATION_NORMAL);
|
|
||||||
searchText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(11)});
|
|
||||||
abn = true;
|
|
||||||
}else{
|
|
||||||
searchText.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.fade_in));
|
|
||||||
searchText.setHint("Search via Name");
|
|
||||||
searchText.setInputType(InputType.TYPE_TEXT_VARIATION_NORMAL);
|
|
||||||
searchText.setFilters(new InputFilter[] {});
|
|
||||||
abn = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTabUnselected(TabLayout.Tab tab) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTabReselected(TabLayout.Tab tab) {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static class GetCompanies extends AsyncTask<URL,Void,String> {
|
|
||||||
|
|
||||||
private Context context;
|
|
||||||
private ListView listView;
|
|
||||||
|
|
||||||
public GetCompanies(Context context, ListView listView) {
|
|
||||||
this.context = context;
|
|
||||||
this.listView = listView;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String doInBackground(URL... urls) {
|
|
||||||
String jsonResponse = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
jsonResponse = makeHttpRequest(urls[0]);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return jsonResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPostExecute(String s) {
|
|
||||||
super.onPostExecute(s);
|
|
||||||
|
|
||||||
List<AbnObject> abnObjectArrayList;
|
|
||||||
|
|
||||||
if (s.contains("callback")){
|
|
||||||
s = s.substring(8,s.length());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (abn){
|
|
||||||
abnObjectArrayList = ExtractFeatureFromAbnJson(s);
|
|
||||||
}else {
|
|
||||||
abnObjectArrayList = ExtractFeatureFromNameJson(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (abnObjectArrayList != null){
|
|
||||||
listView.setAdapter(new AbnListAdapter(context,abnObjectArrayList));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.AddItems;
|
|
||||||
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.support.v4.app.DialogFragment;
|
|
||||||
|
|
||||||
public class SelectEmployerDialog extends Dialog {
|
|
||||||
|
|
||||||
public SelectEmployerDialog(@NonNull Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SelectEmployerDialog(@NonNull Context context, int themeResId) {
|
|
||||||
super(context, themeResId);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected SelectEmployerDialog(@NonNull Context context, boolean cancelable, @Nullable DialogInterface.OnCancelListener cancelListener) {
|
|
||||||
super(context, cancelable, cancelListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v4.app.FragmentManager;
|
|
||||||
import android.support.v4.app.FragmentTransaction;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.Objects.ShiftObject;
|
|
||||||
import com.google.firebase.database.DataSnapshot;
|
|
||||||
import com.google.firebase.database.DatabaseError;
|
|
||||||
import com.google.firebase.database.ValueEventListener;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static com.appttude.h_mal.days_left.MainActivity.shiftObjectArrayList;
|
|
||||||
import static com.appttude.h_mal.days_left.MainActivity.shiftsMap;
|
|
||||||
|
|
||||||
public class CustomValueEventListener implements ValueEventListener {
|
|
||||||
|
|
||||||
private Context context;
|
|
||||||
private FragmentManager fragmentManager;
|
|
||||||
private ProgressBar progressBar;
|
|
||||||
|
|
||||||
public CustomValueEventListener(Context context, FragmentManager fragmentManager, ProgressBar progressBar) {
|
|
||||||
this.context = context;
|
|
||||||
this.fragmentManager = fragmentManager;
|
|
||||||
this.progressBar = progressBar;
|
|
||||||
|
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
|
|
||||||
|
|
||||||
for (DataSnapshot postSnapshot: dataSnapshot.getChildren()) {
|
|
||||||
shiftObjectArrayList.add(postSnapshot.getValue(ShiftObject.class));
|
|
||||||
shiftsMap.put(postSnapshot.getKey(),postSnapshot.getValue(ShiftObject.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
// shiftObjectArrayList.stream().filter()
|
|
||||||
|
|
||||||
if (shiftObjectArrayList.size() > 0){
|
|
||||||
if (fragmentManager.getFragments().size() == 0){
|
|
||||||
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
|
||||||
fragmentTransaction.replace(R.id.container,new FragmentHome()).commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
}else {
|
|
||||||
Toast.makeText(context, "List Empty", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCancelled(@NonNull DatabaseError databaseError) {
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,227 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.graphics.Typeface;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.animation.Animation;
|
|
||||||
import android.view.animation.AnimationUtils;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.DatePicker;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.Abn.AbnListAdapter;
|
|
||||||
import com.appttude.h_mal.days_left.Abn.AbnObject;
|
|
||||||
import com.appttude.h_mal.days_left.Objects.ShiftObject;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.zip.Inflater;
|
|
||||||
|
|
||||||
public class FilterDialogClass extends AlertDialog {
|
|
||||||
|
|
||||||
private FilterDialogClickListener listener;
|
|
||||||
private TextView fromButton;
|
|
||||||
private TextView toButton;
|
|
||||||
private DatePicker datePicker;
|
|
||||||
|
|
||||||
private String dateSelectionFrom;
|
|
||||||
private String dateSelectionTo;
|
|
||||||
|
|
||||||
private String currentTag = "from";
|
|
||||||
|
|
||||||
protected FilterDialogClass(@NonNull Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected FilterDialogClass(@NonNull Context context, int selection, FilterDialogClickListener listener) {
|
|
||||||
super(context);
|
|
||||||
init(selection);
|
|
||||||
|
|
||||||
this.listener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void init(int selection){
|
|
||||||
View view;
|
|
||||||
if (selection == 0){
|
|
||||||
view = viewOne();
|
|
||||||
}else {
|
|
||||||
view = viewTwo();
|
|
||||||
}
|
|
||||||
|
|
||||||
setView(view);
|
|
||||||
setButton(BUTTON_NEGATIVE, getContext().getResources().getString(android.R.string.cancel), new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public View viewOne(){
|
|
||||||
View view = View.inflate(getContext(),R.layout.dialog_previous_abns_used,null);
|
|
||||||
|
|
||||||
final ListView listView = view.findViewById(R.id.list_item_list_dialog);
|
|
||||||
view.findViewById(R.id.button_list_dialog).setVisibility(View.GONE);
|
|
||||||
|
|
||||||
Map<String, AbnObject> mappedList = new HashMap<>();
|
|
||||||
|
|
||||||
for(ShiftObject shiftObject : MainActivity.shiftObjectArrayList){
|
|
||||||
mappedList.put(shiftObject.getAbnObject().getAbn(),shiftObject.getAbnObject());
|
|
||||||
}
|
|
||||||
|
|
||||||
final List<AbnObject> abnObjectList = new ArrayList<>(mappedList.values());
|
|
||||||
|
|
||||||
listView.setAdapter(new AbnListAdapter(getContext(),abnObjectList));
|
|
||||||
|
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
String currentAbn = abnObjectList.get(position).getAbn();
|
|
||||||
|
|
||||||
listener.applyAbn(currentAbn);
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
public View viewTwo(){
|
|
||||||
View view = View.inflate(getContext(),R.layout.date_selector_dialog,null);
|
|
||||||
|
|
||||||
fromButton = view.findViewById(R.id.from_date);
|
|
||||||
toButton = view.findViewById(R.id.to_date);
|
|
||||||
datePicker = view.findViewById(R.id.date_picker);
|
|
||||||
|
|
||||||
fromButton.setOnClickListener(onClickListener);
|
|
||||||
toButton.setOnClickListener(onClickListener);
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
||||||
datePicker.setOnDateChangedListener(dateChangedListener);
|
|
||||||
}else{
|
|
||||||
datePicker.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleTextButtons(true);
|
|
||||||
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
String dateString = retrieveDateString(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) +1, calendar.get(Calendar.DAY_OF_MONTH));
|
|
||||||
|
|
||||||
dateSelectionFrom = dateString;
|
|
||||||
dateSelectionTo = dateString;
|
|
||||||
|
|
||||||
setButton(BUTTON_POSITIVE, getContext().getResources().getString(android.R.string.yes), new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
//interface results back
|
|
||||||
if (!dateSelectionFrom.equals(dateSelectionTo)){
|
|
||||||
listener.applyDates(dateSelectionFrom,dateSelectionTo);
|
|
||||||
}
|
|
||||||
|
|
||||||
Toast.makeText(getContext(), dateSelectionFrom + " - " + dateSelectionTo, Toast.LENGTH_SHORT).show();
|
|
||||||
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface FilterDialogClickListener {
|
|
||||||
void applyDates(String arg1,String arg2);
|
|
||||||
|
|
||||||
void applyAbn(String abn);
|
|
||||||
}
|
|
||||||
|
|
||||||
DatePicker.OnDateChangedListener dateChangedListener = new DatePicker.OnDateChangedListener() {
|
|
||||||
@Override
|
|
||||||
public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
|
|
||||||
monthOfYear = monthOfYear + 1;
|
|
||||||
if (currentTag.equals("from")){
|
|
||||||
dateSelectionFrom = retrieveDateString(year, monthOfYear, dayOfMonth);
|
|
||||||
}else {
|
|
||||||
dateSelectionTo = retrieveDateString(year, monthOfYear, dayOfMonth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
View.OnClickListener onClickListener = new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
currentTag = (String) v.getTag();
|
|
||||||
|
|
||||||
if (currentTag.equals("from")){
|
|
||||||
toggleTextButtons(true);
|
|
||||||
setDateOnDatePicker(dateSelectionFrom);
|
|
||||||
|
|
||||||
}else {
|
|
||||||
toggleTextButtons(false);
|
|
||||||
setDateOnDatePicker(dateSelectionTo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private String retrieveDateString(int year, int monthOfYear, int dayOfMonth){
|
|
||||||
DecimalFormat mFormat= new DecimalFormat("00");
|
|
||||||
|
|
||||||
String monthString = mFormat.format(monthOfYear );
|
|
||||||
String dayString = mFormat.format(dayOfMonth);
|
|
||||||
|
|
||||||
return year + "-" + monthString + "-" + dayString;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setDateOnDatePicker(String dateString){
|
|
||||||
/* 2019-06-04 */
|
|
||||||
int year = Integer.parseInt(dateString.substring(0,4));
|
|
||||||
int month = Integer.parseInt(dateString.substring(5,7)) - 1;
|
|
||||||
int day = Integer.parseInt(dateString.substring(8));
|
|
||||||
|
|
||||||
datePicker.init(year,month,day,dateChangedListener);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void toggleTextButtons(boolean top){
|
|
||||||
setFadeAnimation(fromButton);
|
|
||||||
setFadeAnimation(toButton);
|
|
||||||
|
|
||||||
if (top){
|
|
||||||
fromButton.setTypeface(null, Typeface.BOLD);
|
|
||||||
toButton.setTypeface(null, Typeface.NORMAL);
|
|
||||||
|
|
||||||
fromButton.setBackgroundColor(getContext().getResources().getColor(R.color.one));
|
|
||||||
toButton.setBackgroundColor(getContext().getResources().getColor(android.R.color.white));
|
|
||||||
}else {
|
|
||||||
toButton.setTypeface(null, Typeface.BOLD);
|
|
||||||
fromButton.setTypeface(null, Typeface.NORMAL);
|
|
||||||
|
|
||||||
toButton.setBackgroundColor(getContext().getResources().getColor(R.color.one));
|
|
||||||
fromButton.setBackgroundColor(getContext().getResources().getColor(android.R.color.white));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setFadeAnimation(View view){
|
|
||||||
Animation bottomUp = AnimationUtils.loadAnimation(getContext(),
|
|
||||||
R.anim.fade_in);
|
|
||||||
|
|
||||||
view.setAnimation(bottomUp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.Filter;
|
|
||||||
import android.widget.Filterable;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.Objects.ShiftObject;
|
|
||||||
import com.appttude.h_mal.days_left.Objects.TaskObject;
|
|
||||||
import com.appttude.h_mal.days_left.Objects.TimeObject;
|
|
||||||
import com.firebase.ui.database.FirebaseListAdapter;
|
|
||||||
import com.google.firebase.database.DataSnapshot;
|
|
||||||
import com.google.firebase.database.DatabaseReference;
|
|
||||||
import com.google.firebase.database.Query;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
class FireAdapter extends FirebaseListAdapter<ShiftObject>{
|
|
||||||
|
|
||||||
String TAG = "FireAdapter";
|
|
||||||
|
|
||||||
List<ShiftObject> shiftObjects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param activity The activity containing the ListView
|
|
||||||
* @param modelClass Firebase will marshall the data at a location into
|
|
||||||
* an instance of a class that you provide
|
|
||||||
* @param modelLayout This is the layout used to represent a single list item.
|
|
||||||
* You will be responsible for populating an instance of the corresponding
|
|
||||||
* view with the data from an instance of modelClass.
|
|
||||||
* @param ref The Firebase location to watch for data changes. Can also be a slice of a location,
|
|
||||||
* using some combination of {@code limit()}, {@code startAt()}, and {@code endAt()}.
|
|
||||||
*/
|
|
||||||
public FireAdapter(Activity activity, Class<ShiftObject> modelClass, int modelLayout, Query ref) {
|
|
||||||
super(activity, modelClass, modelLayout, ref);
|
|
||||||
shiftObjects = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void populateView(View listItemView, ShiftObject currentShift, final int position) {
|
|
||||||
|
|
||||||
TextView farmNameTextView = listItemView.findViewById(R.id.farm_name);
|
|
||||||
TextView dateTextView = listItemView.findViewById(R.id.date);
|
|
||||||
TextView tastTextView = listItemView.findViewById(R.id.task_name);
|
|
||||||
TextView typeTextView = listItemView.findViewById(R.id.type);
|
|
||||||
LinearLayout timeHolderLinearLayout = listItemView.findViewById(R.id.time_holder);
|
|
||||||
TextView timeTextView = listItemView.findViewById(R.id.time);
|
|
||||||
LinearLayout breakHolderLinearLayout = listItemView.findViewById(R.id.break_holder);
|
|
||||||
TextView breakTimeTextView = listItemView.findViewById(R.id.break_time);
|
|
||||||
LinearLayout unitsHolderLinearLayout = listItemView.findViewById(R.id.units_holder);
|
|
||||||
TextView unitsTextView = listItemView.findViewById(R.id.units);
|
|
||||||
TextView locationTextView = listItemView.findViewById(R.id.location);
|
|
||||||
|
|
||||||
dateTextView.setText(currentShift.getShiftDate());
|
|
||||||
|
|
||||||
TaskObject taskObject = currentShift.getTaskObject();
|
|
||||||
tastTextView.setText(taskObject.getTask());
|
|
||||||
String s = taskObject.getWorkType() + " - $" + taskObject.getRate() + "/";
|
|
||||||
if (taskObject.getWorkType().equals("Hourly")){
|
|
||||||
s = s + "Hour";
|
|
||||||
timeHolderLinearLayout.setVisibility(View.VISIBLE);
|
|
||||||
unitsHolderLinearLayout.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
TimeObject timeObject = currentShift.getTimeObject();
|
|
||||||
|
|
||||||
timeTextView.setText(timeObject.getTimeIn() + " - " + timeObject.getTimeOut());
|
|
||||||
|
|
||||||
if (timeObject.getBreakEpoch() > 0){
|
|
||||||
breakHolderLinearLayout.setVisibility(View.VISIBLE);
|
|
||||||
String breakString = getBreakTimeString(timeObject.getBreakEpoch());
|
|
||||||
breakTimeTextView.setText(breakString);
|
|
||||||
}else {
|
|
||||||
breakHolderLinearLayout.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
unitsTextView.setText(String.valueOf(timeObject.getHours()));
|
|
||||||
|
|
||||||
}else {
|
|
||||||
s = s + "Unit";
|
|
||||||
timeHolderLinearLayout.setVisibility(View.GONE);
|
|
||||||
unitsHolderLinearLayout.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
unitsTextView.setText(String.valueOf(currentShift.getUnitsCount()));
|
|
||||||
}
|
|
||||||
|
|
||||||
typeTextView.setText(s);
|
|
||||||
farmNameTextView.setText(currentShift.getAbnObject().getCompanyName());
|
|
||||||
|
|
||||||
locationTextView.setText(currentShift.getAbnObject().getState() + " - " + currentShift.getAbnObject().getPostCode());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId(int i){
|
|
||||||
return getRef(i).getKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ShiftObject parseSnapshot(DataSnapshot snapshot) {
|
|
||||||
shiftObjects.add(snapshot.getValue(ShiftObject.class));
|
|
||||||
return super.parseSnapshot(snapshot);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private String getBreakTimeString(int breakMins){
|
|
||||||
float hoursFloat = breakMins/60;
|
|
||||||
|
|
||||||
int hoursInt = (int) Math.floor(hoursFloat);
|
|
||||||
int minsInt = breakMins - (hoursInt*60);
|
|
||||||
|
|
||||||
String s = "";
|
|
||||||
if (hoursInt > 0){
|
|
||||||
s = hoursInt + " h" + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (minsInt > 0){
|
|
||||||
s = s + minsInt + " m";
|
|
||||||
}
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package com.appttude.h_mal.days_left
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.view.View
|
||||||
|
import com.appttude.h_mal.days_left.models.ShiftObject
|
||||||
|
import com.firebase.ui.database.FirebaseListAdapter
|
||||||
|
import com.google.firebase.database.Query
|
||||||
|
import kotlinx.android.synthetic.main.list_item.view.*
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,253 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
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 com.appttude.h_mal.days_left.Objects.ShiftObject;
|
|
||||||
import com.appttude.h_mal.days_left.arc.ArcAnimation;
|
|
||||||
import com.appttude.h_mal.days_left.arc.CircleView;
|
|
||||||
import com.appttude.h_mal.days_left.bar.BarAnimation;
|
|
||||||
import com.appttude.h_mal.days_left.bar.BarView;
|
|
||||||
import com.firebase.ui.database.FirebaseRecyclerAdapter;
|
|
||||||
import com.google.firebase.database.DataSnapshot;
|
|
||||||
import com.google.firebase.database.DatabaseReference;
|
|
||||||
import com.google.firebase.database.Query;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class FireRecyclerAdapter extends FirebaseRecyclerAdapter<ShiftObject,RecyclerView.ViewHolder> {
|
|
||||||
|
|
||||||
private String TAG = "FireRecyclerAdapter";
|
|
||||||
private Context context;
|
|
||||||
private List<ShiftObject> shiftObjectList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param modelClass Firebase will marshall the data at a location into
|
|
||||||
* an instance of a class that you provide
|
|
||||||
* @param modelLayout This is the layout used to represent a single item in the list.
|
|
||||||
* You will be responsible for populating an instance of the corresponding
|
|
||||||
* view with the data from an instance of modelClass.
|
|
||||||
* @param viewHolderClass The class that hold references to all sub-views in an instance modelLayout.
|
|
||||||
* @param ref The Firebase location to watch for data changes. Can also be a slice of a location,
|
|
||||||
* using some combination of {@code limit()}, {@code startAt()}, and {@code endAt()}.
|
|
||||||
*/
|
|
||||||
public FireRecyclerAdapter(Class<ShiftObject> modelClass, int modelLayout, Class<RecyclerView.ViewHolder> viewHolderClass, Query ref, Context context) {
|
|
||||||
super(modelClass, modelLayout, viewHolderClass, ref);
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
|
||||||
switch (i) {
|
|
||||||
case 1:
|
|
||||||
final View itemOne = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_one, viewGroup, false);
|
|
||||||
return new FireRecyclerAdapter.ItemOne(itemOne);
|
|
||||||
case 2:
|
|
||||||
final View itemTwo = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_two, viewGroup, false);
|
|
||||||
return new FireRecyclerAdapter.ItemTwo(itemTwo);
|
|
||||||
case 3:
|
|
||||||
final View itemThree = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_three, viewGroup, false);
|
|
||||||
return new FireRecyclerAdapter.ItemThree(itemThree);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void populateViewHolder(RecyclerView.ViewHolder viewHolder, ShiftObject model, int i) {
|
|
||||||
switch (viewHolder.getItemViewType()) {
|
|
||||||
case 1:
|
|
||||||
final FireRecyclerAdapter.ItemOne viewHolderCurrent = (FireRecyclerAdapter.ItemOne) viewHolder;
|
|
||||||
|
|
||||||
CircleView arcView = viewHolderCurrent.arc;
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
arcView.setPaintColor(context.getColor(R.color.two));
|
|
||||||
}
|
|
||||||
|
|
||||||
int days = 76;
|
|
||||||
|
|
||||||
int complete = (360 * days) / 88;
|
|
||||||
|
|
||||||
viewHolderCurrent.days.setText(String.valueOf(days));
|
|
||||||
|
|
||||||
ArcAnimation animation = new ArcAnimation(arcView, complete);
|
|
||||||
animation.setDuration(600);
|
|
||||||
arcView.startAnimation(animation);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
final FireRecyclerAdapter.ItemTwo viewTwo = (FireRecyclerAdapter.ItemTwo) viewHolder;
|
|
||||||
|
|
||||||
final BarView barView = viewTwo.barView;
|
|
||||||
final LinearLayout linearLayout = viewTwo.linearLayout;
|
|
||||||
|
|
||||||
barView.setCover(0.56f);
|
|
||||||
|
|
||||||
barView.setColourOne(context.getResources().getColor(R.color.four));
|
|
||||||
barView.setColourTwo(context.getResources().getColor(R.color.three));
|
|
||||||
|
|
||||||
// viewTwo.textholder.setPadding(60,0,60,0);
|
|
||||||
// viewTwo.bottomTextholder.setPadding(60,0,60,0);
|
|
||||||
|
|
||||||
linearLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
Log.i(TAG, "onGlobalLayout: " + linearLayout.getWidth());
|
|
||||||
|
|
||||||
BarAnimation barAnimation = new BarAnimation(barView, linearLayout.getWidth(), 0);
|
|
||||||
barAnimation.setDuration(600);
|
|
||||||
barView.setAnimation(barAnimation);
|
|
||||||
linearLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
final FireRecyclerAdapter.ItemThree viewCounting = (FireRecyclerAdapter.ItemThree) viewHolder;
|
|
||||||
|
|
||||||
TextView cardTitle = viewCounting.cardTitle;
|
|
||||||
ImageView cardIcon = viewCounting.cardIcon;
|
|
||||||
TextView units = viewCounting.units;
|
|
||||||
TextView totalEarned = viewCounting.totalEarned;
|
|
||||||
LinearLayout top = viewCounting.textholderTop;
|
|
||||||
LinearLayout bottom = viewCounting.textholderBottom;
|
|
||||||
|
|
||||||
// top.setPadding(60,0,60,0);
|
|
||||||
// bottom.setPadding(60,0,60,0);
|
|
||||||
// cardIcon.setPadding(0,0,10,0);
|
|
||||||
|
|
||||||
if (i == 2) {
|
|
||||||
cardTitle.setText("Hourly");
|
|
||||||
cardIcon.setImageResource(R.drawable.clock_icon);
|
|
||||||
units.setText("296" + "Hours");
|
|
||||||
totalEarned.setText("$" + "907.53");
|
|
||||||
}
|
|
||||||
if (i == 3) {
|
|
||||||
cardTitle.setText("Piece");
|
|
||||||
cardTitle.setTextColor(context.getResources().getColor(R.color.three));
|
|
||||||
cardIcon.setImageResource(R.drawable.piece);
|
|
||||||
cardIcon.setRotation(270);
|
|
||||||
units.setText("180" + "Pcs");
|
|
||||||
totalEarned.setText("$" + "67.53");
|
|
||||||
}
|
|
||||||
if (i == 4) {
|
|
||||||
cardTitle.setVisibility(View.GONE);
|
|
||||||
cardIcon.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
totalEarned.setText("$" + "974.53");
|
|
||||||
|
|
||||||
viewCounting.textholderTop.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
Log.i(TAG, "getItemCount: " +super.getItemCount());
|
|
||||||
if (super.getItemCount() == 0){
|
|
||||||
return super.getItemCount();
|
|
||||||
}else {
|
|
||||||
return 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemViewType(int position) {
|
|
||||||
int type = 0;
|
|
||||||
|
|
||||||
switch (position){
|
|
||||||
case 0:
|
|
||||||
type = 1;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
type = 2;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
type = 3;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
type = 3;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
type = 3;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ShiftObject parseSnapshot(DataSnapshot snapshot) {
|
|
||||||
shiftObjectList = new ArrayList<>();
|
|
||||||
shiftObjectList.add(snapshot.getValue(ShiftObject.class));
|
|
||||||
|
|
||||||
return super.parseSnapshot(snapshot);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ItemOne extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
CircleView arc;
|
|
||||||
TextView days;
|
|
||||||
|
|
||||||
public ItemOne(View itemView){
|
|
||||||
super(itemView);
|
|
||||||
arc = itemView.findViewById(R.id.arc_view);
|
|
||||||
days = itemView.findViewById(R.id.days_completed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ItemTwo extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
BarView barView;
|
|
||||||
LinearLayout linearLayout;
|
|
||||||
|
|
||||||
public ItemTwo(View itemView){
|
|
||||||
super(itemView);
|
|
||||||
|
|
||||||
barView = itemView.findViewById(R.id.bar);
|
|
||||||
linearLayout = itemView.findViewById(R.id.lin);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ItemThree extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
private TextView cardTitle;
|
|
||||||
private ImageView cardIcon;
|
|
||||||
private TextView units;
|
|
||||||
private TextView totalEarned;
|
|
||||||
private LinearLayout textholderTop;
|
|
||||||
private LinearLayout textholderBottom;
|
|
||||||
|
|
||||||
public ItemThree(View itemView){
|
|
||||||
super(itemView);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.appttude.h_mal.days_left
|
||||||
|
|
||||||
|
import com.appttude.h_mal.days_left.FirebaseClass.Companion.auth
|
||||||
|
import com.appttude.h_mal.days_left.FirebaseClass.Companion.mDatabase
|
||||||
|
|
||||||
|
const val USER_FIREBASE = "users"
|
||||||
|
val EMPLOYER_FIREBASE = "employers"
|
||||||
|
const val SHIFT_FIREBASE = "shifts"
|
||||||
|
val TASK_FIREBASE = "taskList"
|
||||||
|
|
||||||
|
val SHIFT_ID = "shift_id"
|
||||||
|
|
||||||
|
val PIECE = "Piece Rate"
|
||||||
|
val HOURLY = "Hourly"
|
||||||
|
class FirebaseDatabase{
|
||||||
|
|
||||||
|
fun allShifts() = mDatabase.child(USER_FIREBASE).child(auth.uid!!).child(SHIFT_FIREBASE)
|
||||||
|
fun child(shiftId: String) = mDatabase.child(USER_FIREBASE).child(auth.uid!!).child(SHIFT_FIREBASE).child(shiftId)
|
||||||
|
|
||||||
|
fun taskObject(abn: String) = mDatabase.child(FirebaseClass.EMPLOYER_FIREBASE).child(abn).child(
|
||||||
|
FirebaseClass.TASK_FIREBASE
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.Objects.CustomViewHolder;
|
|
||||||
import com.appttude.h_mal.days_left.Objects.ShiftObject;
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
import com.google.firebase.database.DatabaseReference;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.SHIFT_FIREBASE;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.USER_FIREBASE;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.auth;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.mDatabase;
|
|
||||||
import static com.appttude.h_mal.days_left.MainActivity.shiftsMap;
|
|
||||||
|
|
||||||
|
|
||||||
public class FragmentHome extends Fragment {
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
// Inflate the layout for this fragment
|
|
||||||
View view = inflater.inflate(R.layout.fragment_home, container, false);
|
|
||||||
|
|
||||||
RecyclerView recyclerView = view.findViewById(R.id.recycler);
|
|
||||||
// recyclerView.setAdapter(new RecyclerViewAdapter(getContext()));
|
|
||||||
|
|
||||||
// DatabaseReference reference = mDatabase.child(USER_FIREBASE).child(auth.getUid()).child(SHIFT_FIREBASE);
|
|
||||||
// reference.keepSynced(true);
|
|
||||||
|
|
||||||
// recyclerView.setAdapter(new FireRecyclerAdapter(ShiftObject.class,R.layout.item_one,RecyclerView.ViewHolder.class,reference,getContext()));
|
|
||||||
|
|
||||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(getContext(),new ArrayList<>(shiftsMap.values()));
|
|
||||||
recyclerView.setAdapter(adapter);
|
|
||||||
|
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
|
||||||
recyclerView.setHasFixedSize(true);
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,268 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ListAdapter;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.AddItems.AddShiftActivity;
|
|
||||||
import com.appttude.h_mal.days_left.Objects.ShiftObject;
|
|
||||||
import com.google.firebase.database.DataSnapshot;
|
|
||||||
import com.google.firebase.database.DatabaseError;
|
|
||||||
import com.google.firebase.database.DatabaseReference;
|
|
||||||
import com.google.firebase.database.Query;
|
|
||||||
import com.google.firebase.database.ValueEventListener;
|
|
||||||
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.SHIFT_FIREBASE;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.SHIFT_ID;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.USER_FIREBASE;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.auth;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.mDatabase;
|
|
||||||
|
|
||||||
|
|
||||||
public class FragmentList extends Fragment {
|
|
||||||
|
|
||||||
private static String TAG = "FragmentList";
|
|
||||||
|
|
||||||
private DatabaseReference reference;
|
|
||||||
private ListView listView;
|
|
||||||
private FireAdapter adapter;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
|
|
||||||
reference = mDatabase.child(USER_FIREBASE).child(auth.getUid()).child(SHIFT_FIREBASE);
|
|
||||||
reference.keepSynced(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
// Inflate the layout for this fragment
|
|
||||||
View view = inflater.inflate(R.layout.fragment_list, container, false);
|
|
||||||
|
|
||||||
listView = view.findViewById(R.id.page_two_list);
|
|
||||||
|
|
||||||
adapter = new FireAdapter(getActivity(), ShiftObject.class, R.layout.list_item, reference);
|
|
||||||
|
|
||||||
listView.setAdapter(adapter);
|
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
String refId = adapter.getId(position);
|
|
||||||
Intent intent = new Intent(getActivity(), AddShiftActivity.class);
|
|
||||||
intent.putExtra(SHIFT_ID,refId);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
|
||||||
builder.setTitle("Are you sure you want to delete?");
|
|
||||||
builder.setNegativeButton(android.R.string.no, null);
|
|
||||||
builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
//todo: delete from previously used if last entry
|
|
||||||
adapter.getRef(position).removeValue();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.create().show();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
|
|
||||||
inflater.inflate(R.menu.menu_list_fragment, menu);
|
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
|
|
||||||
case R.id.app_bar_filter:
|
|
||||||
filterData();
|
|
||||||
return false;
|
|
||||||
|
|
||||||
case R.id.app_bar_soft:
|
|
||||||
sortData();
|
|
||||||
return false;
|
|
||||||
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sortData(){
|
|
||||||
final String[] grpname = {"Name","Date Added","Date of shift"};
|
|
||||||
int checkedItem = -1;
|
|
||||||
|
|
||||||
AlertDialog.Builder alt_bld = new AlertDialog.Builder(getContext());
|
|
||||||
alt_bld.setTitle("Sort by:");
|
|
||||||
alt_bld.setSingleChoiceItems(grpname, checkedItem, new DialogInterface
|
|
||||||
.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, final int item) {
|
|
||||||
switch (item){
|
|
||||||
case 0:
|
|
||||||
Query q1 = reference.orderByChild("abnObject/companyName").equalTo("GREEN CLOUD NURSERY");
|
|
||||||
// .startAt("2018-04-12").endAt("2019-03-29");
|
|
||||||
|
|
||||||
adapter = new FireAdapter(getActivity(), ShiftObject.class, R.layout.list_item, q1);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
adapter = new FireAdapter(getActivity(), ShiftObject.class, R.layout.list_item, reference.orderByChild("dateTimeAdded"));
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
adapter = new FireAdapter(getActivity(), ShiftObject.class, R.layout.list_item, reference.orderByChild("shiftDate"));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
|
|
||||||
}
|
|
||||||
listView.setAdapter(adapter);
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
AlertDialog alert = alt_bld.create();
|
|
||||||
alert.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void filterData(){
|
|
||||||
final String[] groupName = {"Name","Date Added","Shift Type"};
|
|
||||||
int checkedItem = -1;
|
|
||||||
|
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
|
||||||
builder.setTitle("Filter by:");
|
|
||||||
builder.setSingleChoiceItems(groupName, checkedItem, new DialogInterface
|
|
||||||
.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, final int item) {
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
switch (item){
|
|
||||||
case 0:
|
|
||||||
final FilterDialogClass filterDialog = new FilterDialogClass(getContext(), 0, new FilterDialogClass.FilterDialogClickListener() {
|
|
||||||
@Override
|
|
||||||
public void applyDates(String arg1, String arg2) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applyAbn(String abn) {
|
|
||||||
applyFilter(abn,null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
filterDialog.show();
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
final FilterDialogClass filterDialog2 = new FilterDialogClass(getContext(), 1, new FilterDialogClass.FilterDialogClickListener() {
|
|
||||||
@Override
|
|
||||||
public void applyDates(String arg1, String arg2) {
|
|
||||||
applyFilter(arg1, arg2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applyAbn(String abn) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
filterDialog2.show();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
AlertDialog.Builder typeDialog = new AlertDialog.Builder(getContext());
|
|
||||||
final String[] typeString = {"Hourly", "Piece Rate"};
|
|
||||||
|
|
||||||
typeDialog.setSingleChoiceItems(new String[]{"Hourly", "Piece Rate"}, -1, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
Query q1 = reference.orderByChild("taskObject/workType").equalTo(typeString[which]);
|
|
||||||
|
|
||||||
adapter = new FireAdapter(getActivity(), ShiftObject.class, R.layout.list_item, q1);
|
|
||||||
listView.setAdapter(adapter);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
typeDialog.create().show();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
AlertDialog alert = builder.create();
|
|
||||||
alert.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void applyFilter(String arg1, String arg2){
|
|
||||||
Query q1;
|
|
||||||
if (arg2 == null){
|
|
||||||
q1 = reference.orderByChild("abnObject/abn").equalTo(arg1);
|
|
||||||
}else {
|
|
||||||
q1 = reference.orderByChild("shiftDate").startAt(arg1).endAt(arg2);
|
|
||||||
}
|
|
||||||
|
|
||||||
adapter = new FireAdapter(getActivity(), ShiftObject.class, R.layout.list_item, q1);
|
|
||||||
listView.setAdapter(adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Date convertDate(String s){
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
|
||||||
Date d = null;
|
|
||||||
try {
|
|
||||||
d = sdf.parse(s);
|
|
||||||
} catch (ParseException ex) {
|
|
||||||
Log.v("Exception", ex.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
if (d == null){
|
|
||||||
sdf.applyPattern("dd/MM/yyyy");
|
|
||||||
|
|
||||||
try {
|
|
||||||
d = sdf.parse(s);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,523 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.ActivityNotFoundException;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.os.StrictMode;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v4.app.ActivityCompat;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.content.ContextCompat;
|
|
||||||
import android.support.v4.content.FileProvider;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.AddItems.AddShiftActivity;
|
|
||||||
import com.appttude.h_mal.days_left.Objects.ShiftObject;
|
|
||||||
import com.fasterxml.aalto.in.ElementScope;
|
|
||||||
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.database.DataSnapshot;
|
|
||||||
import com.google.firebase.database.DatabaseError;
|
|
||||||
import com.google.firebase.database.DatabaseReference;
|
|
||||||
import com.google.firebase.database.ValueEventListener;
|
|
||||||
import com.google.firebase.functions.FirebaseFunctions;
|
|
||||||
import com.google.firebase.functions.FirebaseFunctionsException;
|
|
||||||
import com.google.firebase.functions.HttpsCallableResult;
|
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static com.appttude.h_mal.days_left.FragmentList.convertDate;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.SHIFT_FIREBASE;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.SHIFT_ID;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.USER_FIREBASE;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.auth;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.mDatabase;
|
|
||||||
|
|
||||||
public class FragmentTools extends Fragment {
|
|
||||||
|
|
||||||
private static String TAG = "FragmentTools";
|
|
||||||
|
|
||||||
private DatabaseReference reference;
|
|
||||||
private List<ShiftObject> shiftObjectArrayList;
|
|
||||||
private Button button;
|
|
||||||
|
|
||||||
private FirebaseFunctions mFunctions;
|
|
||||||
|
|
||||||
private static final int STORAGE_PERMISSIONS = 1331;
|
|
||||||
private int selection;
|
|
||||||
private Button summery;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
reference = mDatabase.child(USER_FIREBASE).child(auth.getUid()).child(SHIFT_FIREBASE);
|
|
||||||
reference.keepSynced(true);
|
|
||||||
shiftObjectArrayList = new ArrayList<>();
|
|
||||||
|
|
||||||
mFunctions = FirebaseFunctions.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
// Inflate the layout for this fragment
|
|
||||||
View view = inflater.inflate(R.layout.fragment_tools, container, false);
|
|
||||||
|
|
||||||
button = view.findViewById(R.id.compile);
|
|
||||||
summery = view.findViewById(R.id.summary_button);
|
|
||||||
|
|
||||||
reference.addListenerForSingleValueEvent(valueEventListener);
|
|
||||||
// if (shiftObjectArrayList.size() > 0){
|
|
||||||
// Toast.makeText(getContext(), "Button Active", Toast.LENGTH_SHORT).show();
|
|
||||||
// button.setOnClickListener(clickListener);
|
|
||||||
// summery.setOnClickListener(clickListener);
|
|
||||||
// }else {
|
|
||||||
// Toast.makeText(getContext(), "List Empty", Toast.LENGTH_SHORT).show();
|
|
||||||
// }
|
|
||||||
summery.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
writeToExcel().addOnCompleteListener(new OnCompleteListener<String>() {
|
|
||||||
@Override
|
|
||||||
public void onComplete(@NonNull Task<String> task) {
|
|
||||||
if (!task.isSuccessful()) {
|
|
||||||
Exception e = task.getException();
|
|
||||||
if (e instanceof FirebaseFunctionsException) {
|
|
||||||
FirebaseFunctionsException ffe = (FirebaseFunctionsException) e;
|
|
||||||
FirebaseFunctionsException.Code code = ffe.getCode();
|
|
||||||
Object details = ffe.getDetails();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Log.w(TAG, "addMessage:onFailure", e);
|
|
||||||
Toast.makeText(getContext(), "An error occurred.", Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// [START_EXCLUDE]
|
|
||||||
String result = task.getResult();
|
|
||||||
Log.i(TAG, "onComplete: " + result);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Task<String> writeToExcel() {
|
|
||||||
// Create the arguments to the callable function.
|
|
||||||
Map<String, Object> data = new HashMap<>();
|
|
||||||
data.put("text", "wtf!!");
|
|
||||||
data.put("push", true);
|
|
||||||
|
|
||||||
return mFunctions
|
|
||||||
.getHttpsCallable("addMessage")
|
|
||||||
.call(data)
|
|
||||||
.continueWith(new Continuation<HttpsCallableResult, String>() {
|
|
||||||
@Override
|
|
||||||
public String then(@NonNull Task<HttpsCallableResult> task) throws Exception {
|
|
||||||
// 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.
|
|
||||||
String result = (String) task.getResult().getData();
|
|
||||||
|
|
||||||
Log.i(TAG, "then: " + result);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ValueEventListener valueEventListener = new ValueEventListener() {
|
|
||||||
@Override
|
|
||||||
public void onDataChange(@NonNull final DataSnapshot dataSnapshot) {
|
|
||||||
for (DataSnapshot postSnapshot: dataSnapshot.getChildren()) {
|
|
||||||
shiftObjectArrayList.add(postSnapshot.getValue(ShiftObject.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shiftObjectArrayList.size() > 0){
|
|
||||||
Toast.makeText(getContext(), "Button Active", Toast.LENGTH_SHORT).show();
|
|
||||||
button.setOnClickListener(clickListener);
|
|
||||||
// summery.setOnClickListener(clickListener);
|
|
||||||
}else {
|
|
||||||
Toast.makeText(getContext(), "List Empty", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCancelled(@NonNull DatabaseError databaseError) {
|
|
||||||
Toast.makeText(getContext(), "Cancelled", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
View.OnClickListener clickListener = new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
switch (v.getId()){
|
|
||||||
|
|
||||||
case R.id.compile:
|
|
||||||
selection = 0;
|
|
||||||
break;
|
|
||||||
case R.id.summary_button:
|
|
||||||
selection = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ActivityCompat.checkSelfPermission(getContext(), android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
|
||||||
// Permission is not granted
|
|
||||||
|
|
||||||
requestPermissions(new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE},STORAGE_PERMISSIONS);
|
|
||||||
}else{
|
|
||||||
Toast.makeText(getContext(), "" + selection, Toast.LENGTH_SHORT).show();
|
|
||||||
executeCompile();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private void executeCompile(){
|
|
||||||
boolean success = false;
|
|
||||||
try {
|
|
||||||
if (selection == 0){
|
|
||||||
saveExcelFile(getActivity(),"compile",shiftObjectArrayList);
|
|
||||||
}else if (selection == 1){
|
|
||||||
saveExcelSummaryFile(getActivity(),"summary",shiftObjectArrayList);
|
|
||||||
}
|
|
||||||
|
|
||||||
success = true;
|
|
||||||
}catch (Exception e){
|
|
||||||
Log.e(TAG, "onClick: ",e );
|
|
||||||
}finally {
|
|
||||||
if (success){
|
|
||||||
//open the file
|
|
||||||
Log.i(TAG, "executeCompile: Success");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean saveExcelFile(Activity activity, String fileName, List<ShiftObject> shifts) {
|
|
||||||
|
|
||||||
String[] strings = {"Employer name","ABN","Shift Date","Time in","Time out","Break","Hours","Units","Pay","Work Type"};
|
|
||||||
|
|
||||||
// check if available and not read only
|
|
||||||
if (!isExternalStorageAvailable() || isExternalStorageReadOnly()) {
|
|
||||||
Log.e(TAG, "Storage not available or read only");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean success = false;
|
|
||||||
|
|
||||||
//New Workbook
|
|
||||||
Workbook wb = new HSSFWorkbook();
|
|
||||||
|
|
||||||
Cell c = null;
|
|
||||||
|
|
||||||
//New Sheet
|
|
||||||
Sheet sheet1 = null;
|
|
||||||
sheet1 = wb.createSheet("Shift List");
|
|
||||||
|
|
||||||
// Generate column headings
|
|
||||||
Row row = sheet1.createRow(0);
|
|
||||||
|
|
||||||
//Initialise top row
|
|
||||||
for (int i=0; i<strings.length; i++){
|
|
||||||
c = row.createCell(i);
|
|
||||||
c.setCellValue(strings[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
sortArrayByDate(shifts);
|
|
||||||
|
|
||||||
int r = 1;
|
|
||||||
for (ShiftObject shift : shifts){
|
|
||||||
row = sheet1.createRow(r);
|
|
||||||
for (int i=0; i<strings.length; i++){
|
|
||||||
c = row.createCell(i);
|
|
||||||
|
|
||||||
switch (i) {
|
|
||||||
case 0:
|
|
||||||
c.setCellValue(shift.getAbnObject().getCompanyName());
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
c.setCellValue(shift.getAbnObject().getAbn());
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
c.setCellValue(shift.getShiftDate());
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
if (shift.timeObject != null){
|
|
||||||
c.setCellValue(shift.getTimeObject().getTimeIn());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
if (shift.timeObject != null) {
|
|
||||||
c.setCellValue(shift.getTimeObject().getTimeOut());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
if (shift.timeObject != null) {
|
|
||||||
c.setCellValue(shift.getTimeObject().getBreakEpoch());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
if (shift.timeObject != null) {
|
|
||||||
c.setCellValue(shift.getTimeObject().getHours());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
if (shift.unitsCount != null){
|
|
||||||
c.setCellValue(shift.getUnitsCount());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
float units;
|
|
||||||
if (shift.unitsCount != null){
|
|
||||||
units = shift.getUnitsCount();
|
|
||||||
}else{
|
|
||||||
units = shift.getTimeObject().getHours();
|
|
||||||
}
|
|
||||||
c.setCellValue(shift.getTaskObject().getRate() * units);
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
c.setCellValue(shift.getTaskObject().getWorkType());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
r++;
|
|
||||||
}
|
|
||||||
|
|
||||||
sheet1.setColumnWidth(0, (15 * 500));
|
|
||||||
|
|
||||||
try {
|
|
||||||
createAndOpenFile(fileName,wb,activity);
|
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
catch (ActivityNotFoundException e) {
|
|
||||||
Toast.makeText(activity, "No Application Available to View Excel", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isExternalStorageReadOnly() {
|
|
||||||
String extStorageState = Environment.getExternalStorageState();
|
|
||||||
if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(extStorageState)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isExternalStorageAvailable() {
|
|
||||||
String extStorageState = Environment.getExternalStorageState();
|
|
||||||
if (Environment.MEDIA_MOUNTED.equals(extStorageState)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
||||||
|
|
||||||
if (requestCode == STORAGE_PERMISSIONS){
|
|
||||||
if (grantResults.length > 0
|
|
||||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
|
||||||
executeCompile();
|
|
||||||
}else{
|
|
||||||
Toast.makeText(getContext(), "No Storage Permissions", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean saveExcelSummaryFile(Activity activity, String fileName, List<ShiftObject> shifts) {
|
|
||||||
List<String> abnList = new ArrayList<>();
|
|
||||||
String[] strings = {"ABN","Post code","Start Date","End date"};
|
|
||||||
|
|
||||||
//add abn numbers to list
|
|
||||||
for(ShiftObject currentShift : shifts){
|
|
||||||
String currentAbn = currentShift.getAbnObject().getAbn();
|
|
||||||
|
|
||||||
if (!abnList.contains(currentAbn)) {
|
|
||||||
abnList.add(currentAbn);
|
|
||||||
Log.i(TAG, "saveExcelSummaryFile: current abn = " + currentAbn);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//sort by date
|
|
||||||
sortArrayByDate(shifts);
|
|
||||||
|
|
||||||
boolean success = false;
|
|
||||||
|
|
||||||
//New Workbook
|
|
||||||
Workbook wb = new HSSFWorkbook();
|
|
||||||
|
|
||||||
Cell c = null;
|
|
||||||
|
|
||||||
//New Sheet
|
|
||||||
Sheet sheet1 = null;
|
|
||||||
sheet1 = wb.createSheet("Visa summary List");
|
|
||||||
|
|
||||||
// Generate column headings
|
|
||||||
Row row = sheet1.createRow(0);
|
|
||||||
|
|
||||||
//Initialise top row
|
|
||||||
for (int i=0; i<strings.length; i++){
|
|
||||||
c = row.createCell(i);
|
|
||||||
c.setCellValue(strings[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
int r = 1;
|
|
||||||
|
|
||||||
|
|
||||||
//create shifts for export arraylist
|
|
||||||
List<ShiftObject> tempArray = new ArrayList<>();
|
|
||||||
|
|
||||||
//loop through abnList and add to excel
|
|
||||||
for(String abn : abnList){
|
|
||||||
//add shifts to tempArray
|
|
||||||
for(ShiftObject tempShift : shifts){
|
|
||||||
if (tempShift.getAbnObject().getAbn().equals(abn)){
|
|
||||||
//exists
|
|
||||||
tempArray.add(tempShift);
|
|
||||||
Log.i(TAG, "saveExcelSummaryFile: " + tempShift.getAbnObject().getAbn());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
row = sheet1.createRow(r);
|
|
||||||
for (int i=0; i<strings.length; i++){
|
|
||||||
c = row.createCell(i);
|
|
||||||
|
|
||||||
switch (i) {
|
|
||||||
case 0:
|
|
||||||
c.setCellValue(tempArray.get(0).getAbnObject().getAbn());
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
c.setCellValue(tempArray.get(0).getAbnObject().getPostCode());
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
c.setCellValue(tempArray.get(0).getShiftDate());
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
c.setCellValue(tempArray.get(tempArray.size() - 1).getShiftDate());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
r++;
|
|
||||||
tempArray.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
sheet1.setColumnWidth(0, (6 * 500));
|
|
||||||
sheet1.setColumnWidth(1, (5 * 500));
|
|
||||||
sheet1.setColumnWidth(2, (6 * 500));
|
|
||||||
sheet1.setColumnWidth(3, (6 * 500));
|
|
||||||
|
|
||||||
// Create a path where we will place our List of objects on external storage
|
|
||||||
try {
|
|
||||||
createAndOpenFile(fileName,wb,activity);
|
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
catch (ActivityNotFoundException e) {
|
|
||||||
Toast.makeText(activity, "No Application Available to View Excel", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void sortArrayByDate(List<ShiftObject> shifts){
|
|
||||||
Collections.sort(shifts, new Comparator<ShiftObject>() {
|
|
||||||
|
|
||||||
public int compare(ShiftObject s1, ShiftObject s2) {
|
|
||||||
Date d1 = convertDate(s1.getShiftDate());
|
|
||||||
Date d2 = convertDate(s2.getShiftDate());
|
|
||||||
|
|
||||||
return d1.compareTo(d2);
|
|
||||||
}});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void createAndOpenFile(String fileName,Workbook wb, Activity activity){
|
|
||||||
final String savePath = Environment.getExternalStorageDirectory() + "/ShifttrackerTemp";
|
|
||||||
File file = new File(savePath);
|
|
||||||
if (!file.exists()) {
|
|
||||||
file.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
File myFile = new File(savePath,fileName + ".xls");
|
|
||||||
FileOutputStream os = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
os = new FileOutputStream(myFile);
|
|
||||||
wb.write(os);
|
|
||||||
Log.w("FileUtils", "Writing file" + file);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.w("FileUtils", "Error writing " + file, e);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.w("FileUtils", "Failed to save file", e);
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (null != os)
|
|
||||||
os.close();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
Log.i(TAG, "saveExcelFile: filepath = " + myFile.getAbsolutePath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final Uri data = FileProvider.getUriForFile(activity, BuildConfig.APPLICATION_ID + ".provider", myFile);
|
|
||||||
activity.grantUriPermission(activity.getPackageName(), data, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
||||||
final Intent intent1 = new Intent(Intent.ACTION_VIEW)
|
|
||||||
.setDataAndType(data, "application/vnd.ms-excel")
|
|
||||||
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
||||||
|
|
||||||
try {
|
|
||||||
activity.startActivity(intent1);
|
|
||||||
}
|
|
||||||
catch (ActivityNotFoundException e) {
|
|
||||||
Toast.makeText(activity, "No Application Available to View Excel", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,124 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.Global;
|
|
||||||
|
|
||||||
import android.app.DatePickerDialog;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.support.annotation.RequiresApi;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.DatePicker;
|
|
||||||
import android.widget.EditText;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class DateDialog extends DatePickerDialog {
|
|
||||||
|
|
||||||
int mYear;
|
|
||||||
int mMonth;
|
|
||||||
int mDay;
|
|
||||||
|
|
||||||
EditText editText;
|
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
||||||
public DateDialog(@NonNull Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
||||||
public DateDialog(@NonNull Context context, int themeResId) {
|
|
||||||
super(context, themeResId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DateDialog(@NonNull Context context,
|
|
||||||
@Nullable OnDateSetListener listener,
|
|
||||||
int year, int month, int dayOfMonth) {
|
|
||||||
super(context, listener, year, month, dayOfMonth);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public DateDialog(@NonNull Context context, int themeResId, @Nullable OnDateSetListener listener, int year, int monthOfYear, int dayOfMonth) {
|
|
||||||
super(context, themeResId, listener, year, monthOfYear, dayOfMonth);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTitle(CharSequence title) {
|
|
||||||
super.setTitle(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setOnDateSetListener(@Nullable OnDateSetListener listener) {
|
|
||||||
super.setOnDateSetListener(dateSetListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init(EditText editText){
|
|
||||||
this.editText = editText;
|
|
||||||
|
|
||||||
String dateString = editText.getText().toString();
|
|
||||||
|
|
||||||
Date javaDate = null;
|
|
||||||
|
|
||||||
if(TextUtils.isEmpty(dateString)){
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
mYear = calendar.get(Calendar.YEAR);
|
|
||||||
mMonth = calendar.get(Calendar.MONTH);
|
|
||||||
mDay = calendar.get(Calendar.DAY_OF_MONTH);
|
|
||||||
}else {
|
|
||||||
try {
|
|
||||||
SimpleDateFormat sdfrmt = new SimpleDateFormat("dd/MM/yyyy");
|
|
||||||
sdfrmt.setLenient(false);
|
|
||||||
javaDate = sdfrmt.parse(dateString);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
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 {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
mYear = calendar.get(Calendar.YEAR);
|
|
||||||
mMonth = calendar.get(Calendar.MONTH);
|
|
||||||
mDay = calendar.get(Calendar.DAY_OF_MONTH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.i(this.getClass().getSimpleName(), "init: year =" + mYear +
|
|
||||||
"month = " + mMonth +
|
|
||||||
"day = " + mDay);
|
|
||||||
|
|
||||||
|
|
||||||
updateDate(mYear,mMonth,mDay);
|
|
||||||
|
|
||||||
setOnDateSetListener(null);
|
|
||||||
|
|
||||||
this.setTitle(getContext().getString(R.string.set_date));
|
|
||||||
this.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
OnDateSetListener dateSetListener = new OnDateSetListener() {
|
|
||||||
@Override
|
|
||||||
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
|
|
||||||
mYear = year;
|
|
||||||
mMonth = month + 1;
|
|
||||||
mDay = dayOfMonth;
|
|
||||||
|
|
||||||
String date = mYear + "-" + String.format("%02d", mMonth) + "-" + String.format("%02d", mDay);
|
|
||||||
|
|
||||||
editText.setText(date);
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.Global;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.app.FragmentTransaction;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
|
|
||||||
import static com.appttude.h_mal.days_left.MainActivity.fragmentManager;
|
|
||||||
|
|
||||||
public class ExecuteFragment {
|
|
||||||
|
|
||||||
public static void executeFragment(Fragment fragment, Bundle bundle) {
|
|
||||||
executeFragmentMethod(fragment,bundle);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void executeFragment(Fragment fragment) {
|
|
||||||
executeFragmentMethod(fragment);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void executeFragmentMethod(Fragment f){
|
|
||||||
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
|
||||||
fragmentTransaction.replace(R.id.container,f).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).addToBackStack(f.getClass().getSimpleName()).commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void executeFragmentMethod(Fragment f, Bundle b){
|
|
||||||
if (b != null){
|
|
||||||
f.setArguments(b);
|
|
||||||
}
|
|
||||||
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
|
||||||
fragmentTransaction.replace(R.id.container,f).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).addToBackStack(f.getClass().getSimpleName()).commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,429 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.Global;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.Abn.AbnObject;
|
|
||||||
import com.appttude.h_mal.days_left.Abn.SearchAbnRecords;
|
|
||||||
import com.appttude.h_mal.days_left.AddItems.SearchAsyncTask;
|
|
||||||
import com.appttude.h_mal.days_left.Objects.TaskObject;
|
|
||||||
import com.google.android.gms.tasks.OnCompleteListener;
|
|
||||||
import com.google.android.gms.tasks.Task;
|
|
||||||
import com.google.firebase.auth.FirebaseAuth;
|
|
||||||
import com.google.firebase.database.DataSnapshot;
|
|
||||||
import com.google.firebase.database.DatabaseError;
|
|
||||||
import com.google.firebase.database.DatabaseReference;
|
|
||||||
import com.google.firebase.database.FirebaseDatabase;
|
|
||||||
import com.google.firebase.database.ValueEventListener;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import static com.appttude.h_mal.days_left.Abn.SearchAbnRecords.ExtractFeatureFromAbnJson;
|
|
||||||
import static com.appttude.h_mal.days_left.Abn.SearchAbnRecords.makeHttpRequest;
|
|
||||||
|
|
||||||
public class FirebaseClass {
|
|
||||||
|
|
||||||
private static final String TAG = "FirebaseClass";
|
|
||||||
|
|
||||||
public static final String USER_FIREBASE = "users";
|
|
||||||
public static final String EMPLOYER_FIREBASE = "employers";
|
|
||||||
public static final String SHIFT_FIREBASE = "shifts";
|
|
||||||
public static final String TASK_FIREBASE = "taskList";
|
|
||||||
|
|
||||||
public static final String SHIFT_ID = "shift_id";
|
|
||||||
|
|
||||||
public static final String PIECE = "Piece Rate";
|
|
||||||
public static final String HOURLY = "Hourly";
|
|
||||||
|
|
||||||
public static DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference();
|
|
||||||
public static FirebaseAuth auth = FirebaseAuth.getInstance();
|
|
||||||
|
|
||||||
public interface Response {
|
|
||||||
void retrieveAbnStringList(List<String> abnList);
|
|
||||||
void retrieveAbnObjectList(List<AbnObject> abnObjects);
|
|
||||||
void retrieveTaskList(List<TaskObject> taskObjects);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface matchListener{
|
|
||||||
void abnMatch(Boolean confirm);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface Complete{
|
|
||||||
void taskCompleted(Boolean success);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FirebaseClass() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// public void uploadImage(String path, String name) {
|
|
||||||
//
|
|
||||||
// if(filePath != null) {
|
|
||||||
// final ProgressDialog progressDialog = new ProgressDialog(context);
|
|
||||||
// progressDialog.setTitle("Uploading...");
|
|
||||||
// progressDialog.show();
|
|
||||||
//
|
|
||||||
// final StorageReference ref = storageReference.child("images/"+ auth.getCurrentUser().getUid() + "/" + path
|
|
||||||
// + "/" + name);
|
|
||||||
//
|
|
||||||
// UploadTask uploadTask = ref.putFile(filePath);
|
|
||||||
//
|
|
||||||
// uploadTask.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
|
|
||||||
// @Override
|
|
||||||
// public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
|
|
||||||
// double progress = (100.0*taskSnapshot.getBytesTransferred()/taskSnapshot
|
|
||||||
// .getTotalByteCount());
|
|
||||||
// progressDialog.setMessage("Uploaded "+(int)progress+"%");
|
|
||||||
// }
|
|
||||||
// }).continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
|
|
||||||
// @Override
|
|
||||||
// public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
|
|
||||||
// if (!task.isSuccessful()) {
|
|
||||||
// throw task.getException();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Continue with the task to get the download URL
|
|
||||||
// return ref.getDownloadUrl();
|
|
||||||
// }
|
|
||||||
// }).addOnCompleteListener(new OnCompleteListener<Uri>() {
|
|
||||||
// @Override
|
|
||||||
// public void onComplete(@NonNull Task<Uri> task) {
|
|
||||||
// if (task.isSuccessful()) {
|
|
||||||
// delegate.retrieveAbnStringList(task.getResult());
|
|
||||||
// progressDialog.dismiss();
|
|
||||||
// Toast.makeText(context, "Uploaded Successfully", Toast.LENGTH_SHORT).show();
|
|
||||||
// Log.i(context.getClass().getSimpleName(), "onComplete: uploaded Successful uri: " + task.getResult());
|
|
||||||
// } else {
|
|
||||||
// delegate.retrieveAbnStringList(null);
|
|
||||||
// progressDialog.dismiss();
|
|
||||||
// Toast.makeText(context, "Failed to upload", Toast.LENGTH_SHORT).show();
|
|
||||||
// Log.i(context.getClass().getSimpleName(), "onComplete: failed to get url");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void PushAbnObject(final AbnObject abnObject, final TaskObject taskObject, final ProgressBar progressBar, final Activity activity){
|
|
||||||
final DatabaseReference pushRef = mDatabase.child(EMPLOYER_FIREBASE);
|
|
||||||
pushRef.keepSynced(true);
|
|
||||||
|
|
||||||
pushRef.addListenerForSingleValueEvent(new ValueEventListener() {
|
|
||||||
@Override
|
|
||||||
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
|
|
||||||
|
|
||||||
boolean exists = false;
|
|
||||||
for (DataSnapshot postSnapshot: dataSnapshot.getChildren()) {
|
|
||||||
if (postSnapshot.getKey().equals(abnObject.getAbn())){
|
|
||||||
exists = true;
|
|
||||||
Log.i(TAG, "onDataChange: exists");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//pushing new abn to list
|
|
||||||
if (!exists){
|
|
||||||
Log.i(TAG, "onDataChange: triggered true");
|
|
||||||
abnObject.setDateAdded(getDateTimeString());
|
|
||||||
abnObject.setAddedById(auth.getUid());
|
|
||||||
|
|
||||||
// if (abnObject.getFromAbnSearch()){
|
|
||||||
final SearchAbnRecords abnRecords = new SearchAbnRecords();
|
|
||||||
|
|
||||||
SearchAsyncTask searchAsyncTask = new SearchAsyncTask(new SearchAsyncTask.OnTaskCompleted() {
|
|
||||||
@Override
|
|
||||||
public void onTaskCompleted(String s) {
|
|
||||||
AbnObject retrievedAbn = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
retrievedAbn = ExtractFeatureFromAbnJson(s).get(0);
|
|
||||||
}catch (Exception e){
|
|
||||||
Log.e(TAG, "onTaskCompleted: ", e);
|
|
||||||
}finally {
|
|
||||||
if (retrievedAbn != null){
|
|
||||||
abnObject.setCompanyName(retrievedAbn.getCompanyName());
|
|
||||||
}
|
|
||||||
// pushRef.child(abnObject.getAbn()).setValue(abnObject)
|
|
||||||
// .addOnCompleteListener(new OnCompleteListener<Void>() {
|
|
||||||
// @Override
|
|
||||||
// public void onComplete(@NonNull Task<Void> task) {
|
|
||||||
// if (task.isSuccessful()){
|
|
||||||
// PushTaskObject(abnObject.getAbn(), taskObject, new Complete() {
|
|
||||||
// @Override
|
|
||||||
// public void taskCompleted(Boolean success) {
|
|
||||||
// if (success){
|
|
||||||
// activity.finish();
|
|
||||||
// }else {
|
|
||||||
// progressBar.setVisibility(View.GONE);
|
|
||||||
// Toast.makeText(activity, "Could not upload Task", Toast.LENGTH_SHORT).show();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }else {
|
|
||||||
// Log.i(TAG, "onComplete: " + task.getResult());
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
searchAsyncTask.execute(abnRecords.searchViaAbn(abnObject.getAbn()));
|
|
||||||
// }else
|
|
||||||
// {
|
|
||||||
// pushRef.child(abnObject.getAbn()).setValue(abnObject)
|
|
||||||
// .addOnCompleteListener(new OnCompleteListener<Void>() {
|
|
||||||
// @Override
|
|
||||||
// public void onComplete(@NonNull Task<Void> task) {
|
|
||||||
// Log.i(TAG, "onComplete: triggered");
|
|
||||||
// if (task.isSuccessful()){
|
|
||||||
// PushTaskObject(abnObject.getAbn(), taskObject, new Complete() {
|
|
||||||
// @Override
|
|
||||||
// public void taskCompleted(Boolean success) {
|
|
||||||
// if (success){
|
|
||||||
// activity.finish();
|
|
||||||
// }else {
|
|
||||||
// progressBar.setVisibility(View.GONE);
|
|
||||||
// Toast.makeText(activity, "Could not upload Task", Toast.LENGTH_SHORT).show();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }else {
|
|
||||||
// Log.i(TAG, "onComplete: " + task.getResult());
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
}else {
|
|
||||||
Log.i(TAG, "onDataChange: exists false");
|
|
||||||
PushTaskObject(abnObject.getAbn(), taskObject, new Complete() {
|
|
||||||
@Override
|
|
||||||
public void taskCompleted(Boolean success) {
|
|
||||||
Log.i(TAG, "taskCompleted: " + success);
|
|
||||||
if (success){
|
|
||||||
activity.finish();
|
|
||||||
}else {
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
Toast.makeText(activity, "Could not upload Task", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCancelled(@NonNull DatabaseError databaseError) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PushTaskObject(String Abn, final TaskObject taskObject, final Complete complete){
|
|
||||||
final DatabaseReference pushRef = mDatabase.child(EMPLOYER_FIREBASE).child(Abn).child(TASK_FIREBASE);
|
|
||||||
pushRef.keepSynced(true);
|
|
||||||
final List<TaskObject> taskObjectList = new ArrayList<>();
|
|
||||||
|
|
||||||
retrieveListOfTasks(Abn, new Response() {
|
|
||||||
@Override
|
|
||||||
public void retrieveAbnStringList(List<String> abnList) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void retrieveAbnObjectList(List<AbnObject> abnObjects) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void retrieveTaskList(List<TaskObject> taskObjects) {
|
|
||||||
Log.i(TAG, "retrieveTaskList: triggered" + taskObjects.size());
|
|
||||||
boolean exists = false;
|
|
||||||
if (taskObjects != null && taskObjects.size() > 0){
|
|
||||||
taskObjectList.addAll(taskObjects);
|
|
||||||
|
|
||||||
for (TaskObject tO : taskObjectList){
|
|
||||||
if (taskObject.getWorkType().equals(tO.getWorkType()) &&
|
|
||||||
taskObject.getRate() == tO.getRate() &&
|
|
||||||
taskObject.getTask().equals(tO.getTask())){
|
|
||||||
exists = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!exists){
|
|
||||||
taskObject.setDateAddedToDb(getDateTimeString());
|
|
||||||
taskObject.setUserIdOfCreator(auth.getUid());
|
|
||||||
|
|
||||||
taskObjectList.add(taskObject);
|
|
||||||
|
|
||||||
pushRef.setValue(taskObjectList).addOnCompleteListener(new OnCompleteListener<Void>() {
|
|
||||||
@Override
|
|
||||||
public void onComplete(@NonNull Task<Void> task) {
|
|
||||||
Log.i(TAG, "onComplete: isSuccessful = " + task.isSuccessful());
|
|
||||||
complete.taskCompleted(task.isSuccessful());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}else {
|
|
||||||
complete.taskCompleted(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateListOfPreviouslyUsedAbns(final String currentAbn, final Complete complete){
|
|
||||||
final DatabaseReference listRef = mDatabase.child(USER_FIREBASE).child(auth.getUid()).child("recent" + EMPLOYER_FIREBASE);
|
|
||||||
listRef.keepSynced(true);
|
|
||||||
final boolean[] exists = {false};
|
|
||||||
|
|
||||||
LoadListOfPreviousAbn(new Response() {
|
|
||||||
@Override
|
|
||||||
public void retrieveAbnStringList(List<String> abnList) {
|
|
||||||
if (abnList.size() > 0){
|
|
||||||
for (String abnString : abnList){
|
|
||||||
if (abnString.equals(currentAbn)){
|
|
||||||
exists[0] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!exists[0]){
|
|
||||||
abnList.add(currentAbn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (abnList.size() == 0){
|
|
||||||
abnList.add(currentAbn);
|
|
||||||
}
|
|
||||||
|
|
||||||
listRef.setValue(abnList).addOnCompleteListener(new OnCompleteListener<Void>() {
|
|
||||||
@Override
|
|
||||||
public void onComplete(@NonNull Task<Void> task) {
|
|
||||||
Log.i(TAG, "onComplete: isSuccessful = " + task.isSuccessful());
|
|
||||||
complete.taskCompleted(task.isSuccessful());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void retrieveAbnObjectList(List<AbnObject> abnObjects) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void retrieveTaskList(List<TaskObject> taskObjects) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadListOfPreviousAbn(final Response delegate){
|
|
||||||
DatabaseReference listRef = mDatabase.child(USER_FIREBASE).child(auth.getUid()).child("recent" + EMPLOYER_FIREBASE);
|
|
||||||
listRef.keepSynced(true);
|
|
||||||
final List<String> abnList = new ArrayList<>();
|
|
||||||
|
|
||||||
listRef.addListenerForSingleValueEvent(new ValueEventListener() {
|
|
||||||
@Override
|
|
||||||
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
|
|
||||||
for (DataSnapshot abn : dataSnapshot.getChildren()){
|
|
||||||
Log.i(TAG, "onDataChange: abn = " + abn);
|
|
||||||
abnList.add((String) abn.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate.retrieveAbnStringList(abnList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCancelled(@NonNull DatabaseError databaseError) {
|
|
||||||
delegate.retrieveAbnStringList(null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void retrieveListOfEmployers(final List<String> abnStrings, final Response delegate){
|
|
||||||
final List<AbnObject> abnObjects = new ArrayList<>();
|
|
||||||
DatabaseReference listRef = mDatabase.child(USER_FIREBASE).child(auth.getUid()).child("recent" + EMPLOYER_FIREBASE);
|
|
||||||
listRef.addListenerForSingleValueEvent(new ValueEventListener() {
|
|
||||||
@Override
|
|
||||||
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
|
|
||||||
for (DataSnapshot current : dataSnapshot.getChildren()){
|
|
||||||
for (String abnString : abnStrings){
|
|
||||||
if (current.getKey().equals(abnString)){
|
|
||||||
abnObjects.add(current.getValue(AbnObject.class));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delegate.retrieveAbnObjectList(abnObjects);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCancelled(@NonNull DatabaseError databaseError) {
|
|
||||||
delegate.retrieveAbnObjectList(null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void newAbnEntry(final String currentAbn, final matchListener delegate){
|
|
||||||
DatabaseReference listRef = mDatabase.child(USER_FIREBASE).child(auth.getUid()).child("recent" + EMPLOYER_FIREBASE);
|
|
||||||
listRef.addListenerForSingleValueEvent(new ValueEventListener() {
|
|
||||||
@Override
|
|
||||||
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
|
|
||||||
for (DataSnapshot current : dataSnapshot.getChildren()){
|
|
||||||
if (current.getKey().equals(currentAbn)){
|
|
||||||
delegate.abnMatch(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
delegate.abnMatch(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCancelled(@NonNull DatabaseError databaseError) {
|
|
||||||
delegate.abnMatch(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void retrieveListOfTasks (String abn, final Response delegate){
|
|
||||||
DatabaseReference taskListReference = mDatabase.child(EMPLOYER_FIREBASE).child(abn).child(TASK_FIREBASE);
|
|
||||||
taskListReference.keepSynced(true);
|
|
||||||
taskListReference.addListenerForSingleValueEvent(new ValueEventListener() {
|
|
||||||
@Override
|
|
||||||
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
|
|
||||||
List<TaskObject> taskObjects = new ArrayList<>();
|
|
||||||
for (DataSnapshot current : dataSnapshot.getChildren()){
|
|
||||||
taskObjects.add(current.getValue(TaskObject.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate.retrieveTaskList(taskObjects);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCancelled(@NonNull DatabaseError databaseError) {
|
|
||||||
delegate.retrieveTaskList(null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getDateTimeString(){
|
|
||||||
Calendar cal = Calendar.getInstance();
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss", Locale.ENGLISH);
|
|
||||||
|
|
||||||
return sdf.format(cal.getTime());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.Login;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.app.FragmentTransaction;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
import com.google.firebase.auth.FirebaseUser;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.MainActivity;
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
|
|
||||||
import static com.appttude.h_mal.days_left.Login.FullscreenActivity.auth;
|
|
||||||
import static com.appttude.h_mal.days_left.Login.FullscreenActivity.fragmentManager;
|
|
||||||
|
|
||||||
public class BlankFragment extends Fragment {
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
// Inflate the layout for this fragment
|
|
||||||
View view = inflater.inflate(R.layout.fragment_blank, container, false);
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
|
||||||
super.onActivityCreated(savedInstanceState);
|
|
||||||
|
|
||||||
Handler handler = new Handler();
|
|
||||||
handler.postDelayed(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
//check if logged in
|
|
||||||
FirebaseUser user = auth.getCurrentUser();
|
|
||||||
if (user == null){
|
|
||||||
fragmentManager.beginTransaction()
|
|
||||||
.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)
|
|
||||||
.replace(R.id.container,new LoginFragment())
|
|
||||||
.commit();
|
|
||||||
}else {
|
|
||||||
Intent intent = new Intent(getContext(),MainActivity.class);
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
||||||
startActivity(intent);
|
|
||||||
getActivity().finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,220 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.Login;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.text.InputType;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
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.AuthCredential;
|
|
||||||
import com.google.firebase.auth.EmailAuthProvider;
|
|
||||||
import com.google.firebase.auth.FirebaseAuth;
|
|
||||||
import com.google.firebase.auth.FirebaseUser;
|
|
||||||
import com.google.firebase.auth.UserProfileChangeRequest;
|
|
||||||
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.auth;
|
|
||||||
|
|
||||||
public class ChangeUserDetailsActivity extends AppCompatActivity {
|
|
||||||
|
|
||||||
private static String TAG = "ChangeUserDetailsActivity";
|
|
||||||
|
|
||||||
private TextView email;
|
|
||||||
private TextView name;
|
|
||||||
private TextView changePw;
|
|
||||||
|
|
||||||
private FirebaseUser user;
|
|
||||||
|
|
||||||
private static final String EMAIL_CONSTANT = "Email Address";
|
|
||||||
private static final String PW_CONSTANT = "Password";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_change_user_details);
|
|
||||||
|
|
||||||
email = findViewById(R.id.change_email);
|
|
||||||
name = findViewById(R.id.change_profile_name);
|
|
||||||
changePw = findViewById(R.id.change_pw);
|
|
||||||
|
|
||||||
user = auth.getCurrentUser();
|
|
||||||
|
|
||||||
Button button = findViewById(R.id.submit_profile);
|
|
||||||
button.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
name.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
AlertDialog.Builder dialog = new AlertDialog.Builder(ChangeUserDetailsActivity.this);
|
|
||||||
dialog.setTitle("Update Username");
|
|
||||||
|
|
||||||
final EditText titleBox = new EditText(ChangeUserDetailsActivity.this);
|
|
||||||
titleBox.setText(user.getDisplayName());
|
|
||||||
dialog.setView(titleBox);
|
|
||||||
dialog.setPositiveButton("Update", new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
updateProfile(titleBox.getText().toString().trim());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.create().show();
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
email.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
showDialog(EMAIL_CONSTANT);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
changePw.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
showDialog(PW_CONSTANT);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateProfile(String profileName){
|
|
||||||
UserProfileChangeRequest.Builder profileUpdatesBuilder = new UserProfileChangeRequest.Builder();
|
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(profileName)){
|
|
||||||
profileUpdatesBuilder.setDisplayName(profileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
UserProfileChangeRequest profileUpdates = profileUpdatesBuilder.build();
|
|
||||||
|
|
||||||
user.updateProfile(profileUpdates)
|
|
||||||
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
|
||||||
@Override
|
|
||||||
public void onComplete(@NonNull Task<Void> task) {
|
|
||||||
if (task.isSuccessful()) {
|
|
||||||
Log.d(TAG, "User profile updated.");
|
|
||||||
// viewController.reloadDrawer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.addOnFailureListener(new OnFailureListener() {
|
|
||||||
@Override
|
|
||||||
public void onFailure(@NonNull Exception e) {
|
|
||||||
Toast.makeText(ChangeUserDetailsActivity.this, "Update Failed", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void changeCredentials(String email, String password, final String changeText, final String selector){
|
|
||||||
// Get auth credentials from the user for re-authentication
|
|
||||||
AuthCredential credential = EmailAuthProvider
|
|
||||||
.getCredential(email, password); // Current Login Credentials \\
|
|
||||||
// Prompt the user to re-provide their sign-in credentials
|
|
||||||
user.reauthenticate(credential)
|
|
||||||
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
|
||||||
@Override
|
|
||||||
public void onComplete(@NonNull Task<Void> task) {
|
|
||||||
Log.d(TAG, "User re-authenticated.");
|
|
||||||
|
|
||||||
user = FirebaseAuth.getInstance().getCurrentUser();
|
|
||||||
if (selector.equals(EMAIL_CONSTANT)){
|
|
||||||
user.updateEmail(changeText)
|
|
||||||
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
|
||||||
@Override
|
|
||||||
public void onComplete(@NonNull Task<Void> task) {
|
|
||||||
if (task.isSuccessful()) {
|
|
||||||
Log.d(TAG, "User email address updated.");
|
|
||||||
Toast.makeText(ChangeUserDetailsActivity.this, "Email Update Successful", Toast.LENGTH_SHORT).show();
|
|
||||||
|
|
||||||
// viewController.reloadDrawer();
|
|
||||||
}else {
|
|
||||||
Toast.makeText(ChangeUserDetailsActivity.this, "Email Update Unsuccessful", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (selector.equals(PW_CONSTANT)){
|
|
||||||
user.updatePassword(changeText)
|
|
||||||
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
|
||||||
@Override
|
|
||||||
public void onComplete(@NonNull Task<Void> task) {
|
|
||||||
if (task.isSuccessful()) {
|
|
||||||
Log.d(TAG, "User email address updated.");
|
|
||||||
Toast.makeText(ChangeUserDetailsActivity.this, "Password Update Successful", Toast.LENGTH_SHORT).show();
|
|
||||||
}else {
|
|
||||||
Toast.makeText(ChangeUserDetailsActivity.this, "Password Update Unsuccessful", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showDialog(final String update){
|
|
||||||
//Make new Dialog
|
|
||||||
AlertDialog.Builder dialog = new AlertDialog.Builder(ChangeUserDetailsActivity.this);
|
|
||||||
dialog.setTitle("Update " + update);
|
|
||||||
|
|
||||||
LinearLayout layout = new LinearLayout(ChangeUserDetailsActivity.this);
|
|
||||||
layout.setOrientation(LinearLayout.VERTICAL);
|
|
||||||
layout.setPadding(28,0,56,0);
|
|
||||||
|
|
||||||
final EditText box1 = new EditText(ChangeUserDetailsActivity.this);
|
|
||||||
box1.setHint("Current Email Address");
|
|
||||||
box1.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
|
|
||||||
layout.addView(box1); // Notice this is an add method
|
|
||||||
|
|
||||||
final EditText box2 = new EditText(ChangeUserDetailsActivity.this);
|
|
||||||
box2.setHint("Current Password");
|
|
||||||
box2.setInputType(InputType.TYPE_CLASS_TEXT |
|
|
||||||
InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
|
||||||
layout.addView(box2); // Another add method
|
|
||||||
|
|
||||||
final EditText box3 = new EditText(ChangeUserDetailsActivity.this);
|
|
||||||
if (update.equals(PW_CONSTANT)){
|
|
||||||
box3.setInputType(InputType.TYPE_CLASS_TEXT |
|
|
||||||
InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
|
||||||
}else {
|
|
||||||
box3.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
|
|
||||||
}
|
|
||||||
box3.setHint("New " + update);
|
|
||||||
layout.addView(box3); // Another add method
|
|
||||||
|
|
||||||
dialog.setView(layout);
|
|
||||||
dialog.setPositiveButton("Update", new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
String email = box1.getText().toString().trim();
|
|
||||||
String password = box2.getText().toString().trim();
|
|
||||||
String textThree = box3.getText().toString().trim();
|
|
||||||
|
|
||||||
changeCredentials(email,password,textThree,update);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.create().show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.Login;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.google.android.gms.tasks.OnCompleteListener;
|
|
||||||
import com.google.android.gms.tasks.Task;
|
|
||||||
import com.google.firebase.auth.FirebaseAuth;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
|
|
||||||
|
|
||||||
public class ForgotPassword extends Fragment {
|
|
||||||
|
|
||||||
String TAG = "forgotPasswordFragment";
|
|
||||||
private EditText editText;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
// Inflate the layout for this fragment
|
|
||||||
View view = inflater.inflate(R.layout.fragment_forgot_password, container, false);
|
|
||||||
|
|
||||||
editText = view.findViewById(R.id.reset_pw);
|
|
||||||
|
|
||||||
Button resetPw = view.findViewById(R.id.reset_pw_sign_up);
|
|
||||||
resetPw.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
resetPassword(editText.getText().toString().trim());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void resetPassword(String emailAddress){
|
|
||||||
FirebaseAuth auth = FirebaseAuth.getInstance();
|
|
||||||
|
|
||||||
auth.sendPasswordResetEmail(emailAddress)
|
|
||||||
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
|
||||||
@Override
|
|
||||||
public void onComplete(@NonNull Task<Void> task) {
|
|
||||||
if (task.isSuccessful()) {
|
|
||||||
Log.d(TAG, "Email sent.");
|
|
||||||
|
|
||||||
FullscreenActivity.fragmentManager.popBackStack();
|
|
||||||
}else {
|
|
||||||
Toast.makeText(getContext(), "Could not reset Password", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.Login;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.support.v4.app.ActivityCompat;
|
|
||||||
import android.support.v4.app.FragmentManager;
|
|
||||||
import android.support.v4.app.FragmentTransaction;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
import com.google.firebase.FirebaseApp;
|
|
||||||
import com.google.firebase.auth.FirebaseAuth;
|
|
||||||
|
|
||||||
|
|
||||||
public class FullscreenActivity extends AppCompatActivity {
|
|
||||||
|
|
||||||
protected static FragmentManager fragmentManager;
|
|
||||||
protected static FirebaseAuth auth;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_fullscreen);
|
|
||||||
|
|
||||||
FrameLayout frameLayout = findViewById(R.id.container);
|
|
||||||
|
|
||||||
auth = FirebaseAuth.getInstance();
|
|
||||||
|
|
||||||
fragmentManager = getSupportFragmentManager();
|
|
||||||
|
|
||||||
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
|
||||||
fragmentTransaction.replace(R.id.container,new BlankFragment()).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).commit();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
super.onBackPressed();
|
|
||||||
if (fragmentManager.getFragments().size() > 1){
|
|
||||||
fragmentManager.popBackStack();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,338 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.Login;
|
|
||||||
|
|
||||||
import android.animation.Animator;
|
|
||||||
import android.animation.AnimatorListenerAdapter;
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.provider.ContactsContract;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.support.design.widget.Snackbar;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.app.FragmentTransaction;
|
|
||||||
import android.support.v4.app.LoaderManager;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.inputmethod.EditorInfo;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.AutoCompleteTextView;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.MainActivity;
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
import com.google.android.gms.tasks.OnCompleteListener;
|
|
||||||
import com.google.android.gms.tasks.Task;
|
|
||||||
import com.google.firebase.auth.AuthResult;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static android.Manifest.permission.READ_CONTACTS;
|
|
||||||
|
|
||||||
public class LoginFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Id to identity READ_CONTACTS permission request.
|
|
||||||
*/
|
|
||||||
private static final int REQUEST_READ_CONTACTS = 0;
|
|
||||||
|
|
||||||
// UI references.
|
|
||||||
private AutoCompleteTextView mEmailView;
|
|
||||||
private EditText mPasswordView;
|
|
||||||
private View mProgressView;
|
|
||||||
private View mLoginFormView;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
// Inflate the layout for this fragment
|
|
||||||
View view = inflater.inflate(R.layout.fragment_login, container, false);
|
|
||||||
|
|
||||||
// Set up the login form.
|
|
||||||
mEmailView = (AutoCompleteTextView) view.findViewById(R.id.email);
|
|
||||||
populateAutoComplete();
|
|
||||||
|
|
||||||
mPasswordView = (EditText) view.findViewById(R.id.password);
|
|
||||||
mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
|
|
||||||
if (id == EditorInfo.IME_ACTION_DONE || id == EditorInfo.IME_NULL) {
|
|
||||||
attemptLogin();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
TextView forgotPassWord = view.findViewById(R.id.forgot);
|
|
||||||
forgotPassWord.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
FullscreenActivity.fragmentManager.beginTransaction()
|
|
||||||
.setCustomAnimations(android.R.anim.fade_in,android.R.anim.fade_in)
|
|
||||||
.replace(R.id.container,new ForgotPassword())
|
|
||||||
.addToBackStack("forgot_pw").commit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
TextView register = view.findViewById(R.id.register_button);
|
|
||||||
register.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
FullscreenActivity.fragmentManager.beginTransaction()
|
|
||||||
.setCustomAnimations(android.R.anim.fade_in,android.R.anim.fade_in)
|
|
||||||
.replace(R.id.container,new Register())
|
|
||||||
.addToBackStack("register")
|
|
||||||
.commit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Button mEmailSignInButton = (Button) view.findViewById(R.id.email_sign_in_button);
|
|
||||||
mEmailSignInButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
attemptLogin();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
mLoginFormView = view.findViewById(R.id.email_login_form);
|
|
||||||
mProgressView = view.findViewById(R.id.login_progress);
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void populateAutoComplete() {
|
|
||||||
if (!mayRequestContacts()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
getLoaderManager().initLoader(0, null, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean mayRequestContacts() {
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (getActivity().checkSelfPermission(READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (shouldShowRequestPermissionRationale(READ_CONTACTS)) {
|
|
||||||
Snackbar.make(mEmailView, R.string.permission_rationale, Snackbar.LENGTH_INDEFINITE)
|
|
||||||
.setAction(android.R.string.ok, new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
@TargetApi(Build.VERSION_CODES.M)
|
|
||||||
public void onClick(View v) {
|
|
||||||
requestPermissions(new String[]{READ_CONTACTS}, REQUEST_READ_CONTACTS);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
requestPermissions(new String[]{READ_CONTACTS}, REQUEST_READ_CONTACTS);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback received when a permissions request has been completed.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
|
||||||
@NonNull int[] grantResults) {
|
|
||||||
if (requestCode == REQUEST_READ_CONTACTS) {
|
|
||||||
if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
|
||||||
populateAutoComplete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempts to sign in or register the account specified by the login form.
|
|
||||||
* If there are form errors (invalid email, missing fields, etc.), the
|
|
||||||
* errors are presented and no actual login attempt is made.
|
|
||||||
*/
|
|
||||||
private void attemptLogin() {
|
|
||||||
if (FullscreenActivity.auth == null) {
|
|
||||||
Toast.makeText(getContext(), "Login invalid", Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset errors.
|
|
||||||
mEmailView.setError(null);
|
|
||||||
mPasswordView.setError(null);
|
|
||||||
|
|
||||||
// Store values at the time of the login attempt.
|
|
||||||
String email = mEmailView.getText().toString();
|
|
||||||
String password = mPasswordView.getText().toString();
|
|
||||||
|
|
||||||
boolean cancel = false;
|
|
||||||
View focusView = null;
|
|
||||||
|
|
||||||
// Check for a valid password, if the user entered one.
|
|
||||||
if (!TextUtils.isEmpty(password) && !isPasswordValid(password)) {
|
|
||||||
mPasswordView.setError(getString(R.string.error_invalid_password));
|
|
||||||
focusView = mPasswordView;
|
|
||||||
cancel = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for a valid email address.
|
|
||||||
if (TextUtils.isEmpty(email)) {
|
|
||||||
mEmailView.setError(getString(R.string.error_field_required));
|
|
||||||
focusView = mEmailView;
|
|
||||||
cancel = true;
|
|
||||||
} else if (!isEmailValid(email)) {
|
|
||||||
mEmailView.setError(getString(R.string.error_invalid_email));
|
|
||||||
focusView = mEmailView;
|
|
||||||
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.
|
|
||||||
showProgress(true);
|
|
||||||
FullscreenActivity.auth.signInWithEmailAndPassword(email,password)
|
|
||||||
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
|
|
||||||
@Override
|
|
||||||
public void onComplete(@NonNull Task<AuthResult> task) {
|
|
||||||
showProgress(false);
|
|
||||||
if (task.isSuccessful()){
|
|
||||||
Intent intent = new Intent(getContext(),MainActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
getActivity().finish();
|
|
||||||
}else {
|
|
||||||
Toast.makeText(getContext(), getString(R.string.login_failed), Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isEmailValid(String email) {
|
|
||||||
//TODO: Replace this with your own logic
|
|
||||||
return email.contains("@");
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isPasswordValid(String password) {
|
|
||||||
//TODO: Replace this with your own logic
|
|
||||||
return password.length() > 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shows the progress UI and hides the login form.
|
|
||||||
*/
|
|
||||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
|
|
||||||
private void showProgress(final boolean show) {
|
|
||||||
// On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
|
|
||||||
// for very easy animations. If available, use these APIs to fade-in
|
|
||||||
// the progress spinner.
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
|
|
||||||
int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
|
|
||||||
|
|
||||||
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
|
|
||||||
mLoginFormView.animate().setDuration(shortAnimTime).alpha(
|
|
||||||
show ? 0 : 1).setListener(new AnimatorListenerAdapter() {
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animator animation) {
|
|
||||||
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
|
|
||||||
mProgressView.animate().setDuration(shortAnimTime).alpha(
|
|
||||||
show ? 1 : 0).setListener(new AnimatorListenerAdapter() {
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animator animation) {
|
|
||||||
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// The ViewPropertyAnimator APIs are not available, so simply show
|
|
||||||
// and hide the relevant UI components.
|
|
||||||
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
|
|
||||||
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addEmailsToAutoComplete(List<String> emailAddressCollection) {
|
|
||||||
//Create adapter to tell the AutoCompleteTextView what to show in its dropdown list.
|
|
||||||
ArrayAdapter<String> adapter =
|
|
||||||
new ArrayAdapter<>(getContext(),
|
|
||||||
android.R.layout.simple_dropdown_item_1line, emailAddressCollection);
|
|
||||||
|
|
||||||
mEmailView.setAdapter(adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public android.support.v4.content.Loader<Cursor> onCreateLoader(int i, @Nullable Bundle bundle) {
|
|
||||||
|
|
||||||
// Retrieve data rows for the device user's 'profile' contact.
|
|
||||||
Uri uri = Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,ContactsContract.Contacts.Data.CONTENT_DIRECTORY);
|
|
||||||
// Select only email addresses.
|
|
||||||
String selection = ContactsContract.Contacts.Data.MIMETYPE + " = ?";
|
|
||||||
String[] selections = new String[]{ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE};
|
|
||||||
// Show primary email addresses first. Note that there won't be
|
|
||||||
// a primary email address if the user hasn't specified one.
|
|
||||||
String sortOrder = ContactsContract.Contacts.Data.IS_PRIMARY + " DESC";
|
|
||||||
|
|
||||||
return new android.support.v4.content.CursorLoader(getContext(),
|
|
||||||
uri,
|
|
||||||
ProfileQuery.PROJECTION,
|
|
||||||
selection,
|
|
||||||
selections,
|
|
||||||
sortOrder);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoadFinished(@NonNull android.support.v4.content.Loader<Cursor> loader, Cursor cursor) {
|
|
||||||
List<String> emails = new ArrayList<>();
|
|
||||||
cursor.moveToFirst();
|
|
||||||
while (!cursor.isAfterLast()) {
|
|
||||||
emails.add(cursor.getString(ProfileQuery.ADDRESS));
|
|
||||||
cursor.moveToNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
addEmailsToAutoComplete(emails);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoaderReset(@NonNull android.support.v4.content.Loader<Cursor> loader) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private interface ProfileQuery {
|
|
||||||
String[] PROJECTION = {
|
|
||||||
ContactsContract.CommonDataKinds.Email.ADDRESS,
|
|
||||||
ContactsContract.CommonDataKinds.Email.IS_PRIMARY,
|
|
||||||
};
|
|
||||||
|
|
||||||
int ADDRESS = 0;
|
|
||||||
int IS_PRIMARY = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,176 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.Login;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.Objects.UserObject;
|
|
||||||
import com.google.android.gms.tasks.OnCompleteListener;
|
|
||||||
import com.google.android.gms.tasks.Task;
|
|
||||||
import com.google.firebase.auth.AuthResult;
|
|
||||||
import com.google.firebase.auth.FirebaseAuth;
|
|
||||||
import com.google.firebase.auth.UserProfileChangeRequest;
|
|
||||||
import com.google.firebase.database.DatabaseReference;
|
|
||||||
import com.google.firebase.database.FirebaseDatabase;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.MainActivity;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.USER_FIREBASE;
|
|
||||||
|
|
||||||
public class Register extends Fragment {
|
|
||||||
|
|
||||||
private String TAG = "LoginActivity";
|
|
||||||
private FirebaseAuth auth;
|
|
||||||
|
|
||||||
// UI references.
|
|
||||||
private EditText name;
|
|
||||||
private EditText email;
|
|
||||||
private EditText passwordTop;
|
|
||||||
private EditText passwordBottom;
|
|
||||||
private ProgressBar progressBar;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
// Inflate the layout for this fragment
|
|
||||||
View view = inflater.inflate(R.layout.fragment_register, container, false);
|
|
||||||
|
|
||||||
auth = FirebaseAuth.getInstance();
|
|
||||||
|
|
||||||
name = view.findViewById(R.id.name_register);
|
|
||||||
email = view.findViewById(R.id.email_register);
|
|
||||||
passwordTop = view.findViewById(R.id.password_top);
|
|
||||||
passwordBottom = view.findViewById(R.id.password_bottom);
|
|
||||||
progressBar = view.findViewById(R.id.pb);
|
|
||||||
Button submit = view.findViewById(R.id.email_sign_up);
|
|
||||||
|
|
||||||
submit.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
|
|
||||||
final String nameString = name.getText().toString().trim();
|
|
||||||
String emailText = email.getText().toString().trim();
|
|
||||||
String passwordText = passwordTop.getText().toString().trim();
|
|
||||||
String passwordTextBottom = passwordBottom.getText().toString().trim();
|
|
||||||
|
|
||||||
boolean cancel = false;
|
|
||||||
View focusView = null;
|
|
||||||
|
|
||||||
if (TextUtils.isEmpty(nameString)) {
|
|
||||||
name.setError(getString(R.string.error_field_required));
|
|
||||||
focusView = name;
|
|
||||||
cancel = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TextUtils.isEmpty(emailText)) {
|
|
||||||
email.setError(getString(R.string.error_field_required));
|
|
||||||
focusView = email;
|
|
||||||
cancel = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TextUtils.isEmpty(passwordText)) {
|
|
||||||
passwordTop.setError(getString(R.string.error_field_required));
|
|
||||||
focusView = passwordTop;
|
|
||||||
cancel = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TextUtils.isEmpty(passwordTextBottom)) {
|
|
||||||
passwordBottom.setError(getString(R.string.error_field_required));
|
|
||||||
focusView = passwordBottom;
|
|
||||||
cancel = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(passwordText) && !isPasswordValid(passwordText)) {
|
|
||||||
passwordTop.setError(getString(R.string.error_invalid_password));
|
|
||||||
focusView = passwordTop;
|
|
||||||
cancel = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!passwordText.equals(passwordTextBottom)){
|
|
||||||
passwordBottom.setError(getString(R.string.no_match_password));
|
|
||||||
focusView = passwordBottom;
|
|
||||||
cancel = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cancel) {
|
|
||||||
// There was an error; don't attempt login and focus the first
|
|
||||||
// form field with an error.
|
|
||||||
focusView.requestFocus();
|
|
||||||
} else {
|
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
|
||||||
//create user
|
|
||||||
auth.createUserWithEmailAndPassword(emailText, passwordText)
|
|
||||||
.addOnCompleteListener(getActivity(), new OnCompleteListener<AuthResult>() {
|
|
||||||
@Override
|
|
||||||
public void onComplete(@NonNull Task<AuthResult> task) {
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
if (!task.isSuccessful()) {
|
|
||||||
Toast.makeText(getContext(), "Authentication failed." + task.getException(),
|
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
} else {
|
|
||||||
|
|
||||||
UserProfileChangeRequest.Builder profileUpdatesBuilder = new UserProfileChangeRequest.Builder();
|
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(nameString)){
|
|
||||||
profileUpdatesBuilder.setDisplayName(nameString);
|
|
||||||
}
|
|
||||||
|
|
||||||
UserProfileChangeRequest profileUpdates = profileUpdatesBuilder.build();
|
|
||||||
|
|
||||||
auth.getCurrentUser().updateProfile(profileUpdates).addOnCompleteListener(new OnCompleteListener<Void>() {
|
|
||||||
@Override
|
|
||||||
public void onComplete(@NonNull Task<Void> task) {
|
|
||||||
if (task.isSuccessful()){
|
|
||||||
Log.i("RegisterActivity", "onComplete: " + task.isSuccessful());
|
|
||||||
|
|
||||||
DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference();
|
|
||||||
|
|
||||||
mDatabase.child(USER_FIREBASE).child(auth.getCurrentUser().getUid()).child("role")
|
|
||||||
.setValue("driver");
|
|
||||||
mDatabase.child(USER_FIREBASE).child(auth.getCurrentUser().getUid()).child("user_details")
|
|
||||||
.setValue(new UserObject(auth.getCurrentUser().getDisplayName(),auth.getCurrentUser().getEmail(),null));
|
|
||||||
|
|
||||||
Intent intent = new Intent(getContext(),MainActivity.class);
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
||||||
startActivity(intent);
|
|
||||||
getActivity().finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isPasswordValid(String password) {
|
|
||||||
//TODO: Replace this with your own logic
|
|
||||||
return password.length() > 6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,328 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left;
|
|
||||||
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.design.widget.BottomNavigationView;
|
|
||||||
import android.support.design.widget.FloatingActionButton;
|
|
||||||
import android.support.design.widget.NavigationView;
|
|
||||||
import android.support.v4.app.FragmentManager;
|
|
||||||
import android.support.v4.app.FragmentTransaction;
|
|
||||||
import android.support.v4.view.GravityCompat;
|
|
||||||
import android.support.v4.widget.DrawerLayout;
|
|
||||||
import android.support.v7.app.ActionBarDrawerToggle;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.AddItems.AddShiftActivity;
|
|
||||||
import com.appttude.h_mal.days_left.Login.ChangeUserDetailsActivity;
|
|
||||||
import com.appttude.h_mal.days_left.Login.FullscreenActivity;
|
|
||||||
import com.appttude.h_mal.days_left.Objects.ShiftObject;
|
|
||||||
import com.google.android.gms.tasks.OnCompleteListener;
|
|
||||||
import com.google.android.gms.tasks.Task;
|
|
||||||
import com.google.firebase.auth.FirebaseUser;
|
|
||||||
import com.google.firebase.database.DataSnapshot;
|
|
||||||
import com.google.firebase.database.DatabaseError;
|
|
||||||
import com.google.firebase.database.DatabaseReference;
|
|
||||||
import com.google.firebase.database.FirebaseDatabase;
|
|
||||||
import com.google.firebase.database.ValueEventListener;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import com.squareup.picasso.Picasso;
|
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.SHIFT_FIREBASE;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.USER_FIREBASE;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.auth;
|
|
||||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.mDatabase;
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
|
||||||
|
|
||||||
public String currentFragment;
|
|
||||||
private Toolbar toolbar;
|
|
||||||
public static FragmentManager fragmentManager;
|
|
||||||
private ProgressBar progressBar;
|
|
||||||
public NavigationView navigationView;
|
|
||||||
|
|
||||||
private DatabaseReference reference;
|
|
||||||
public static List<ShiftObject> shiftObjectArrayList;
|
|
||||||
public static Map<String,ShiftObject> shiftsMap = new HashMap<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_drawer_main);
|
|
||||||
|
|
||||||
shiftObjectArrayList = new ArrayList<>();
|
|
||||||
|
|
||||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
|
||||||
progressBar = (ProgressBar) findViewById(R.id.progressBar2);
|
|
||||||
FloatingActionButton fab = findViewById(R.id.fab);
|
|
||||||
|
|
||||||
setSupportActionBar(toolbar);
|
|
||||||
|
|
||||||
fragmentManager = getSupportFragmentManager();
|
|
||||||
fragmentManager.addOnBackStackChangedListener(backStackChangedListener);
|
|
||||||
|
|
||||||
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
|
|
||||||
reference = mDatabase.child(USER_FIREBASE).child(auth.getUid()).child(SHIFT_FIREBASE);
|
|
||||||
reference.addValueEventListener(new CustomValueEventListener(this,fragmentManager,progressBar));
|
|
||||||
|
|
||||||
fab.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
Intent intent = new Intent(MainActivity.this,AddShiftActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
|
||||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
|
||||||
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
|
||||||
drawer.addDrawerListener(toggle);
|
|
||||||
toggle.syncState();
|
|
||||||
|
|
||||||
navigationView = (NavigationView) findViewById(R.id.nav_view);
|
|
||||||
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
|
|
||||||
// Handle navigation view item clicks here.
|
|
||||||
int id = menuItem.getItemId();
|
|
||||||
|
|
||||||
if (id == R.id.nav_camera) {
|
|
||||||
// // Handle the camera action
|
|
||||||
Intent ChangeDetailsIntent = new Intent(MainActivity.this,ChangeUserDetailsActivity.class);
|
|
||||||
startActivity(ChangeDetailsIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
|
||||||
drawer.closeDrawer(GravityCompat.START);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setupDrawer();
|
|
||||||
|
|
||||||
parseXmlLayout();
|
|
||||||
|
|
||||||
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
|
|
||||||
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
|
|
||||||
= new BottomNavigationView.OnNavigationItemSelectedListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
|
||||||
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
|
||||||
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.navigation_home:
|
|
||||||
fragmentTransaction.replace(R.id.container,new FragmentHome()).commit();
|
|
||||||
return true;
|
|
||||||
case R.id.navigation_list:
|
|
||||||
fragmentTransaction.replace(R.id.container,new FragmentList()).commit();
|
|
||||||
return true;
|
|
||||||
case R.id.navigation_tools:
|
|
||||||
fragmentTransaction.replace(R.id.container,new FragmentTools()).commit();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public FragmentManager.OnBackStackChangedListener backStackChangedListener= new FragmentManager.OnBackStackChangedListener() {
|
|
||||||
@Override
|
|
||||||
public void onBackStackChanged() {
|
|
||||||
String fragmentString = fragmentManager.getFragments().get(0).getClass().getSimpleName();
|
|
||||||
String title;
|
|
||||||
|
|
||||||
switch (fragmentString){
|
|
||||||
case "DriverProfileFragment":
|
|
||||||
title = "Driver Profile";
|
|
||||||
break;
|
|
||||||
case "DriverLicenseFragment":
|
|
||||||
title = "Drivers License";
|
|
||||||
break;
|
|
||||||
case "InsuranceFragment":
|
|
||||||
title = "Insurance";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
title = getResources().getString(R.string.app_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
setTitle(title);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public void setupDrawer(){
|
|
||||||
View header = navigationView.getHeaderView(0);
|
|
||||||
|
|
||||||
TextView driverEmail = header.findViewById(R.id.driver_email);
|
|
||||||
TextView driverName = header.findViewById(R.id.driver_name);
|
|
||||||
ImageView driverImage = header.findViewById(R.id.profileImage);
|
|
||||||
|
|
||||||
if (auth != null){
|
|
||||||
FirebaseUser user = auth.getCurrentUser();
|
|
||||||
if (user.getEmail() != null){
|
|
||||||
driverEmail.setText(user.getEmail());
|
|
||||||
}
|
|
||||||
if (user.getDisplayName() != null){
|
|
||||||
driverName.setText(user.getDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
Picasso.get()
|
|
||||||
.load(user.getPhotoUrl())
|
|
||||||
.placeholder(R.mipmap.ic_launcher_round)
|
|
||||||
.into(driverImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
TextView textView = findViewById(R.id.logout);
|
|
||||||
textView.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
auth.signOut();
|
|
||||||
Intent intent = new Intent(getApplicationContext(),FullscreenActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTitle(CharSequence title) {
|
|
||||||
toolbar.setTitle(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
|
||||||
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
|
||||||
drawer.closeDrawer(GravityCompat.START);
|
|
||||||
} else {
|
|
||||||
if (fragmentManager.getBackStackEntryCount() > 1) {
|
|
||||||
fragmentManager.popBackStack();
|
|
||||||
}else{
|
|
||||||
new AlertDialog.Builder(this)
|
|
||||||
.setTitle("Leave?")
|
|
||||||
.setMessage("Are you sure you want to exit?")
|
|
||||||
.setNegativeButton(android.R.string.no, null)
|
|
||||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface arg0, int arg1) {
|
|
||||||
finish();
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
}).create().show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printObjectAsJson(String TAG, Object o){
|
|
||||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
|
||||||
JsonParser jp = new JsonParser();
|
|
||||||
JsonElement je = jp.parse(new Gson().toJson(o));
|
|
||||||
String prettyJsonString = gson.toJson(je);
|
|
||||||
|
|
||||||
Log.i(TAG, "onBindViewHolder: object" + prettyJsonString);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void parseXmlLayout(){
|
|
||||||
final String ANDROID_ID = "android:id";
|
|
||||||
String TAG = "parsingxml";
|
|
||||||
boolean fragment = true;
|
|
||||||
String preString = "";
|
|
||||||
|
|
||||||
if (fragment){
|
|
||||||
preString = "view.";
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
InputStream is = getResources().openRawResource(R.raw.fragment_add_employer);
|
|
||||||
|
|
||||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
|
||||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
|
||||||
|
|
||||||
Document doc = dBuilder.parse(is);
|
|
||||||
doc.getDocumentElement().normalize();
|
|
||||||
|
|
||||||
NodeList nList = doc.getElementsByTagName("*");
|
|
||||||
|
|
||||||
for (int temp = 0; temp < nList.getLength(); temp++) {
|
|
||||||
Node nNode = nList.item(temp);
|
|
||||||
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
|
|
||||||
Element eElement = (Element) nNode;
|
|
||||||
|
|
||||||
if (eElement.hasAttribute(ANDROID_ID)){
|
|
||||||
String view = eElement.getTagName();
|
|
||||||
String Id = eElement.getAttribute(ANDROID_ID).replace("@+id/","");
|
|
||||||
|
|
||||||
Log.i(TAG, view + " " + getFieldName(Id,view) + " = " + preString
|
|
||||||
+ "findViewById(R.id." + Id + ");");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "parseXmlLayout: ", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getFieldName (String name,String view){
|
|
||||||
if (name.contains("_")){
|
|
||||||
int index = name.indexOf("_");
|
|
||||||
name = name.replace("_","");
|
|
||||||
|
|
||||||
char[] array = name.toCharArray();
|
|
||||||
array[index] = Character.toUpperCase(array[index]);
|
|
||||||
name = new String(array);
|
|
||||||
}
|
|
||||||
|
|
||||||
name = name + view;
|
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String Epoch2DateString(long epochSeconds, String formatString) {
|
|
||||||
Date updatedate = new Date(epochSeconds * 1000);
|
|
||||||
SimpleDateFormat format = new SimpleDateFormat(formatString);
|
|
||||||
return format.format(updatedate);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int[] Epoch2DateTimes(int epochSeconds) {
|
|
||||||
Date updatedate = new Date(epochSeconds);
|
|
||||||
SimpleDateFormat format = new SimpleDateFormat("hh:mm");
|
|
||||||
String time = format.format(updatedate);
|
|
||||||
|
|
||||||
int[] array = new int[]{Integer.parseInt(time.split(":")[0]),Integer.parseInt(time.split(":")[1])};
|
|
||||||
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,133 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.BaseAdapter;
|
|
||||||
import android.widget.Filter;
|
|
||||||
import android.widget.Filterable;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.Objects.ShiftObject;
|
|
||||||
import com.appttude.h_mal.days_left.Objects.TaskObject;
|
|
||||||
import com.appttude.h_mal.days_left.Objects.TimeObject;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class MapListViewAdapter extends BaseAdapter implements Filterable {
|
|
||||||
|
|
||||||
private Context context;
|
|
||||||
private final ArrayList mData;
|
|
||||||
|
|
||||||
public MapListViewAdapter(Context context, Map<String,ShiftObject> map) {
|
|
||||||
this.context = context;
|
|
||||||
mData = new ArrayList();
|
|
||||||
mData.addAll(map.entrySet());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ShiftObject getItem(int position) {
|
|
||||||
return (ShiftObject)((Map.Entry) mData.get(position)).getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getItemId(int position) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId(int position){
|
|
||||||
return (String) ((Map.Entry) mData.get(position)).getKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
|
||||||
View listItemView = convertView;
|
|
||||||
if (convertView == null){
|
|
||||||
listItemView = LayoutInflater.from(context).inflate(R.layout.list_item, parent,false);
|
|
||||||
}
|
|
||||||
|
|
||||||
ShiftObject currentShift = getItem(position);
|
|
||||||
|
|
||||||
TextView farmNameTextView = listItemView.findViewById(R.id.farm_name);
|
|
||||||
TextView dateTextView = listItemView.findViewById(R.id.date);
|
|
||||||
TextView tastTextView = listItemView.findViewById(R.id.task_name);
|
|
||||||
TextView typeTextView = listItemView.findViewById(R.id.type);
|
|
||||||
LinearLayout timeHolderLinearLayout = listItemView.findViewById(R.id.time_holder);
|
|
||||||
TextView timeTextView = listItemView.findViewById(R.id.time);
|
|
||||||
LinearLayout breakHolderLinearLayout = listItemView.findViewById(R.id.break_holder);
|
|
||||||
TextView breakTimeTextView = listItemView.findViewById(R.id.break_time);
|
|
||||||
LinearLayout unitsHolderLinearLayout = listItemView.findViewById(R.id.units_holder);
|
|
||||||
TextView unitsTextView = listItemView.findViewById(R.id.units);
|
|
||||||
TextView locationTextView = listItemView.findViewById(R.id.location);
|
|
||||||
|
|
||||||
dateTextView.setText(currentShift.getShiftDate());
|
|
||||||
|
|
||||||
TaskObject taskObject = currentShift.getTaskObject();
|
|
||||||
tastTextView.setText(taskObject.getTask());
|
|
||||||
String s = taskObject.getWorkType() + " - $" + taskObject.getRate() + "/";
|
|
||||||
if (taskObject.getWorkType().equals("Hourly")){
|
|
||||||
s = s + "Hour";
|
|
||||||
timeHolderLinearLayout.setVisibility(View.VISIBLE);
|
|
||||||
unitsHolderLinearLayout.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
TimeObject timeObject = currentShift.getTimeObject();
|
|
||||||
|
|
||||||
timeTextView.setText(timeObject.getTimeIn() + " - " + timeObject.getTimeOut());
|
|
||||||
|
|
||||||
if (timeObject.getBreakEpoch() > 0){
|
|
||||||
breakHolderLinearLayout.setVisibility(View.VISIBLE);
|
|
||||||
String breakString = getBreakTimeString(timeObject.getBreakEpoch());
|
|
||||||
breakTimeTextView.setText(breakString);
|
|
||||||
}else {
|
|
||||||
breakHolderLinearLayout.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
unitsTextView.setText(String.valueOf(timeObject.getHours()));
|
|
||||||
|
|
||||||
}else {
|
|
||||||
s = s + "Unit";
|
|
||||||
timeHolderLinearLayout.setVisibility(View.GONE);
|
|
||||||
unitsHolderLinearLayout.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
unitsTextView.setText(String.valueOf(currentShift.getUnitsCount()));
|
|
||||||
}
|
|
||||||
|
|
||||||
typeTextView.setText(s);
|
|
||||||
farmNameTextView.setText(currentShift.getAbnObject().getCompanyName());
|
|
||||||
|
|
||||||
locationTextView.setText(currentShift.getAbnObject().getState() + " - " + currentShift.getAbnObject().getPostCode());
|
|
||||||
|
|
||||||
return listItemView;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Filter getFilter() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getBreakTimeString(int breakMins){
|
|
||||||
float hoursFloat = breakMins/60;
|
|
||||||
|
|
||||||
int hoursInt = (int) Math.floor(hoursFloat);
|
|
||||||
int minsInt = breakMins - (hoursInt*60);
|
|
||||||
|
|
||||||
String s = "";
|
|
||||||
if (hoursInt > 0){
|
|
||||||
s = hoursInt + " h" + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (minsInt > 0){
|
|
||||||
s = s + minsInt + " m";
|
|
||||||
}
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.Objects;
|
|
||||||
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
import com.appttude.h_mal.days_left.bar.BarView;
|
|
||||||
|
|
||||||
public class CustomViewHolder extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
BarView barView;
|
|
||||||
LinearLayout linearLayout;
|
|
||||||
|
|
||||||
public CustomViewHolder(View itemView){
|
|
||||||
super(itemView);
|
|
||||||
|
|
||||||
barView = itemView.findViewById(R.id.bar);
|
|
||||||
linearLayout = itemView.findViewById(R.id.lin);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.Objects;
|
|
||||||
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.support.design.widget.FloatingActionButton;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.Abn.AbnObject;
|
|
||||||
import com.appttude.h_mal.days_left.Login.LoginFragment;
|
|
||||||
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class ShiftObject {
|
|
||||||
|
|
||||||
public String shiftDate;
|
|
||||||
public String dateTimeAdded;
|
|
||||||
public AbnObject abnObject;
|
|
||||||
public TaskObject taskObject;
|
|
||||||
public Float unitsCount;
|
|
||||||
public TimeObject timeObject;
|
|
||||||
|
|
||||||
public ShiftObject(String shiftDate, String dateTimeAdded, AbnObject abnObject, TaskObject taskObject, @Nullable Float unitsCount, @Nullable TimeObject timeObject) {
|
|
||||||
this.shiftDate = shiftDate;
|
|
||||||
this.dateTimeAdded = dateTimeAdded;
|
|
||||||
this.abnObject = abnObject;
|
|
||||||
this.taskObject = taskObject;
|
|
||||||
this.unitsCount = unitsCount;
|
|
||||||
this.timeObject = timeObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShiftObject() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getShiftDate() {
|
|
||||||
return shiftDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDateTimeAdded() {
|
|
||||||
return dateTimeAdded;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AbnObject getAbnObject() {
|
|
||||||
return abnObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TaskObject getTaskObject() {
|
|
||||||
return taskObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Float getUnitsCount() {
|
|
||||||
return unitsCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TimeObject getTimeObject() {
|
|
||||||
return timeObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShiftDate(String shiftDate) {
|
|
||||||
this.shiftDate = shiftDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void changeDate(){
|
|
||||||
SimpleDateFormat dt = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
|
||||||
Date date = null;
|
|
||||||
try {
|
|
||||||
date = dt.parse(dateTimeAdded);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
Log.i("DateChange", "changeDate: " + dateTimeAdded + " -> " + dt1.format(date));
|
|
||||||
|
|
||||||
this.dateTimeAdded = dt1.format(date);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.Objects;
|
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
|
|
||||||
public class TaskObject implements Parcelable {
|
|
||||||
|
|
||||||
private String workType;
|
|
||||||
private float rate;
|
|
||||||
private String task;
|
|
||||||
private String dateAddedToDb;
|
|
||||||
private String userIdOfCreator;
|
|
||||||
|
|
||||||
public TaskObject() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public TaskObject(String workType, float rate, String task, @Nullable String dateAddedToDb, @Nullable String userIdOfCreater) {
|
|
||||||
this.workType = workType;
|
|
||||||
this.rate = rate;
|
|
||||||
this.task = task;
|
|
||||||
this.dateAddedToDb = dateAddedToDb;
|
|
||||||
this.userIdOfCreator = userIdOfCreater;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected TaskObject(Parcel in) {
|
|
||||||
workType = in.readString();
|
|
||||||
rate = in.readFloat();
|
|
||||||
task = in.readString();
|
|
||||||
dateAddedToDb = in.readString();
|
|
||||||
userIdOfCreator = in.readString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Creator<TaskObject> CREATOR = new Creator<TaskObject>() {
|
|
||||||
@Override
|
|
||||||
public TaskObject createFromParcel(Parcel in) {
|
|
||||||
return new TaskObject(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskObject[] newArray(int size) {
|
|
||||||
return new TaskObject[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public String getWorkType() {
|
|
||||||
return workType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWorkType(String workType) {
|
|
||||||
this.workType = workType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getRate() {
|
|
||||||
return rate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRate(float rate) {
|
|
||||||
this.rate = rate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTask() {
|
|
||||||
return task;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTask(String task) {
|
|
||||||
this.task = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDateAddedToDb() {
|
|
||||||
return dateAddedToDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDateAddedToDb(String dateAddedToDb) {
|
|
||||||
this.dateAddedToDb = dateAddedToDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUserIdOfCreator() {
|
|
||||||
return userIdOfCreator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserIdOfCreator(String userIdOfCreator) {
|
|
||||||
this.userIdOfCreator = userIdOfCreator;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
dest.writeString(workType);
|
|
||||||
dest.writeFloat(rate);
|
|
||||||
dest.writeString(task);
|
|
||||||
dest.writeString(dateAddedToDb);
|
|
||||||
dest.writeString(userIdOfCreator);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.Objects;
|
|
||||||
|
|
||||||
public class TimeObject {
|
|
||||||
|
|
||||||
private String timeIn;
|
|
||||||
private String timeOut;
|
|
||||||
private int breakEpoch;
|
|
||||||
private float hours;
|
|
||||||
|
|
||||||
public TimeObject(String timeIn, String timeOut, int breakEpoch, float hours) {
|
|
||||||
this.timeIn = timeIn;
|
|
||||||
this.timeOut = timeOut;
|
|
||||||
this.breakEpoch = breakEpoch;
|
|
||||||
this.hours = hours;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TimeObject() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTimeIn() {
|
|
||||||
return timeIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTimeIn(String timeIn) {
|
|
||||||
this.timeIn = timeIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTimeOut() {
|
|
||||||
return timeOut;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTimeOut(String timeOut) {
|
|
||||||
this.timeOut = timeOut;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBreakEpoch() {
|
|
||||||
return breakEpoch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBreakEpoch(int breakEpoch) {
|
|
||||||
this.breakEpoch = breakEpoch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getHours() {
|
|
||||||
return hours;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHours(float hours) {
|
|
||||||
this.hours = hours;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.Objects;
|
|
||||||
|
|
||||||
public class UserObject {
|
|
||||||
|
|
||||||
public String profileName;
|
|
||||||
public String profileEmail;
|
|
||||||
public String profilePicString;
|
|
||||||
|
|
||||||
public UserObject() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserObject(String profileName, String profileEmail, String profilePicString) {
|
|
||||||
this.profileName = profileName;
|
|
||||||
this.profileEmail = profileEmail;
|
|
||||||
this.profilePicString = profilePicString;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProfileName() {
|
|
||||||
return profileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProfileEmail() {
|
|
||||||
return profileEmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProfilePicString() {
|
|
||||||
return profilePicString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,320 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
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 com.appttude.h_mal.days_left.Objects.ShiftObject;
|
|
||||||
import com.appttude.h_mal.days_left.arc.ArcAnimation;
|
|
||||||
import com.appttude.h_mal.days_left.bar.BarAnimation;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.arc.CircleView;
|
|
||||||
import com.appttude.h_mal.days_left.bar.BarView;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
||||||
|
|
||||||
String TAG = "something";
|
|
||||||
|
|
||||||
private Context context;
|
|
||||||
private List<ShiftObject> shiftObjectList;
|
|
||||||
private int uniqueEntries;
|
|
||||||
private int[] typeCount;
|
|
||||||
|
|
||||||
public RecyclerViewAdapter(Context context, List<ShiftObject> shiftObjectList) {
|
|
||||||
this.context = context;
|
|
||||||
this.shiftObjectList = shiftObjectList;
|
|
||||||
uniqueEntries = countDistinct();
|
|
||||||
typeCount = countShiftType();
|
|
||||||
}
|
|
||||||
|
|
||||||
class ItemOne extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
CircleView arc;
|
|
||||||
TextView days;
|
|
||||||
|
|
||||||
public ItemOne(View itemView){
|
|
||||||
super(itemView);
|
|
||||||
arc = itemView.findViewById(R.id.arc_view);
|
|
||||||
days = itemView.findViewById(R.id.days_completed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ItemTwo extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
BarView barView;
|
|
||||||
LinearLayout linearLayout;
|
|
||||||
TextView pcText;
|
|
||||||
TextView hrText;
|
|
||||||
// LinearLayout textholder;
|
|
||||||
// LinearLayout bottomTextholder;
|
|
||||||
|
|
||||||
public ItemTwo(View itemView){
|
|
||||||
super(itemView);
|
|
||||||
|
|
||||||
barView = itemView.findViewById(R.id.bar);
|
|
||||||
linearLayout = itemView.findViewById(R.id.lin);
|
|
||||||
pcText = itemView.findViewById(R.id.pc_amount_text);
|
|
||||||
hrText = itemView.findViewById(R.id.hr_amount_text);
|
|
||||||
// textholder = itemView.findViewById(R.id.text_holder);
|
|
||||||
// bottomTextholder = itemView.findViewById(R.id.bottom_text_holder);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ItemThree extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
private TextView cardTitle;
|
|
||||||
private ImageView cardIcon;
|
|
||||||
private TextView units;
|
|
||||||
private TextView totalEarned;
|
|
||||||
private LinearLayout textholderTop;
|
|
||||||
private LinearLayout textholderBottom;
|
|
||||||
|
|
||||||
public ItemThree(View itemView){
|
|
||||||
super(itemView);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
|
|
||||||
switch (i) {
|
|
||||||
case 1:
|
|
||||||
final View itemOne = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_one, viewGroup, false);
|
|
||||||
return new ItemOne(itemOne);
|
|
||||||
case 2:
|
|
||||||
final View itemTwo = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_two, viewGroup, false);
|
|
||||||
return new ItemTwo(itemTwo);
|
|
||||||
case 3:
|
|
||||||
final View itemThree = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_three, viewGroup, false);
|
|
||||||
return new ItemThree(itemThree);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int i) {
|
|
||||||
|
|
||||||
switch (holder.getItemViewType()) {
|
|
||||||
case 1:
|
|
||||||
final ItemOne viewHolderCurrent = (ItemOne) holder;
|
|
||||||
|
|
||||||
CircleView arcView = viewHolderCurrent.arc;
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
arcView.setPaintColor(context.getColor(R.color.two));
|
|
||||||
}
|
|
||||||
|
|
||||||
int days = uniqueEntries;
|
|
||||||
|
|
||||||
int complete = (360 * days)/88;
|
|
||||||
|
|
||||||
viewHolderCurrent.days.setText(String.valueOf(days));
|
|
||||||
|
|
||||||
ArcAnimation animation = new ArcAnimation(arcView, complete);
|
|
||||||
animation.setDuration(600);
|
|
||||||
arcView.startAnimation(animation);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
final ItemTwo viewTwo = (ItemTwo) holder;
|
|
||||||
|
|
||||||
final BarView barView = viewTwo.barView;
|
|
||||||
final LinearLayout linearLayout = viewTwo.linearLayout;
|
|
||||||
|
|
||||||
float cover = (float) typeCount[1]/shiftObjectList.size();
|
|
||||||
|
|
||||||
barView.setCover(cover);
|
|
||||||
|
|
||||||
barView.setColourOne(context.getResources().getColor(R.color.four));
|
|
||||||
barView.setColourTwo(context.getResources().getColor(R.color.three));
|
|
||||||
|
|
||||||
viewTwo.pcText.setText(String.valueOf(typeCount[1]));
|
|
||||||
viewTwo.hrText.setText(String.valueOf(typeCount[0]));
|
|
||||||
|
|
||||||
// viewTwo.textholder.setPadding(60,0,60,0);
|
|
||||||
// viewTwo.bottomTextholder.setPadding(60,0,60,0);
|
|
||||||
|
|
||||||
linearLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
Log.i(TAG, "onGlobalLayout: " + linearLayout.getWidth());
|
|
||||||
|
|
||||||
BarAnimation barAnimation = new BarAnimation(barView, linearLayout.getWidth(), 0);
|
|
||||||
barAnimation.setDuration(600);
|
|
||||||
barView.setAnimation(barAnimation);
|
|
||||||
linearLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
final ItemThree viewCounting = (ItemThree) holder;
|
|
||||||
|
|
||||||
TextView cardTitle = viewCounting.cardTitle;
|
|
||||||
ImageView cardIcon = viewCounting.cardIcon;
|
|
||||||
TextView units = viewCounting.units;
|
|
||||||
TextView totalEarned = viewCounting.totalEarned;
|
|
||||||
LinearLayout top = viewCounting.textholderTop;
|
|
||||||
LinearLayout bottom = viewCounting.textholderBottom;
|
|
||||||
|
|
||||||
// top.setPadding(60,0,60,0);
|
|
||||||
// bottom.setPadding(60,0,60,0);
|
|
||||||
// cardIcon.setPadding(0,0,10,0);
|
|
||||||
|
|
||||||
if (i == 2){
|
|
||||||
cardTitle.setText("Hourly");
|
|
||||||
cardIcon.setImageResource(R.drawable.clock_icon);
|
|
||||||
String hours = String.format("%.2f", calculateHours());
|
|
||||||
units.setText(hours + " Hours");
|
|
||||||
|
|
||||||
String total = String.format("%.2f", calculateAccumulatedPay(0));
|
|
||||||
totalEarned.setText("$" + total);
|
|
||||||
}
|
|
||||||
if (i == 3){
|
|
||||||
cardTitle.setText("Piece");
|
|
||||||
cardTitle.setTextColor(context.getResources().getColor(R.color.three));
|
|
||||||
cardIcon.setImageResource(R.drawable.piece);
|
|
||||||
cardIcon.setRotation(270);
|
|
||||||
String pieces = String.format("%.2f", calculateUnits());
|
|
||||||
units.setText(pieces + " Units");
|
|
||||||
String total = String.format("%.2f", calculateAccumulatedPay(1));
|
|
||||||
totalEarned.setText("$" + total);
|
|
||||||
}
|
|
||||||
if (i == 4){
|
|
||||||
cardTitle.setVisibility(View.GONE);
|
|
||||||
cardIcon.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
String total = String.format("%.2f", calculateAccumulatedPay(3));
|
|
||||||
totalEarned.setText("$" + total);
|
|
||||||
|
|
||||||
viewCounting.textholderTop.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemViewType(int position) {
|
|
||||||
int type = 0;
|
|
||||||
|
|
||||||
switch (position){
|
|
||||||
case 0:
|
|
||||||
type = 1;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
type = 2;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
type = 3;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
type = 3;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
type = 3;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int countDistinct() {
|
|
||||||
HashSet<String> hs = new HashSet<>();
|
|
||||||
|
|
||||||
for(int i = 0; i < shiftObjectList.size(); i++) {
|
|
||||||
|
|
||||||
hs.add(shiftObjectList.get(i).getShiftDate());
|
|
||||||
}
|
|
||||||
|
|
||||||
return hs.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
private int[] countShiftType(){
|
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
|
|
||||||
for (ShiftObject shiftObject : shiftObjectList){
|
|
||||||
if (shiftObject.getTaskObject().getWorkType().equals("Hourly")){
|
|
||||||
i++;
|
|
||||||
}else {
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new int[]{i,j};
|
|
||||||
}
|
|
||||||
|
|
||||||
private float calculateHours(){
|
|
||||||
float hours = 0;
|
|
||||||
for (ShiftObject shiftObject : shiftObjectList){
|
|
||||||
if (shiftObject.getTaskObject().getWorkType().equals("Hourly")){
|
|
||||||
hours = hours + shiftObject.getTimeObject().getHours() - shiftObject.getTimeObject().getBreakEpoch();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return hours;
|
|
||||||
}
|
|
||||||
|
|
||||||
private float calculateUnits(){
|
|
||||||
float units = 0;
|
|
||||||
for (ShiftObject shiftObject : shiftObjectList){
|
|
||||||
if (shiftObject.getTaskObject().getWorkType().equals("Piece Rate")){
|
|
||||||
units = units + shiftObject.getUnitsCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return units;
|
|
||||||
}
|
|
||||||
|
|
||||||
private float calculateAccumulatedPay(int type){
|
|
||||||
float pay = 0;
|
|
||||||
|
|
||||||
for (ShiftObject shiftObject : shiftObjectList){
|
|
||||||
if (type == 0){
|
|
||||||
if (shiftObject.getTaskObject().getWorkType().equals("Hourly")){
|
|
||||||
pay = pay + (shiftObject.getTaskObject().getRate() *
|
|
||||||
(shiftObject.getTimeObject().getHours() - shiftObject.getTimeObject().getBreakEpoch()));
|
|
||||||
}
|
|
||||||
}else if (type == 1){
|
|
||||||
if (shiftObject.getTaskObject().getWorkType().equals("Piece Rate")){
|
|
||||||
pay = pay + (shiftObject.getTaskObject().getRate() * shiftObject.getUnitsCount());
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
if (shiftObject.getTaskObject().getWorkType().equals("Hourly")){
|
|
||||||
pay = pay + (shiftObject.getTaskObject().getRate() *
|
|
||||||
(shiftObject.getTimeObject().getHours() - shiftObject.getTimeObject().getBreakEpoch()));
|
|
||||||
}else {
|
|
||||||
pay = pay + (shiftObject.getTaskObject().getRate() * shiftObject.getUnitsCount());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pay;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,143 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.Filter;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.appttude.h_mal.days_left.Objects.ShiftObject;
|
|
||||||
import com.appttude.h_mal.days_left.Objects.TaskObject;
|
|
||||||
import com.appttude.h_mal.days_left.Objects.TimeObject;
|
|
||||||
import com.appttude.h_mal.days_left.R;
|
|
||||||
|
|
||||||
public class ShiftListViewAdapter extends ArrayAdapter<ShiftObject> {
|
|
||||||
|
|
||||||
public ShiftListViewAdapter(@NonNull Context context, @NonNull List<ShiftObject> objects) {
|
|
||||||
super(context, 0, objects);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
|
||||||
View listItemView = convertView;
|
|
||||||
if (convertView == null){
|
|
||||||
listItemView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent,false);
|
|
||||||
}
|
|
||||||
|
|
||||||
ShiftObject currentShift = getItem(position);
|
|
||||||
|
|
||||||
TextView farmNameTextView = listItemView.findViewById(R.id.farm_name);
|
|
||||||
TextView dateTextView = listItemView.findViewById(R.id.date);
|
|
||||||
TextView tastTextView = listItemView.findViewById(R.id.task_name);
|
|
||||||
TextView typeTextView = listItemView.findViewById(R.id.type);
|
|
||||||
LinearLayout timeHolderLinearLayout = listItemView.findViewById(R.id.time_holder);
|
|
||||||
TextView timeTextView = listItemView.findViewById(R.id.time);
|
|
||||||
LinearLayout breakHolderLinearLayout = listItemView.findViewById(R.id.break_holder);
|
|
||||||
TextView breakTimeTextView = listItemView.findViewById(R.id.break_time);
|
|
||||||
LinearLayout unitsHolderLinearLayout = listItemView.findViewById(R.id.units_holder);
|
|
||||||
TextView unitsTextView = listItemView.findViewById(R.id.units);
|
|
||||||
TextView locationTextView = listItemView.findViewById(R.id.location);
|
|
||||||
|
|
||||||
dateTextView.setText(currentShift.getShiftDate());
|
|
||||||
|
|
||||||
TaskObject taskObject = currentShift.getTaskObject();
|
|
||||||
tastTextView.setText(taskObject.getTask());
|
|
||||||
String s = taskObject.getWorkType() + " - $" + taskObject.getRate() + "/";
|
|
||||||
if (taskObject.getWorkType().equals("Hourly")){
|
|
||||||
s = s + "Hour";
|
|
||||||
timeHolderLinearLayout.setVisibility(View.VISIBLE);
|
|
||||||
unitsHolderLinearLayout.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
TimeObject timeObject = currentShift.getTimeObject();
|
|
||||||
|
|
||||||
timeTextView.setText(timeObject.getTimeIn() + " - " + timeObject.getTimeOut());
|
|
||||||
|
|
||||||
if (timeObject.getBreakEpoch() > 0){
|
|
||||||
breakHolderLinearLayout.setVisibility(View.VISIBLE);
|
|
||||||
String breakString = getBreakTimeString(timeObject.getBreakEpoch());
|
|
||||||
breakTimeTextView.setText(breakString);
|
|
||||||
}else {
|
|
||||||
breakHolderLinearLayout.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
unitsTextView.setText(String.valueOf(timeObject.getHours()));
|
|
||||||
|
|
||||||
}else {
|
|
||||||
s = s + "Unit";
|
|
||||||
timeHolderLinearLayout.setVisibility(View.GONE);
|
|
||||||
unitsHolderLinearLayout.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
unitsTextView.setText(String.valueOf(currentShift.getUnitsCount()));
|
|
||||||
}
|
|
||||||
|
|
||||||
typeTextView.setText(s);
|
|
||||||
farmNameTextView.setText(currentShift.getAbnObject().getCompanyName());
|
|
||||||
|
|
||||||
locationTextView.setText(currentShift.getAbnObject().getState() + " - " + currentShift.getAbnObject().getPostCode());
|
|
||||||
|
|
||||||
return listItemView;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ShiftObject getItem(int position) {
|
|
||||||
return super.getItem(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getBreakTimeString(int breakMins){
|
|
||||||
float hoursFloat = breakMins/60;
|
|
||||||
|
|
||||||
int hoursInt = (int) Math.floor(hoursFloat);
|
|
||||||
int minsInt = breakMins - (hoursInt*60);
|
|
||||||
|
|
||||||
String s = "";
|
|
||||||
if (hoursInt > 0){
|
|
||||||
s = hoursInt + " h" + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (minsInt > 0){
|
|
||||||
s = s + minsInt + " m";
|
|
||||||
}
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class fireFilter extends Filter{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected FilterResults performFiltering(CharSequence constraint) {
|
|
||||||
FilterResults results = new FilterResults();
|
|
||||||
|
|
||||||
// if (constraint != null && constraint.length() > 0) {
|
|
||||||
// ArrayList<ShiftObject> filterList = new ArrayList<>();
|
|
||||||
//
|
|
||||||
// for (ShiftObject shiftObject : shiftObjects){
|
|
||||||
// if (shiftObject.getAbnObject().getCompanyName().toUpperCase().contains(constraint.toString().toUpperCase())){
|
|
||||||
// filterList.add(shiftObject);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// results.count = filterList.size();
|
|
||||||
// results.values = filterList;
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
// results.count = shiftObjects.size();
|
|
||||||
// results.values = shiftObjects;
|
|
||||||
// }
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.appttude.h_mal.days_left.application
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import com.appttude.h_mal.days_left.FirebaseDatabase
|
||||||
|
import com.appttude.h_mal.days_left.ui.login.FirebaseAuthSource
|
||||||
|
import com.appttude.h_mal.days_left.ui.login.UserRepository
|
||||||
|
import com.appttude.h_mal.days_left.ui.main.MainViewModelFactory
|
||||||
|
import com.appttude.h_mal.days_left.ui.main.ShiftsViewModelFactory
|
||||||
|
import org.kodein.di.Kodein
|
||||||
|
import org.kodein.di.KodeinAware
|
||||||
|
import org.kodein.di.android.x.androidXModule
|
||||||
|
import org.kodein.di.generic.bind
|
||||||
|
import org.kodein.di.generic.instance
|
||||||
|
import org.kodein.di.generic.provider
|
||||||
|
import org.kodein.di.generic.singleton
|
||||||
|
|
||||||
|
class AppClass : Application(), KodeinAware{
|
||||||
|
|
||||||
|
override val kodein = Kodein.lazy {
|
||||||
|
import(androidXModule(this@AppClass))
|
||||||
|
|
||||||
|
bind() from singleton { FirebaseAuthSource() }
|
||||||
|
bind() from singleton { FirebaseDatabase() }
|
||||||
|
bind() from singleton { UserRepository(instance()) }
|
||||||
|
bind() from provider {
|
||||||
|
MainViewModelFactory(
|
||||||
|
instance()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
bind() from provider {
|
||||||
|
ShiftsViewModelFactory(
|
||||||
|
instance()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.arc;
|
|
||||||
|
|
||||||
import android.view.animation.Animation;
|
|
||||||
import android.view.animation.Transformation;
|
|
||||||
|
|
||||||
public class ArcAnimation extends Animation {
|
|
||||||
|
|
||||||
private CircleView arcView;
|
|
||||||
|
|
||||||
private float oldAngle;
|
|
||||||
private float newAngle;
|
|
||||||
|
|
||||||
public ArcAnimation(CircleView arcView, int newAngle) {
|
|
||||||
this.oldAngle = arcView.getArcAngle();
|
|
||||||
this.newAngle = newAngle;
|
|
||||||
this.arcView = arcView;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void applyTransformation(float interpolatedTime, Transformation transformation) {
|
|
||||||
float angle = 0 + ((newAngle - oldAngle) * interpolatedTime);
|
|
||||||
|
|
||||||
arcView.setArcAngle(angle);
|
|
||||||
arcView.requestLayout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.arc;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.graphics.PorterDuff;
|
|
||||||
import android.graphics.PorterDuffXfermode;
|
|
||||||
import android.graphics.RectF;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
public class CircleView extends View {
|
|
||||||
|
|
||||||
private float arcAngle;
|
|
||||||
private RectF mRect;
|
|
||||||
private RectF mRect2;
|
|
||||||
private Paint mPaint;
|
|
||||||
private Paint paint2;
|
|
||||||
private int thinkness;
|
|
||||||
|
|
||||||
public CircleView(Context context) {
|
|
||||||
super(context);
|
|
||||||
init(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CircleView(Context context, @Nullable AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
init(attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CircleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
|
||||||
super(context, attrs, defStyleAttr);
|
|
||||||
|
|
||||||
init(attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CircleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
|
||||||
|
|
||||||
init(attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init(@Nullable AttributeSet attributeSet){
|
|
||||||
mRect = new RectF();
|
|
||||||
mRect2 = new RectF();
|
|
||||||
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
|
||||||
|
|
||||||
paint2 = new Paint();
|
|
||||||
paint2.setAntiAlias(true);
|
|
||||||
paint2.setColor(Color.TRANSPARENT);
|
|
||||||
paint2.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
||||||
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBackgroundColor(int color) {
|
|
||||||
super.setBackgroundColor(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDraw(Canvas canvas) {
|
|
||||||
super.onDraw(canvas);
|
|
||||||
|
|
||||||
if (thinkness == 0){
|
|
||||||
thinkness = 35;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
mRect.centerX();
|
|
||||||
mRect.centerY();
|
|
||||||
mRect.left = 10f;
|
|
||||||
mRect.top = 10f;
|
|
||||||
mRect.right = getWidth()-10;
|
|
||||||
mRect.bottom = getWidth()-10;
|
|
||||||
|
|
||||||
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(View.LAYER_TYPE_SOFTWARE,null);
|
|
||||||
|
|
||||||
canvas.drawArc(mRect,270f,arcAngle,true,mPaint);
|
|
||||||
canvas.drawOval(mRect2,paint2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPaintColor(int color){
|
|
||||||
mPaint.setColor(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setThickness(int thickness){
|
|
||||||
this.thinkness = thickness;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getArcAngle() {
|
|
||||||
return arcAngle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setArcAngle(float arcAngle) {
|
|
||||||
this.arcAngle = arcAngle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.bar;
|
|
||||||
|
|
||||||
import android.view.animation.Animation;
|
|
||||||
import android.view.animation.Transformation;
|
|
||||||
|
|
||||||
public class BarAnimation extends Animation {
|
|
||||||
|
|
||||||
private BarView barView;
|
|
||||||
|
|
||||||
private int targetWidth;
|
|
||||||
private int startWidth;
|
|
||||||
|
|
||||||
public BarAnimation(BarView barView, int targetWidth, int startWidth) {
|
|
||||||
this.barView = barView;
|
|
||||||
this.targetWidth = targetWidth;
|
|
||||||
this.startWidth = startWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
|
||||||
|
|
||||||
int newWidth = (int) (startWidth + targetWidth * interpolatedTime);
|
|
||||||
|
|
||||||
barView.getLayoutParams().width = newWidth;
|
|
||||||
barView.requestLayout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
package com.appttude.h_mal.days_left.bar;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.graphics.RectF;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
public class BarView extends View {
|
|
||||||
|
|
||||||
private RectF topRect;
|
|
||||||
private RectF bottomRect;
|
|
||||||
private Paint colourOne;
|
|
||||||
private Paint colourTwo;
|
|
||||||
private RectF hardEdge;
|
|
||||||
private float cover;
|
|
||||||
|
|
||||||
public BarView(Context context) {
|
|
||||||
super(context);
|
|
||||||
init(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BarView(Context context, @Nullable AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
init(attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BarView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
|
||||||
super(context, attrs, defStyleAttr);
|
|
||||||
init(attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BarView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
|
||||||
init(attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init (@Nullable AttributeSet attrs){
|
|
||||||
topRect = new RectF();
|
|
||||||
bottomRect = new RectF();
|
|
||||||
hardEdge = new RectF();
|
|
||||||
|
|
||||||
colourOne = new Paint(Paint.ANTI_ALIAS_FLAG);
|
|
||||||
colourTwo = new Paint(Paint.ANTI_ALIAS_FLAG);
|
|
||||||
|
|
||||||
colourOne.setColor(Color.BLUE);
|
|
||||||
colourTwo.setColor(Color.GREEN);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBackgroundColor(int color) {
|
|
||||||
super.setBackgroundColor(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDraw(Canvas canvas) {
|
|
||||||
super.onDraw(canvas);
|
|
||||||
|
|
||||||
|
|
||||||
topRect.centerX();
|
|
||||||
topRect.centerY();
|
|
||||||
topRect.left = 0f;
|
|
||||||
topRect.top = 0f;
|
|
||||||
topRect.right = getWidth();
|
|
||||||
topRect.bottom = getHeight();
|
|
||||||
|
|
||||||
canvas.drawRoundRect(topRect,20,20,colourOne);
|
|
||||||
|
|
||||||
|
|
||||||
bottomRect.centerX();
|
|
||||||
bottomRect.centerY();
|
|
||||||
if (cover < 0.05f){
|
|
||||||
cover = 0.05f;
|
|
||||||
}
|
|
||||||
bottomRect.left = ((getWidth()-20)*cover);
|
|
||||||
bottomRect.top = 0f;
|
|
||||||
bottomRect.right = getWidth();
|
|
||||||
bottomRect.bottom = getHeight();
|
|
||||||
|
|
||||||
canvas.drawRoundRect(bottomRect,20,20,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,0,0,colourTwo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getCover() {
|
|
||||||
return cover;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCover(float cover) {
|
|
||||||
this.cover = cover;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCover(float total,float number) {
|
|
||||||
this.cover = number/total;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColourOne(int colour) {
|
|
||||||
colourOne.setColor(colour);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColourTwo(int colour) {
|
|
||||||
colourTwo.setColor(colour);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.appttude.h_mal.days_left.firebaseLiveData
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import com.google.firebase.database.DataSnapshot
|
||||||
|
import com.google.firebase.database.DatabaseError
|
||||||
|
import com.google.firebase.database.Query
|
||||||
|
import com.google.firebase.database.ValueEventListener
|
||||||
|
|
||||||
|
|
||||||
|
class FirebaseQueryLiveData(
|
||||||
|
var query: Query
|
||||||
|
): LiveData<DataSnapshot>(),ValueEventListener {
|
||||||
|
|
||||||
|
override fun onActive() {
|
||||||
|
query.addValueEventListener(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onInactive() {
|
||||||
|
query.removeEventListener(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDataChange(p0: DataSnapshot) {
|
||||||
|
postValue(p0)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCancelled(p0: DatabaseError) {
|
||||||
|
Log.e(this.toString(),p0.message)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.appttude.h_mal.days_left.ui.login
|
||||||
|
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.ViewModelProvider
|
||||||
|
import com.appttude.h_mal.days_left.FirebaseDatabase
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ViewModel provider factory to instantiate LoginViewModel.
|
||||||
|
* Required given LoginViewModel has a non-empty constructor
|
||||||
|
*/
|
||||||
|
class AuthViewModelFactory(
|
||||||
|
private val userRepository: UserRepository
|
||||||
|
) : ViewModelProvider.Factory {
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||||
|
if (modelClass.isAssignableFrom(AuthViewModel::class.java)) {
|
||||||
|
return (
|
||||||
|
AuthViewModel(
|
||||||
|
userRepository
|
||||||
|
)
|
||||||
|
) as T
|
||||||
|
}
|
||||||
|
throw IllegalArgumentException("Unknown ViewModel class")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package com.appttude.h_mal.days_left.ui.login
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
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.R
|
||||||
|
import com.appttude.h_mal.days_left.ui.login.FullscreenActivity.Companion.fragmentManagerLogin
|
||||||
|
import kotlinx.android.synthetic.main.fragment_forgot_password.*
|
||||||
|
|
||||||
|
|
||||||
|
class ForgotPassword : Fragment(), ForgotPasswordCallback {
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
|
||||||
|
return inflater.inflate(R.layout.fragment_forgot_password, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStarted() {
|
||||||
|
pb.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onEmailInvalid() {
|
||||||
|
pb.visibility = View.GONE
|
||||||
|
reset_pw.error = getString(R.string.error_invalid_password)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSuccess() {
|
||||||
|
pb.visibility = View.GONE
|
||||||
|
fragmentManagerLogin.popBackStack()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFailure(message: String) {
|
||||||
|
pb.visibility = View.GONE
|
||||||
|
Toast.makeText(context,message,Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.appttude.h_mal.days_left.ui.login
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.fragment.app.FragmentManager
|
||||||
|
import androidx.fragment.app.FragmentTransaction
|
||||||
|
import com.appttude.h_mal.days_left.R
|
||||||
|
import com.appttude.h_mal.days_left.FirebaseClass.Companion.auth
|
||||||
|
import com.google.firebase.auth.FirebaseAuth
|
||||||
|
|
||||||
|
class FullscreenActivity : AppCompatActivity() {
|
||||||
|
companion object {
|
||||||
|
lateinit var fragmentManagerLogin : FragmentManager
|
||||||
|
}
|
||||||
|
|
||||||
|
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,90 @@
|
|||||||
|
package com.appttude.h_mal.days_left.ui.login
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
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 androidx.fragment.app.viewModels
|
||||||
|
import com.appttude.h_mal.days_left.R
|
||||||
|
import com.appttude.h_mal.days_left.ui.login.FullscreenActivity.Companion.fragmentManagerLogin
|
||||||
|
import com.appttude.h_mal.days_left.ui.main.MainActivity
|
||||||
|
import kotlinx.android.synthetic.main.fragment_login.*
|
||||||
|
import org.kodein.di.KodeinAware
|
||||||
|
import org.kodein.di.android.x.kodein
|
||||||
|
import org.kodein.di.generic.instance
|
||||||
|
|
||||||
|
|
||||||
|
class LoginFragment : Fragment(), LoginCallback, KodeinAware {
|
||||||
|
override val kodein by kodein()
|
||||||
|
private val factory by instance<AuthViewModelFactory>()
|
||||||
|
private val viewModel: AuthViewModel by viewModels{ factory }
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
return inflater.inflate(R.layout.fragment_login, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
password.setOnEditorActionListener(TextView.OnEditorActionListener { textView, id, keyEvent ->
|
||||||
|
if (id == EditorInfo.IME_ACTION_DONE || id == EditorInfo.IME_NULL) {
|
||||||
|
viewModel.onClickLogin(textView)
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStarted() {
|
||||||
|
login_progress.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onEmailInvalid() {
|
||||||
|
email.error = getString(R.string.error_invalid_email)
|
||||||
|
email.requestFocus()
|
||||||
|
login_progress.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPasswordInvalid() {
|
||||||
|
password.error = getString(R.string.error_invalid_password)
|
||||||
|
password.requestFocus()
|
||||||
|
login_progress.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSuccess() {
|
||||||
|
login_progress.visibility = View.GONE
|
||||||
|
Intent(context, MainActivity::class.java).apply {
|
||||||
|
startActivity(this)
|
||||||
|
activity?.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFailure(message: String) {
|
||||||
|
Toast.makeText(context,message,Toast.LENGTH_LONG).show()
|
||||||
|
login_progress.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.appttude.h_mal.days_left.ui.login
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.lifecycle.ViewModelProviders
|
||||||
|
import com.appttude.h_mal.days_left.R
|
||||||
|
import com.appttude.h_mal.days_left.ui.main.MainActivity
|
||||||
|
import kotlinx.android.synthetic.main.fragment_register.*
|
||||||
|
|
||||||
|
|
||||||
|
class Register : Fragment(), RegisterCallBack {
|
||||||
|
val viewModel = ViewModelProviders.of(this).get(RegisterViewModel::class.java)
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
|
||||||
|
return inflater.inflate(R.layout.fragment_register, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun onStarted() {
|
||||||
|
pb.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNameInvalid() {
|
||||||
|
pb.visibility = View.GONE
|
||||||
|
name_register.error = getString(R.string.error_invalid_email)
|
||||||
|
name_register.requestFocus()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onEmailInvalid() {
|
||||||
|
pb.visibility = View.GONE
|
||||||
|
email_register.error = getString(R.string.error_invalid_email)
|
||||||
|
email_register.requestFocus()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPasswordInvalid(id: Int) {
|
||||||
|
pb.visibility = View.GONE
|
||||||
|
when(id){
|
||||||
|
0 -> password_top.error = getString(R.string.error_invalid_password)
|
||||||
|
1 -> password_top.error = getString(R.string.no_match_password)
|
||||||
|
}
|
||||||
|
password_top.requestFocus()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPasswordTwoInvalid() {
|
||||||
|
pb.visibility = View.GONE
|
||||||
|
password_bottom.error = getString(R.string.error_invalid_password)
|
||||||
|
password_bottom.requestFocus()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSuccess() {
|
||||||
|
pb.visibility = View.GONE
|
||||||
|
|
||||||
|
Intent(context, MainActivity::class.java).apply {
|
||||||
|
this.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||||
|
startActivity(this)
|
||||||
|
activity?.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFailure(message: String) {
|
||||||
|
pb.visibility = View.GONE
|
||||||
|
Toast.makeText(context,message,Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,194 @@
|
|||||||
|
package com.appttude.h_mal.days_left.ui.main
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import androidx.appcompat.app.ActionBarDrawerToggle
|
||||||
|
import androidx.activity.viewModels
|
||||||
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
|
import androidx.fragment.app.FragmentManager
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.view.GravityCompat
|
||||||
|
import com.appttude.h_mal.days_left.*
|
||||||
|
import com.appttude.h_mal.days_left.ui.login.FullscreenActivity
|
||||||
|
import com.appttude.h_mal.days_left.FirebaseClass.Companion.SHIFT_FIREBASE
|
||||||
|
import com.appttude.h_mal.days_left.FirebaseClass.Companion.USER_FIREBASE
|
||||||
|
import com.appttude.h_mal.days_left.FirebaseClass.Companion.auth
|
||||||
|
import com.appttude.h_mal.days_left.FirebaseClass.Companion.mDatabase
|
||||||
|
import com.appttude.h_mal.days_left.models.ShiftObject
|
||||||
|
import com.appttude.h_mal.days_left.ui.main.home.HomeFragment
|
||||||
|
import com.appttude.h_mal.days_left.ui.main.list.FragmentList
|
||||||
|
import com.appttude.h_mal.days_left.ui.main.tools.FragmentTools
|
||||||
|
import com.google.android.material.navigation.NavigationView
|
||||||
|
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.*
|
||||||
|
import org.kodein.di.KodeinAware
|
||||||
|
import org.kodein.di.android.kodein
|
||||||
|
import org.kodein.di.generic.instance
|
||||||
|
|
||||||
|
class MainActivity : AppCompatActivity(), KodeinAware {
|
||||||
|
override val kodein by kodein()
|
||||||
|
private val factory by instance<MainViewModelFactory>()
|
||||||
|
val viewModel: MainViewModel by viewModels{ factory }
|
||||||
|
|
||||||
|
companion object{
|
||||||
|
var shiftList = ArrayList<ShiftObject>()
|
||||||
|
val ref = mDatabase.child(USER_FIREBASE).child(auth.uid as String).child(SHIFT_FIREBASE)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.activity_drawer_main)
|
||||||
|
|
||||||
|
//setup backstack change listener
|
||||||
|
supportFragmentManager.addOnBackStackChangedListener(backStackChangedListener)
|
||||||
|
//set toolbar
|
||||||
|
setSupportActionBar(toolbar)
|
||||||
|
//setup fab
|
||||||
|
fab.setOnClickListener{
|
||||||
|
val intent = Intent(this, AddShiftActivity::class.java)
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
|
||||||
|
//setup drawer layout
|
||||||
|
val toggle = ActionBarDrawerToggle(this,drawer_layout,toolbar,R.string.navigation_drawer_open, R.string.navigation_drawer_close)
|
||||||
|
drawer_layout.addDrawerListener(toggle)
|
||||||
|
toggle.syncState()
|
||||||
|
|
||||||
|
//apply navigation listener on bottom bar navigation view
|
||||||
|
navigation.setOnNavigationItemSelectedListener(onNavigationItemSelectedListener)
|
||||||
|
|
||||||
|
//setup naviation view
|
||||||
|
nav_view.setNavigationItemSelectedListener { menuItem ->
|
||||||
|
menuItem.itemId.let { id ->
|
||||||
|
if (id == R.id.nav_camera){
|
||||||
|
val intent = Intent(this, ChangeUserDetailsActivity::class.java)
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drawer_layout.closeDrawer(GravityCompat.START)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
//Setup drawer
|
||||||
|
setupDrawer(nav_view)
|
||||||
|
|
||||||
|
//initialise data for fragments
|
||||||
|
supportFragmentManager.beginTransaction().replace(R.id.container,
|
||||||
|
HomeFragment()
|
||||||
|
).commit()
|
||||||
|
navigation.id = R.id.navigation_home
|
||||||
|
}
|
||||||
|
|
||||||
|
private val onNavigationItemSelectedListener = BottomNavigationView.OnNavigationItemSelectedListener { item ->
|
||||||
|
when (item.itemId) {
|
||||||
|
R.id.navigation_home -> {
|
||||||
|
supportFragmentManager.beginTransaction().replace(R.id.container,
|
||||||
|
HomeFragment()
|
||||||
|
).commit()
|
||||||
|
return@OnNavigationItemSelectedListener true
|
||||||
|
}
|
||||||
|
R.id.navigation_list -> {
|
||||||
|
supportFragmentManager.beginTransaction().replace(R.id.container,
|
||||||
|
FragmentList()
|
||||||
|
).commit()
|
||||||
|
return@OnNavigationItemSelectedListener true
|
||||||
|
}
|
||||||
|
R.id.navigation_tools -> {
|
||||||
|
supportFragmentManager.beginTransaction().replace(R.id.container,
|
||||||
|
FragmentTools()
|
||||||
|
).commit()
|
||||||
|
return@OnNavigationItemSelectedListener true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
private val backStackChangedListener = FragmentManager.OnBackStackChangedListener {
|
||||||
|
supportFragmentManager.fragments[0].javaClass.simpleName.let { fragmentName ->
|
||||||
|
|
||||||
|
when (fragmentName){
|
||||||
|
"HomeFragment" -> {
|
||||||
|
title = "Home"
|
||||||
|
}
|
||||||
|
"ListFragment" -> {
|
||||||
|
title = "List"
|
||||||
|
}
|
||||||
|
"ToolsFragment" -> {
|
||||||
|
title = "Tools"
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
title = getString(R.string.app_name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupDrawer(navigationView: NavigationView){
|
||||||
|
val header: View = navigationView.getHeaderView(0)
|
||||||
|
|
||||||
|
viewModel.getName()?.let {
|
||||||
|
header.driver_name.text = it
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
viewModel.getEmail()?.let {
|
||||||
|
header.driver_email.text = it
|
||||||
|
}
|
||||||
|
|
||||||
|
viewModel.getPhotoUrl()?.let {
|
||||||
|
Picasso.get().load(it).placeholder(R.mipmap.ic_launcher_round)
|
||||||
|
.into(header.profileImage)
|
||||||
|
}
|
||||||
|
|
||||||
|
logout.setOnClickListener{
|
||||||
|
viewModel.logout()
|
||||||
|
val intent = Intent(this, FullscreenActivity::class.java)
|
||||||
|
startActivity(intent)
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// fun initiateFragment(){
|
||||||
|
// progressBar2.visibility = View.VISIBLE
|
||||||
|
//
|
||||||
|
// ref.keepSynced(true)
|
||||||
|
// ref.addValueEventListener(object : ValueEventListener {
|
||||||
|
// override fun onCancelled(p0: DatabaseError) {
|
||||||
|
// progressBar2.visibility = View.GONE
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// override fun onDataChange(p0: DataSnapshot) {
|
||||||
|
// progressBar2.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){
|
||||||
|
// if(fragmentManager.fragments.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,26 @@
|
|||||||
|
package com.appttude.h_mal.days_left.ui.main
|
||||||
|
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.ViewModelProvider
|
||||||
|
import com.appttude.h_mal.days_left.ui.login.UserRepository
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ViewModel provider factory to instantiate LoginViewModel.
|
||||||
|
* Required given LoginViewModel has a non-empty constructor
|
||||||
|
*/
|
||||||
|
class MainViewModelFactory(
|
||||||
|
private val userRepository: UserRepository
|
||||||
|
) : ViewModelProvider.Factory {
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||||
|
if (modelClass.isAssignableFrom(MainViewModel::class.java)) {
|
||||||
|
return (
|
||||||
|
MainViewModel(
|
||||||
|
userRepository
|
||||||
|
)
|
||||||
|
) as T
|
||||||
|
}
|
||||||
|
throw IllegalArgumentException("Unknown ViewModel class")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.appttude.h_mal.days_left.ui.main
|
||||||
|
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import com.appttude.h_mal.days_left.FirebaseDatabase
|
||||||
|
import com.appttude.h_mal.days_left.firebaseLiveData.FirebaseQueryLiveData
|
||||||
|
|
||||||
|
class ShiftsViewModel(
|
||||||
|
val database: FirebaseDatabase
|
||||||
|
): ViewModel() {
|
||||||
|
|
||||||
|
private val shifts = database.allShifts()
|
||||||
|
val shiftData = FirebaseQueryLiveData(shifts)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.appttude.h_mal.days_left.ui.main
|
||||||
|
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.ViewModelProvider
|
||||||
|
import com.appttude.h_mal.days_left.FirebaseDatabase
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ViewModel provider factory to instantiate LoginViewModel.
|
||||||
|
* Required given LoginViewModel has a non-empty constructor
|
||||||
|
*/
|
||||||
|
class ShiftsViewModelFactory(
|
||||||
|
private val firebaseDatabase: FirebaseDatabase
|
||||||
|
) : ViewModelProvider.Factory {
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||||
|
if (modelClass.isAssignableFrom(ShiftsViewModel::class.java)) {
|
||||||
|
return (
|
||||||
|
ShiftsViewModel(
|
||||||
|
firebaseDatabase
|
||||||
|
)
|
||||||
|
) as T
|
||||||
|
}
|
||||||
|
throw IllegalArgumentException("Unknown ViewModel class")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,234 @@
|
|||||||
|
package com.appttude.h_mal.days_left.ui.main.list
|
||||||
|
|
||||||
|
import android.app.AlertDialog
|
||||||
|
import android.content.DialogInterface
|
||||||
|
import android.content.DialogInterface.BUTTON_POSITIVE
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.*
|
||||||
|
import android.widget.AdapterView
|
||||||
|
import com.appttude.h_mal.days_left.*
|
||||||
|
import com.appttude.h_mal.days_left.ui.main.MainActivity
|
||||||
|
import com.appttude.h_mal.days_left.CustomDialog.Companion.dateSelectionFrom
|
||||||
|
import com.appttude.h_mal.days_left.CustomDialog.Companion.dateSelectionTo
|
||||||
|
import com.appttude.h_mal.days_left.ui.main.MainActivity.Companion.ref
|
||||||
|
import com.appttude.h_mal.days_left.FirebaseClass.Companion.SHIFT_ID
|
||||||
|
import com.appttude.h_mal.days_left.models.AbnObject
|
||||||
|
import com.appttude.h_mal.days_left.models.ShiftObject
|
||||||
|
import com.google.firebase.database.Query
|
||||||
|
import kotlinx.android.synthetic.main.dialog_previous_abns_used.view.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_list.*
|
||||||
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
|
|
||||||
|
class FragmentList : androidx.fragment.app.Fragment() {
|
||||||
|
|
||||||
|
lateinit var fireAdapter: FireAdapter
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
return inflater.inflate(R.layout.fragment_list, container, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
//set custom firebase adapter on listview
|
||||||
|
fireAdapter = FireAdapter(
|
||||||
|
activity,
|
||||||
|
ShiftObject::class.java,
|
||||||
|
R.layout.list_item,
|
||||||
|
ref
|
||||||
|
)
|
||||||
|
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 = ref.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,
|
||||||
|
ref.orderByChild("dateTimeAdded")
|
||||||
|
)
|
||||||
|
2 -> fireAdapter = FireAdapter(
|
||||||
|
activity,
|
||||||
|
ShiftObject::class.java,
|
||||||
|
R.layout.list_item,
|
||||||
|
ref.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 = ref.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 = ref.orderByChild("abnObject/abn").equalTo(arg1)
|
||||||
|
} else {
|
||||||
|
q1 = ref.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,183 @@
|
|||||||
|
package com.appttude.h_mal.days_left.ui.main.tools
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
|
import android.content.ActivityNotFoundException
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.pm.PackageManager
|
||||||
|
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.Toast
|
||||||
|
import androidx.core.content.ContextCompat.checkSelfPermission
|
||||||
|
import androidx.core.content.FileProvider
|
||||||
|
import com.appttude.h_mal.days_left.BuildConfig
|
||||||
|
import com.appttude.h_mal.days_left.R
|
||||||
|
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.storage.FirebaseStorage
|
||||||
|
import kotlinx.android.synthetic.main.fragment_tools.*
|
||||||
|
import java.io.File
|
||||||
|
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,91 @@
|
|||||||
|
package com.appttude.h_mal.days_left.utils
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Context
|
||||||
|
import android.net.Uri
|
||||||
|
import android.text.Editable
|
||||||
|
import android.text.TextWatcher
|
||||||
|
import android.view.View
|
||||||
|
import android.view.inputmethod.InputMethodManager
|
||||||
|
import android.widget.EditText
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import com.squareup.picasso.Picasso
|
||||||
|
import java.lang.Exception
|
||||||
|
|
||||||
|
fun View.show() {
|
||||||
|
this.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
|
fun View.hide() {
|
||||||
|
this.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Context.showToast(message: String) {
|
||||||
|
Toast.makeText(this, message, Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Context.showToast(@StringRes resourceId: Int) {
|
||||||
|
Toast.makeText(this, resourceId, Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Context.hideKeyboard(view: View?) {
|
||||||
|
val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
inputMethodManager.hideSoftInputFromWindow(view?.windowToken, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
//fun View.navigateTo(navigationId: Int) {
|
||||||
|
// try {
|
||||||
|
// Navigation.findNavController(this).navigate(navigationId)
|
||||||
|
// }catch (e: IllegalArgumentException){
|
||||||
|
// e.printStackTrace()
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//fun View.navigateTo(navDirections: NavDirections) {
|
||||||
|
// Navigation.findNavController(this).navigate(navDirections)
|
||||||
|
//}
|
||||||
|
|
||||||
|
fun EditText.afterTextChanged(afterTextChanged: (String) -> Unit) {
|
||||||
|
this.addTextChangedListener(object : TextWatcher {
|
||||||
|
override fun afterTextChanged(editable: Editable?) {
|
||||||
|
afterTextChanged.invoke(editable.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
|
||||||
|
|
||||||
|
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//fun ImageView.setPicassoIcon(profileUrl: String?) {
|
||||||
|
// val width = layoutParams?.width?.takeIf { it > 0 }
|
||||||
|
// val height = layoutParams?.height?.takeIf { it > 0 }
|
||||||
|
//
|
||||||
|
// val builder = Picasso.get()
|
||||||
|
// .load(profileUrl)
|
||||||
|
// .placeholder(R.drawable.ic_prova_id_icon)
|
||||||
|
// if (width != null && height != null){
|
||||||
|
// builder
|
||||||
|
// .resize(width, height)
|
||||||
|
// .centerCrop()
|
||||||
|
// }
|
||||||
|
// builder.into(this)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//fun ImageView.setPicassoIcon(profileUri: Uri?) {
|
||||||
|
// val width = layoutParams?.width?.takeIf { it > 0 }
|
||||||
|
// val height = layoutParams?.height?.takeIf { it > 0 }
|
||||||
|
//
|
||||||
|
// val builder = Picasso.get()
|
||||||
|
// .load(profileUri)
|
||||||
|
// .placeholder(R.drawable.ic_prova_id_icon)
|
||||||
|
// if (width != null && height != null){
|
||||||
|
// builder
|
||||||
|
// .resize(width, height)
|
||||||
|
// .centerCrop()
|
||||||
|
// }
|
||||||
|
// builder.into(this)
|
||||||
|
//}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="12dp"
|
android:layout_marginLeft="12dp"
|
||||||
@@ -87,6 +87,6 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="com.appttude.h_mal.days_left.MainActivity">
|
tools:context="com.appttude.h_mal.days_left.MainActivity">
|
||||||
|
|
||||||
<android.support.design.widget.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:id="@+id/appbar"
|
android:id="@+id/appbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
android:paddingTop="@dimen/appbar_padding_top"
|
android:paddingTop="@dimen/appbar_padding_top"
|
||||||
android:theme="@style/AppTheme.AppBarOverlay">
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<androidx.appcompat.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
@@ -24,9 +24,9 @@
|
|||||||
app:popupTheme="@style/AppTheme.PopupOverlay"
|
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||||
app:title="@string/app_name">
|
app:title="@string/app_name">
|
||||||
|
|
||||||
</android.support.v7.widget.Toolbar>
|
</androidx.appcompat.widget.Toolbar>
|
||||||
|
|
||||||
</android.support.design.widget.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_below="@id/appbar"
|
android:layout_below="@id/appbar"
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:id="@+id/centre_view">
|
android:id="@+id/centre_view">
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/select_employer_card"
|
android:id="@+id/select_employer_card"
|
||||||
style="@style/cardview_theme"
|
style="@style/cardview_theme"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -86,9 +86,9 @@
|
|||||||
android:paddingBottom="12dp"
|
android:paddingBottom="12dp"
|
||||||
android:text="Select Employer"
|
android:text="Select Employer"
|
||||||
android:textSize="18sp" />
|
android:textSize="18sp" />
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/select_task_card"
|
android:id="@+id/select_task_card"
|
||||||
style="@style/cardview_theme"
|
style="@style/cardview_theme"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -149,9 +149,9 @@
|
|||||||
android:paddingBottom="12dp"
|
android:paddingBottom="12dp"
|
||||||
android:text="Select Task"
|
android:text="Select Task"
|
||||||
android:textSize="18sp" />
|
android:textSize="18sp" />
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/select_times_card"
|
android:id="@+id/select_times_card"
|
||||||
style="@style/cardview_theme"
|
style="@style/cardview_theme"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -241,7 +241,7 @@
|
|||||||
android:text="insert times"
|
android:text="insert times"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:visibility="visible" />
|
android:visibility="visible" />
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/units"
|
android:id="@+id/units"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/drawer_layout"
|
android:id="@+id/drawer_layout"
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
<android.support.design.widget.NavigationView
|
<com.google.android.material.navigation.NavigationView
|
||||||
android:id="@+id/nav_view"
|
android:id="@+id/nav_view"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
@@ -38,6 +38,6 @@
|
|||||||
android:textColor="@color/colorPrimary"
|
android:textColor="@color/colorPrimary"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</android.support.design.widget.NavigationView>
|
</com.google.android.material.navigation.NavigationView>
|
||||||
|
|
||||||
</android.support.v4.widget.DrawerLayout>
|
</androidx.drawerlayout.widget.DrawerLayout>
|
||||||
|
|||||||
@@ -1,20 +1,24 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="com.appttude.h_mal.days_left.MainActivity">
|
tools:context="com.appttude.h_mal.days_left.ui.main.MainActivity">
|
||||||
|
|
||||||
<android.support.design.widget.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:id="@+id/appbar"
|
android:id="@+id/appbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="@dimen/appbar_padding_top"
|
android:paddingTop="@dimen/appbar_padding_top"
|
||||||
android:theme="@style/AppTheme.AppBarOverlay">
|
android:theme="@style/AppTheme.AppBarOverlay"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent">
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<androidx.appcompat.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
@@ -24,18 +28,22 @@
|
|||||||
app:popupTheme="@style/AppTheme.PopupOverlay"
|
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||||
app:title="@string/app_name">
|
app:title="@string/app_name">
|
||||||
|
|
||||||
</android.support.v7.widget.Toolbar>
|
</androidx.appcompat.widget.Toolbar>
|
||||||
|
|
||||||
</android.support.design.widget.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_below="@id/appbar"
|
android:layout_below="@id/appbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="0dp"
|
||||||
android:layout_above="@id/navigation"
|
android:layout_above="@id/navigation"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/navigation"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/appbar"
|
||||||
android:id="@+id/container">
|
android:id="@+id/container">
|
||||||
|
|
||||||
<android.support.design.widget.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
android:id="@+id/fab"
|
android:id="@+id/fab"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -50,14 +58,21 @@
|
|||||||
style="?android:attr/progressBarStyle"
|
style="?android:attr/progressBarStyle"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
|
|
||||||
<android.support.design.widget.BottomNavigationView
|
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
android:id="@+id/navigation"
|
android:id="@+id/navigation"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:background="?android:attr/windowBackground"
|
android:background="?android:attr/windowBackground"
|
||||||
app:menu="@menu/navigation" />
|
app:menu="@menu/navigation"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
tools:context=".AddItems.AddEmployerFragment">
|
tools:context=".AddItems.AddEmployerFragment">
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/Search"
|
android:id="@+id/Search"
|
||||||
style="@style/cardview_theme"
|
style="@style/cardview_theme"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -46,9 +46,9 @@
|
|||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/idk"
|
android:id="@+id/idk"
|
||||||
style="@style/cardview_theme"
|
style="@style/cardview_theme"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -104,6 +104,6 @@
|
|||||||
android:paddingBottom="12dp"
|
android:paddingBottom="12dp"
|
||||||
android:text="I dont know yet"
|
android:text="I dont know yet"
|
||||||
android:textSize="18sp" />
|
android:textSize="18sp" />
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -7,23 +7,23 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".AddItems.AddEmployerFragment">
|
tools:context=".AddItems.AddEmployerFragment">
|
||||||
|
|
||||||
<android.support.design.widget.TabLayout
|
<com.google.android.material.tabs.TabLayout
|
||||||
android:id="@+id/tab_layout"
|
android:id="@+id/tab_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<android.support.design.widget.TabItem
|
<com.google.android.material.tabs.TabItem
|
||||||
android:id="@+id/abn"
|
android:id="@+id/abn"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="A.B.N" />
|
android:text="A.B.N" />
|
||||||
|
|
||||||
<android.support.design.widget.TabItem
|
<com.google.android.material.tabs.TabItem
|
||||||
android:id="@+id/name"
|
android:id="@+id/name"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Name" />
|
android:text="Name" />
|
||||||
</android.support.design.widget.TabLayout>
|
</com.google.android.material.tabs.TabLayout>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/search_edittext"
|
android:id="@+id/search_edittext"
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:id="@+id/centre_view">
|
android:id="@+id/centre_view">
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/card_one"
|
android:id="@+id/card_one"
|
||||||
style="@style/cardview_theme"
|
style="@style/cardview_theme"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -39,9 +39,9 @@
|
|||||||
|
|
||||||
</Spinner>
|
</Spinner>
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/card_two"
|
android:id="@+id/card_two"
|
||||||
style="@style/cardview_theme"
|
style="@style/cardview_theme"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -78,9 +78,9 @@
|
|||||||
tools:text="per hour" />
|
tools:text="per hour" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/card_three"
|
android:id="@+id/card_three"
|
||||||
style="@style/cardview_theme"
|
style="@style/cardview_theme"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
|
|
||||||
</Spinner>
|
</Spinner>
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="12dp">
|
android:padding="12dp">
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="6dp">
|
android:padding="6dp">
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
android:inputType="textEmailAddress"
|
android:inputType="textEmailAddress"
|
||||||
android:maxLines="1" />
|
android:maxLines="1" />
|
||||||
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="com.appttude.h_mal.days_left.FragmentHome">
|
tools:context="com.appttude.h_mal.days_left.FragmentHome">
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
|
||||||
android:id="@+id/recycler">
|
android:id="@+id/recycler">
|
||||||
|
|
||||||
</android.support.v7.widget.RecyclerView>
|
</androidx.recyclerview.widget.RecyclerView>
|
||||||
<!--android:background="@drawable/gradient_background"-->
|
<!--android:background="@drawable/gradient_background"-->
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="com.appttude.h_mal.days_left.FragmentList">
|
tools:context="com.appttude.h_mal.days_left.ui.main.list.FragmentList">
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/page_two_list"
|
android:id="@+id/page_two_list"
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
style="@style/cardview_theme"
|
style="@style/cardview_theme"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -48,9 +48,9 @@
|
|||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textColorHighlight="@color/three" />
|
android:textColorHighlight="@color/three" />
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
style="@style/cardview_theme"
|
style="@style/cardview_theme"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
android:textColorHighlight="@color/three" />
|
android:textColorHighlight="@color/three" />
|
||||||
|
|
||||||
<!--</android.support.design.widget.TextInputLayout>-->
|
<!--</android.support.design.widget.TextInputLayout>-->
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/register"
|
android:id="@+id/register"
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
android:padding="12dp"
|
android:padding="12dp"
|
||||||
android:layout_centerInParent="true">
|
android:layout_centerInParent="true">
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
style="@style/cardview_theme"
|
style="@style/cardview_theme"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -43,9 +43,9 @@
|
|||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textColorHighlight="@color/three" />
|
android:textColorHighlight="@color/three" />
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
style="@style/cardview_theme"
|
style="@style/cardview_theme"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -68,9 +68,9 @@
|
|||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textColorHighlight="@color/three" />
|
android:textColorHighlight="@color/three" />
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
style="@style/cardview_theme"
|
style="@style/cardview_theme"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -93,9 +93,9 @@
|
|||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textColorHighlight="@color/three" />
|
android:textColorHighlight="@color/three" />
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
style="@style/cardview_theme"
|
style="@style/cardview_theme"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -118,7 +118,7 @@
|
|||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textColorHighlight="@color/three" />
|
android:textColorHighlight="@color/three" />
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".FragmentTools">
|
tools:context=".ui.main.tools.FragmentTools">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
@@ -35,4 +35,4 @@
|
|||||||
android:includeFontPadding="false"
|
android:includeFontPadding="false"
|
||||||
android:textColor="@color/one" />
|
android:textColor="@color/one" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</android.support.constraint.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="12dp"
|
android:layout_marginLeft="12dp"
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_margin="16dp">
|
android:layout_margin="16dp">
|
||||||
|
|
||||||
<com.appttude.h_mal.days_left.arc.CircleView
|
<com.appttude.h_mal.days_left.ui.customViews.CircleView
|
||||||
android:id="@+id/arc_view"
|
android:id="@+id/arc_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
@@ -73,6 +73,6 @@
|
|||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="12dp"
|
android:layout_marginLeft="12dp"
|
||||||
@@ -96,6 +96,6 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="12dp"
|
android:layout_marginLeft="12dp"
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
<!--android:text="Hourly" />-->
|
<!--android:text="Hourly" />-->
|
||||||
<!--</LinearLayout>-->
|
<!--</LinearLayout>-->
|
||||||
|
|
||||||
<com.appttude.h_mal.days_left.bar.BarView
|
<com.appttude.h_mal.days_left.ui.customViews.BarView
|
||||||
android:id="@+id/bar"
|
android:id="@+id/bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="80dp" />
|
android:layout_height="80dp" />
|
||||||
@@ -122,6 +122,6 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="12dp"
|
android:layout_marginLeft="12dp"
|
||||||
@@ -170,6 +170,6 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
android:theme="@style/ThemeOverlay.AppCompat.Dark">
|
android:theme="@style/ThemeOverlay.AppCompat.Dark">
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="100dp"
|
android:layout_height="100dp"
|
||||||
android:layout_above="@id/id_holder"
|
android:layout_above="@id/id_holder"
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
android:contentDescription="@string/nav_header_desc"
|
android:contentDescription="@string/nav_header_desc"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
app:srcCompat="@mipmap/ic_launcher_round" />
|
app:srcCompat="@mipmap/ic_launcher_round" />
|
||||||
</android.support.v7.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<!--<external-path name="external_files" path="."/>-->
|
<!--<external-path name="external_files" path="."/>-->
|
||||||
<external-path name="Shift_tracker" path="ShifttrackerTemp/"/>
|
<external-path name="days_left" path="DaysLeftTemp/"/>
|
||||||
</paths>
|
</paths>
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
|
ext.kotlin_version = '1.3.72'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.4.1'
|
classpath 'com.android.tools.build:gradle:4.0.0'
|
||||||
classpath 'com.google.gms:google-services:4.2.0'
|
classpath 'com.google.gms:google-services:4.2.0'
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
|||||||
@@ -6,7 +6,11 @@
|
|||||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
# Specifies the JVM arguments used for the daemon process.
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
# The setting is particularly useful for tweaking memory settings.
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
android.enableJetifier=true
|
||||||
|
android.useAndroidX=true
|
||||||
org.gradle.jvmargs=-Xmx1536m
|
org.gradle.jvmargs=-Xmx1536m
|
||||||
|
# Kotlin code style for this project: "official" or "obsolete":
|
||||||
|
kotlin.code.style=official
|
||||||
# When configured, Gradle will run in incubating parallel mode.
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
# This option should only be used with decoupled projects. More details, visit
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
|
|||||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
#Thu May 23 18:32:51 AEST 2019
|
#Wed Jul 08 22:53:11 BST 2020
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
||||||
|
|||||||
Reference in New Issue
Block a user