Initial commit

This commit is contained in:
2019-05-29 20:22:58 +10:00
commit e046e57e04
151 changed files with 9814 additions and 0 deletions

11
.gitignore vendored Normal file
View File

@@ -0,0 +1,11 @@
*.iml
.gradle
/local.properties
/.idea/caches/build_file_checksums.ser
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
.DS_Store
/build
/captures
.externalNativeBuild

52
.idea/assetWizardSettings.xml generated Normal file
View File

@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="WizardSettings">
<option name="children">
<map>
<entry key="imageWizard">
<value>
<PersistentState />
</value>
</entry>
<entry key="vectorWizard">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="vectorAssetStep">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="clipartAsset">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="url" value="jar:file:/C:/Program%20Files/Android/Android%20Studio/plugins/android/lib/android.jar!/images/material_design_icons/content/ic_sort_black_24dp.xml" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
<option name="values">
<map>
<entry key="color" value="ffffff" />
<entry key="outputName" value="ic_sort_black_24dp" />
<entry key="sourceFile" value="C:\Users\h_mal" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</component>
</project>

BIN
.idea/caches/gradle_models.ser generated Normal file

Binary file not shown.

4
.idea/encodings.xml generated Normal file
View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>

21
.idea/gradle.xml generated Normal file
View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<compositeConfiguration>
<compositeBuild compositeDefinitionSource="SCRIPT" />
</compositeConfiguration>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>

44
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="10">
<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="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
<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="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="9">
<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="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
<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="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

12
.idea/runConfigurations.xml generated Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>

1
app/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

46
app/build.gradle Normal file
View File

@@ -0,0 +1,46 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.appttude.h_mal.days_left"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.google.code.gson:gson:2.3.1'
implementation 'com.android.support:exifinterface:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.google.android.gms:play-services-auth: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-storage:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.firebaseui:firebase-ui-database:1.1.1'
implementation 'com.google.firebase:firebase-functions:16.2.0'
implementation 'com.github.chrisbanes:PhotoView:2.1.0'
implementation 'com.squareup.picasso:picasso:2.71828'
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'

42
app/google-services.json Normal file
View File

@@ -0,0 +1,42 @@
{
"project_info": {
"project_number": "640643168912",
"firebase_url": "https://farmr-8a496.firebaseio.com",
"project_id": "farmr-8a496",
"storage_bucket": "farmr-8a496.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:640643168912:android:34c3a70dd882364a",
"android_client_info": {
"package_name": "com.appttude.h_mal.days_left"
}
},
"oauth_client": [
{
"client_id": "640643168912-0ssmglfad3vi7f6pok33rrjalm5phlq4.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyA4PcycGfWC3SBUxWqK2qMr9bEpwB3SWaY"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}

21
app/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -0,0 +1,26 @@
package com.appttude.h_mal.days_left;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("h_mal.appttude.com.days_left", appContext.getPackageName());
}
}

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.appttude.h_mal.days_left">
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar">
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name" />
<activity
android:name=".Login.FullscreenActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AddItems.AddItemActivity" />
<activity android:name=".AddItems.AddShiftActivity" />
<activity android:name=".Login.ChangeUserDetailsActivity"></activity>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
</application>
</manifest>

View File

@@ -0,0 +1,49 @@
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;
}
}

View File

@@ -0,0 +1,124 @@
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));
}
}

View File

@@ -0,0 +1,175 @@
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;
}
}

View File

@@ -0,0 +1,171 @@
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;
}
};
}

View File

@@ -0,0 +1,82 @@
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 = (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();
}
}
}

View File

@@ -0,0 +1,639 @@
package com.appttude.h_mal.days_left.AddItems;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Typeface;
import android.media.tv.TvContract;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.CardView;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.TimePicker;
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.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.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.sql.Time;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
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;
import static com.appttude.h_mal.days_left.MainActivity.Epoch2DateTimes;
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();
}
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.start_time);
finishTimeTextView = view.findViewById(R.id.finish_time);
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);
}
}
}

View File

@@ -0,0 +1,328 @@
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;
}
}

View File

@@ -0,0 +1,93 @@
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);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity();
}
});
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setView(dialogView);
final AlertDialog alertDialog = builder.create();
alertDialog.show();
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);
}
}

View File

@@ -0,0 +1,56 @@
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;
}
}

View File

@@ -0,0 +1,126 @@
package com.appttude.h_mal.days_left.AddItems;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
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.EditText;
import android.widget.LinearLayout;
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;
import java.util.Calendar;
import static com.appttude.h_mal.days_left.MainActivity.Epoch2DateString;
import static com.appttude.h_mal.days_left.MainActivity.Epoch2DateTimes;
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.start_time);
finishTimeTextView = view.findViewById(R.id.finish_time);
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) {
}
});
}
}
}

View File

@@ -0,0 +1,126 @@
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);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity();
}
});
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setView(dialogView);
final AlertDialog alertDialog = builder.create();
alertDialog.show();
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);
}
}

View File

@@ -0,0 +1,128 @@
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 com.appttude.h_mal.days_left.Abn.AbnListAdapter;
import com.appttude.h_mal.days_left.Abn.AbnObject;
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);
Intent returnIntent = new Intent();
returnIntent.putExtra("AbnObject",currentAbnObject);
activity.setResult(Activity.RESULT_OK,returnIntent);
activity.finish();
}
});
}else if (abnObjectArrayList == null){
linearLayout.setVisibility(View.VISIBLE);
listView.setVisibility(View.GONE);
}
}else {
onTaskCompleted.onTaskCompleted(s);
}
}
}

View File

@@ -0,0 +1,175 @@
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));
}
}
}
}

View File

@@ -0,0 +1,25 @@
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);
}
}

View File

@@ -0,0 +1,118 @@
package com.appttude.h_mal.days_left;
import android.app.Activity;
import android.util.Log;
import android.view.View;
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.DatabaseReference;
import com.google.firebase.database.Query;
import java.util.ArrayList;
import java.util.List;
class FireAdapter extends FirebaseListAdapter<ShiftObject> {
String TAG = "FireAdapter";
Query ref;
/**
* @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);
this.ref = ref;
}
@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();
}
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;
}
}

View File

@@ -0,0 +1,253 @@
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);
}
}
}

View File

@@ -0,0 +1,51 @@
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 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 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()));
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
// recyclerView.setHasFixedSize(true);
return view;
}
}

View File

@@ -0,0 +1,177 @@
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);
}
});
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:
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:
adapter = new FireAdapter(getActivity(), ShiftObject.class, R.layout.list_item, reference.orderByChild("abnObject/companyName"));
break;
case 1:
adapter = new FireAdapter(getActivity(), ShiftObject.class, R.layout.list_item, reference.orderByChild("shiftDate"));
break;
case 2:
adapter = new FireAdapter(getActivity(), ShiftObject.class, R.layout.list_item, reference.orderByChild("dateTimeAdded"));
break;
default:
}
listView.setAdapter(adapter);
dialog.dismiss();
}
})
// .setPositiveButton("Ascending", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int id) {
//// sortOrder = sortQuery[0] + " ASC";
//
// dialog.dismiss();
// }
// }).setNegativeButton("Descending", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int id) {
//// sortOrder = sortQuery[0] + " DESC";
//
// dialog.dismiss();
// }
// })
;
AlertDialog alert = alt_bld.create();
alert.show();
}
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;
}
}

View File

@@ -0,0 +1,525 @@
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();
}
}
}

View File

@@ -0,0 +1,125 @@
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;
editText.setText(String.format("%02d", mDay) + "/" +
String.format("%02d", (mMonth)) +"/" +
mYear
);
}
};
}

View File

@@ -0,0 +1,33 @@
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();
}
}

View File

@@ -0,0 +1,414 @@
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();
Context context;
Uri filePath;
public interface Response {
void retrieveAbnStringList(List<String> abnList);
void retrieveAbnObjectList(List<AbnObject> abnObjects);
void retrieveTaskList(List<TaskObject> taskObjects);
}
public Response delegate;
public interface Complete{
void taskCompleted(Boolean success);
}
public FirebaseClass() {
}
public FirebaseClass(Context context, Uri filePath, Response delegate) {
this.context = context;
this.filePath = filePath;
this.delegate = delegate;
}
// 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(abnList);
}
});
}
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 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());
}
}

View File

@@ -0,0 +1,56 @@
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);
}
}

View File

@@ -0,0 +1,220 @@
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();
}
}

View File

@@ -0,0 +1,63 @@
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();
}
}
});
}
}

View File

@@ -0,0 +1,44 @@
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();
}
}
}

View File

@@ -0,0 +1,338 @@
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;
}
}

View File

@@ -0,0 +1,176 @@
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;
}
}

View File

@@ -0,0 +1,367 @@
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.List;
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;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_drawer_main);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
// reference.addListenerForSingleValueEvent(valueEventListener);
fragmentManager = getSupportFragmentManager();
progressBar = (ProgressBar) findViewById(R.id.progressBar2);
progressBar.setVisibility(View.GONE);
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this,AddShiftActivity.class);
startActivity(intent);
}
});
fragmentManager.addOnBackStackChangedListener(backStackChangedListener);
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;
}
});
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.container,new FragmentHome()).commit();
setupDrawer();
parseXmlLayout();
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
}
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){
// FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
// fragmentTransaction.replace(R.id.container,new FragmentHome()).commit();
}else {
Toast.makeText(MainActivity.this, "List Empty", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Toast.makeText(MainActivity.this, "Cancelled", Toast.LENGTH_SHORT).show();
}
};
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;
case "logbookFragment":
title = "Logbook";
break;
case "MotFragment":
title = "M.O.T";
break;
case "PrivateHireLicenseFragment":
title = "Private Hire License";
break;
case "VehicleSetupFragment":
title = "Vehicle Profile";
break;
case "UserMainFragment":
return;
case "ArchiveFragment":
return;
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;
}
}

View File

@@ -0,0 +1,22 @@
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);
}
}

View File

@@ -0,0 +1,79 @@
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.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);
}
}

View File

@@ -0,0 +1,99 @@
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);
}
}

View File

@@ -0,0 +1,51 @@
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;
}
}

View File

@@ -0,0 +1,29 @@
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;
}
}

View File

@@ -0,0 +1,222 @@
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.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;
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
//
// String TAG = "something";
//
private Context context;
// private int dx;
//
public RecyclerViewAdapter(Context context) {
this.context = context;
}
//
// 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;
//// LinearLayout textholder;
//// LinearLayout bottomTextholder;
//
// public ItemTwo(View itemView){
// super(itemView);
//
// barView = itemView.findViewById(R.id.bar);
// linearLayout = itemView.findViewById(R.id.lin);
//// 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 = 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 ItemTwo viewTwo = (ItemTwo) holder;
//
// 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 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);
// 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() {
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;
// }
}

View File

@@ -0,0 +1,111 @@
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.LinearLayout;
import android.widget.TextView;
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;
}
}

View File

@@ -0,0 +1,26 @@
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();
}
}

View File

@@ -0,0 +1,116 @@
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;
}
}

View File

@@ -0,0 +1,27 @@
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();
}
}

View File

@@ -0,0 +1,122 @@
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);
}
}

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:fromDegrees="90" android:toDegrees="0"
android:pivotX="0%" android:pivotY="0%"
android:fillEnabled="true"
android:fillBefore="true" android:fillAfter="true"
android:duration="500" />
<alpha
android:fromAlpha="0.0" android:toAlpha="1.0"
android:fillEnabled="true"
android:fillBefore="true" android:fillAfter="true"
android:duration="500" />
</set>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:fromDegrees="0" android:toDegrees="-90"
android:pivotX="0%" android:pivotY="0%"
android:fillEnabled="true"
android:fillBefore="true" android:fillAfter="true"
android:duration="500" />
<alpha
android:fromAlpha="1.0" android:toAlpha="0.0"
android:fillEnabled="true"
android:fillBefore="true" android:fillAfter="true"
android:duration="500" />
</set>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:fromAlpha="0.5" android:toAlpha="1.0"
android:duration="200" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/transparent"/>
<stroke android:width="2dip" android:color="#03a9f4" />
<corners android:radius="22dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>

View File

@@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

View File

@@ -0,0 +1,9 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="135"
android:centerColor="@color/one"
android:endColor="@color/three"
android:startColor="@color/two"
android:type="linear" />
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 MiB

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/two"/>
<stroke android:width="1dip" android:color="@color/one" />
<corners android:radius="@dimen/rounding_radius"/>
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/transparent"/>
<stroke android:width="2dip" android:color="#03a9f4" />
<corners android:radius="@dimen/rounding_radius"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:useLevel="false">
<gradient
android:angle="45"
android:centerColor="#dce7f1"
android:endColor="#cafdbb"
android:startColor="#89b784"
android:useLevel="false" />
</shape>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M3,13h8L11,3L3,3v10zM3,21h8v-6L3,15v6zM13,21h8L21,11h-8v10zM13,3v6h8L21,3h-8z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z" />
</vector>

View File

@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#008577"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M3,13h2v-2L3,11v2zM3,17h2v-2L3,15v2zM3,9h2L5,7L3,7v2zM7,13h14v-2L7,11v2zM7,17h14v-2L7,15v2zM7,7v2h14L21,7L7,7z"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.89,2 2,2zM18,16v-5c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM19,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.11,0 2,-0.9 2,-2L21,5c0,-1.1 -0.89,-2 -2,-2zM17.25,12c0,0.23 -0.02,0.46 -0.05,0.68l1.48,1.16c0.13,0.11 0.17,0.3 0.08,0.45l-1.4,2.42c-0.09,0.15 -0.27,0.21 -0.43,0.15l-1.74,-0.7c-0.36,0.28 -0.76,0.51 -1.18,0.69l-0.26,1.85c-0.03,0.17 -0.18,0.3 -0.35,0.3h-2.8c-0.17,0 -0.32,-0.13 -0.35,-0.29l-0.26,-1.85c-0.43,-0.18 -0.82,-0.41 -1.18,-0.69l-1.74,0.7c-0.16,0.06 -0.34,0 -0.43,-0.15l-1.4,-2.42c-0.09,-0.15 -0.05,-0.34 0.08,-0.45l1.48,-1.16c-0.03,-0.23 -0.05,-0.46 -0.05,-0.69 0,-0.23 0.02,-0.46 0.05,-0.68l-1.48,-1.16c-0.13,-0.11 -0.17,-0.3 -0.08,-0.45l1.4,-2.42c0.09,-0.15 0.27,-0.21 0.43,-0.15l1.74,0.7c0.36,-0.28 0.76,-0.51 1.18,-0.69l0.26,-1.85c0.03,-0.17 0.18,-0.3 0.35,-0.3h2.8c0.17,0 0.32,0.13 0.35,0.29l0.26,1.85c0.43,0.18 0.82,0.41 1.18,0.69l1.74,-0.7c0.16,-0.06 0.34,0 0.43,0.15l1.4,2.42c0.09,0.15 0.05,0.34 -0.08,0.45l-1.48,1.16c0.03,0.23 0.05,0.46 0.05,0.69z"/>
</vector>

View File

@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M3,18h6v-2L3,16v2zM3,6v2h18L21,6L3,6zM3,13h12v-2L3,11v2z"/>
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="@color/two" />
<corners
android:radius="@dimen/rounding_radius" />
</shape>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/one"/>
<stroke android:width="2dip" android:color="@color/two" />
<corners android:radius="@dimen/rounding_radius"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/splash"
android:gravity="center"
android:tint="#da000000"
android:tintMode="src_over"/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/three"/>
<stroke android:width="1dip" android:color="@color/four" />
<corners android:radius="@dimen/rounding_radius"/>
</shape>

View File

@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginTop="6dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="6dp"
app:cardCornerRadius="@dimen/card_radius">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/farm_name"
style="@style/title_card"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:includeFontPadding="false"
android:textColor="@color/three"
tools:text="W and L farms" />
</LinearLayout>
<LinearLayout
android:id="@+id/text_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:orientation="horizontal">
<TextView
style="@style/text_major"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="left|center"
android:text="ABN : " />
<TextView
android:id="@+id/abn_text"
style="@style/text_minor"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
tools:text="75642358411" />
</LinearLayout>
<LinearLayout
android:id="@+id/text_holder_two"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/text_major"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="left|center"
android:text="Postcode : " />
<TextView
android:id="@+id/postcode_text"
style="@style/text_minor"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:text="QLD 4670" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</FrameLayout>

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.appttude.h_mal.days_left.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_alignParentTop="true"
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_weight="1"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:title="@string/app_name">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:layout_below="@id/appbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/navigation"
android:id="@+id/container"></FrameLayout>
<ProgressBar
android:id="@+id/progressBar2"
style="?android:attr/progressBarStyle"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>

View File

@@ -0,0 +1,291 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".AddItems.AddEmployerFragment">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progress_bar"
android:visibility="gone"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerInParent="true"
android:id="@+id/centre_view">
<android.support.v7.widget.CardView
android:id="@+id/select_employer_card"
style="@style/cardview_theme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16sp"
app:cardBackgroundColor="@color/two">
<LinearLayout
android:id="@+id/employer_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/cardviewoutline"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingTop="12dp"
android:paddingRight="16dp"
android:paddingBottom="12dp"
android:visibility="gone">
<TextView
android:id="@+id/employer_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:alpha="0.65"
android:textColor="@color/one"
android:textSize="20sp"
android:textStyle="bold"
tools:text="W and L farms" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:adjustViewBounds="true"
android:alpha="0.56"
android:src="@drawable/marker" />
<TextView
android:id="@+id/employer_location"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
tools:text="Bundaberg" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/lable_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingLeft="16dp"
android:paddingTop="12dp"
android:paddingRight="16dp"
android:paddingBottom="12dp"
android:text="Select Employer"
android:textSize="18sp" />
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/select_task_card"
style="@style/cardview_theme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16sp"
app:cardBackgroundColor="@color/two">
<LinearLayout
android:id="@+id/task_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/cardviewoutline"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingTop="12dp"
android:paddingRight="16dp"
android:paddingBottom="12dp"
android:visibility="gone">
<TextView
android:id="@+id/task"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:alpha="0.65"
android:textColor="@color/three"
android:textSize="16sp"
tools:text="Packing Tomatoes" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:adjustViewBounds="true"
android:alpha="0.56"
android:src="@drawable/task" />
<TextView
android:id="@+id/task_summary"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
tools:text="Bundaberg" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/lable_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingLeft="16dp"
android:paddingTop="12dp"
android:paddingRight="16dp"
android:paddingBottom="12dp"
android:text="Select Task"
android:textSize="18sp" />
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/select_times_card"
style="@style/cardview_theme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16sp"
app:cardBackgroundColor="@color/two">
<LinearLayout
android:id="@+id/time_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/cardviewoutline"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingTop="12dp"
android:paddingRight="16dp"
android:paddingBottom="12dp"
android:visibility="gone">
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:alpha="0.65"
android:textColor="@color/three"
android:textSize="16sp"
tools:text="11H 30m" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:adjustViewBounds="true"
android:alpha="0.56"
android:src="@drawable/clock_icon" />
<TextView
android:id="@+id/time_summary"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
tools:text="11:30 - 18:30" />
</LinearLayout>
<LinearLayout
android:id="@+id/break_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:adjustViewBounds="true"
android:alpha="0.56"
android:src="@drawable/break_time" />
<TextView
android:id="@+id/break_summary"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
tools:text="30 minutes" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/lable_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingLeft="16dp"
android:paddingTop="12dp"
android:paddingRight="16dp"
android:paddingBottom="12dp"
android:text="insert times"
android:textSize="18sp"
android:visibility="visible" />
</android.support.v7.widget.CardView>
<EditText
android:id="@+id/units"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:background="@drawable/round_edit_text"
android:hint="Insert units/time"
android:inputType="numberDecimal"
android:paddingLeft="16dp"
android:paddingTop="12dp"
android:paddingRight="16dp"
android:paddingBottom="12dp"
android:selectAllOnFocus="true"
android:textColorHighlight="#608d91" />
<EditText
android:id="@+id/date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/round_edit_text"
android:hint="Select date"
android:inputType="numberDecimal"
android:focusable="false"
android:paddingLeft="16dp"
android:paddingTop="12dp"
android:paddingRight="16dp"
android:paddingBottom="12dp"
android:selectAllOnFocus="true"
android:textColorHighlight="#608d91" />
</LinearLayout>
<ImageButton
android:id="@+id/search_button"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:background="@drawable/yes_button"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:scaleType="fitCenter"
android:src="@drawable/checkmark"
android:tint="#2b452d" />
</RelativeLayout>

View File

@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".Login.ChangeUserDetailsActivity">
<LinearLayout
android:id="@+id/ph_view_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="12dp"
android:layout_centerInParent="true">
<TextView
android:id="@+id/change_profile_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:background="@drawable/round_edit_text"
android:ems="10"
android:gravity="center"
android:padding="12dp"
android:selectAllOnFocus="true"
android:singleLine="true"
android:text="Change Profile Name"
android:textColorHighlight="#608d91" />
<TextView
android:id="@+id/change_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:background="@drawable/round_edit_text"
android:ems="10"
android:gravity="center"
android:padding="12dp"
android:selectAllOnFocus="true"
android:singleLine="true"
android:text="Change Email Address"
android:textColorHighlight="#608d91" />
<TextView
android:id="@+id/change_pw"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:background="@drawable/round_edit_text"
android:ems="10"
android:gravity="center"
android:padding="12dp"
android:selectAllOnFocus="true"
android:singleLine="true"
android:text="Change Password"
android:textColorHighlight="#608d91" />
</LinearLayout>
<Button
android:id="@+id/submit_profile"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="12dp"
android:layout_marginLeft="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="12dp"
android:background="@drawable/cardviewoutline"
android:text="@string/submit"
android:textColor="@android:color/black"
android:textStyle="bold" />
</RelativeLayout>

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:clickable="true"
android:orientation="vertical">
<TextView
android:id="@+id/logout"
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center"
android:text="Logout"
android:textColor="@color/colorPrimary"
android:textStyle="bold" />
</LinearLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.appttude.h_mal.days_left.Login.FullscreenActivity">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container">
</FrameLayout>
</FrameLayout>

View File

@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.appttude.h_mal.days_left.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_alignParentTop="true"
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_weight="1"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:title="@string/app_name">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:layout_below="@id/appbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/navigation"
android:id="@+id/container">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_input_add"
android:tint="@android:color/white" />
</FrameLayout>
<ProgressBar
android:id="@+id/progressBar2"
style="?android:attr/progressBarStyle"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="?android:attr/windowBackground"
app:menu="@menu/navigation" />
</RelativeLayout>

View File

@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".AddItems.AddEmployerFragment">
<android.support.v7.widget.CardView
android:id="@+id/Search"
style="@style/cardview_theme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16sp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignBottom="@id/title"
android:background="@drawable/cardviewoutline" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:paddingLeft="16dp"
android:paddingTop="12dp"
android:paddingRight="16dp"
android:paddingBottom="12dp"
android:text="Search via Name/ABN"
android:textSize="18sp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/idk"
style="@style/cardview_theme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@color/two">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/cardviewoutline"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingTop="12dp"
android:paddingRight="16dp"
android:paddingBottom="12dp"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:alpha="0.65"
android:textColor="@color/three"
android:textSize="16sp"
tools:text="Packing Tomatoes" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:adjustViewBounds="true"
android:alpha="0.56"
android:src="@drawable/task" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
tools:text="Bundaberg" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingLeft="16dp"
android:paddingTop="12dp"
android:paddingRight="16dp"
android:paddingBottom="12dp"
android:text="I dont know yet"
android:textSize="18sp" />
</android.support.v7.widget.CardView>
</LinearLayout>

View File

@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/button_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/start_time"
android:layout_width="0dp"
android:layout_height="@android:dimen/app_icon_size"
android:layout_weight="1"
android:gravity="center"
android:text="Start" />
<!--<ImageView-->
<!--android:layout_width="1dp"-->
<!--android:background="#8aa4bf"-->
<!--android:layout_height="match_parent"-->
<!--android:layout_margin="4dp"/>-->
<TextView
android:id="@+id/finish_time"
android:layout_width="0dp"
android:layout_height="@android:dimen/app_icon_size"
android:layout_weight="1"
android:gravity="center"
android:text="Finish" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TimePicker
android:id="@+id/time_picker"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:headerBackground="@color/colorPrimaryDark"
android:numbersSelectorColor="@color/colorPrimary">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|bottom">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Break (in minutes) : " />
<EditText
android:id="@+id/breaktime"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:inputType="number" />
</LinearLayout>
</TimePicker>
</LinearLayout>
<LinearLayout
android:id="@+id/end"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="0dp"
android:layout_height="@android:dimen/app_icon_size"
android:layout_weight="2" />
<TextView
android:id="@+id/ok"
android:layout_width="0dp"
android:layout_height="@android:dimen/app_icon_size"
android:layout_weight="1"
android:gravity="center"
android:text="OK"
android:textColor="@color/colorPrimaryDark"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>

Some files were not shown because too many files have changed in this diff Show More