Initial commit
9
.gitignore
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/libraries
|
||||||
|
.DS_Store
|
||||||
|
/build
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
||||||
22
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<resourceExtensions />
|
||||||
|
<wildcardResourcePatterns>
|
||||||
|
<entry name="!?*.java" />
|
||||||
|
<entry name="!?*.form" />
|
||||||
|
<entry name="!?*.class" />
|
||||||
|
<entry name="!?*.groovy" />
|
||||||
|
<entry name="!?*.scala" />
|
||||||
|
<entry name="!?*.flex" />
|
||||||
|
<entry name="!?*.kt" />
|
||||||
|
<entry name="!?*.clj" />
|
||||||
|
<entry name="!?*.aj" />
|
||||||
|
</wildcardResourcePatterns>
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile default="true" name="Default" enabled="false">
|
||||||
|
<processorPath useClasspath="true" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
3
.idea/copyright/profiles_settings.xml
generated
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<component name="CopyrightManager">
|
||||||
|
<settings default="" />
|
||||||
|
</component>
|
||||||
18
.idea/gradle.xml
generated
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/app" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
33
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?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="4">
|
||||||
|
<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="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||||
|
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||||
|
</list>
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="myNotNulls">
|
||||||
|
<value>
|
||||||
|
<list size="4">
|
||||||
|
<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" />
|
||||||
|
</list>
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" 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>
|
||||||
9
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/Shift_tracker.iml" filepath="$PROJECT_DIR$/Shift_tracker.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
12
.idea/runConfigurations.xml
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RunConfigurationProducerService">
|
||||||
|
<option name="ignoredProducers">
|
||||||
|
<set>
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
1
app/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/build
|
||||||
37
app/build.gradle
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 25
|
||||||
|
buildToolsVersion '26.0.2'
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "com.example.h_mal.shift_tracker"
|
||||||
|
minSdkVersion 21
|
||||||
|
targetSdkVersion 25
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
|
vectorDrawables.useSupportLibrary = true
|
||||||
|
}
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation 'com.android.support:support-v4:25.4.0'
|
||||||
|
implementation 'com.android.support:support-vector-drawable:25.4.0'
|
||||||
|
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
|
||||||
|
exclude group: 'com.android.support', module: 'support-annotations'
|
||||||
|
})
|
||||||
|
compile 'com.android.support:appcompat-v7:25.4.0'
|
||||||
|
compile 'com.android.support:design:25.4.0'
|
||||||
|
compile 'com.android.support.constraint:constraint-layout:1.0.2'
|
||||||
|
compile 'com.ajts.androidmads.SQLite2Excel:library:1.0.2'
|
||||||
|
|
||||||
|
compile 'com.google.android.gms:play-services-ads:11.8.0'
|
||||||
|
testCompile 'junit:junit:4.12'
|
||||||
|
}
|
||||||
25
app/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# By default, the flags in this file are appended to flags specified
|
||||||
|
# in C:\Users\h_mal\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
|
||||||
|
# You can edit the include path and order by changing the proguardFiles
|
||||||
|
# directive in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# Add any project specific keep options here:
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.example.h_mal.shift_tracker;
|
||||||
|
|
||||||
|
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.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrumentation 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() throws Exception {
|
||||||
|
// Context of the app under test.
|
||||||
|
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||||
|
|
||||||
|
assertEquals("com.example.h_mal.shift_tracker", appContext.getPackageName());
|
||||||
|
}
|
||||||
|
}
|
||||||
55
app/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.example.h_mal.shift_tracker">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@mipmap/farmicon"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@mipmap/farmicon"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/AppTheme">
|
||||||
|
|
||||||
|
<!-- Splash screen -->
|
||||||
|
<activity
|
||||||
|
android:name=".SplashScreen"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:screenOrientation="portrait"
|
||||||
|
android:theme="@android:style/Theme.Black.NoTitleBar">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:parentActivityName=".SplashScreen"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
<!--<activity-->
|
||||||
|
<!--android:name=".LoginSetup"-->
|
||||||
|
<!--android:parentActivityName=".SplashScreen"-->
|
||||||
|
<!--android:theme="@style/Theme.AppCompat.Light.NoActionBar">-->
|
||||||
|
<!--<meta-data-->
|
||||||
|
<!--android:name="android.support.PARENT_ACTIVITY"-->
|
||||||
|
<!--android:value=".SplashScreen" />-->
|
||||||
|
<!--</activity>-->
|
||||||
|
<!--<activity-->
|
||||||
|
<!--android:name=".LoginScreen"-->
|
||||||
|
<!--android:parentActivityName=".SplashScreen"-->
|
||||||
|
<!--android:theme="@style/Theme.AppCompat.Light.NoActionBar">-->
|
||||||
|
<!--<meta-data-->
|
||||||
|
<!--android:name="android.support.PARENT_ACTIVITY"-->
|
||||||
|
<!--android:value=".SplashScreen" />-->
|
||||||
|
<!--</activity>-->
|
||||||
|
|
||||||
|
<provider
|
||||||
|
android:name=".Data.ShiftProvider"
|
||||||
|
android:authorities="com.example.h_mal.shift_tracker"
|
||||||
|
android:exported="false" />
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
||||||
@@ -0,0 +1,262 @@
|
|||||||
|
package com.example.h_mal.shift_tracker.Data;
|
||||||
|
|
||||||
|
import android.content.ContentProvider;
|
||||||
|
import android.content.ContentUris;
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.content.UriMatcher;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.example.h_mal.shift_tracker.Data.ShiftsContract.ShiftsEntry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by h_mal on 26/12/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ShiftProvider extends ContentProvider {
|
||||||
|
|
||||||
|
|
||||||
|
public static final String LOG_TAG = ShiftProvider.class.getSimpleName();
|
||||||
|
|
||||||
|
private static final int SHIFTS = 100;
|
||||||
|
private static final int SHIFT_ID = 101;
|
||||||
|
|
||||||
|
private static final UriMatcher sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
|
||||||
|
|
||||||
|
|
||||||
|
static {
|
||||||
|
|
||||||
|
sUriMatcher.addURI(ShiftsContract.CONTENT_AUTHORITY, ShiftsContract.PATH_SHIFTS, SHIFTS);
|
||||||
|
|
||||||
|
sUriMatcher.addURI(ShiftsContract.CONTENT_AUTHORITY, ShiftsContract.PATH_SHIFTS + "/#", SHIFT_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
ShiftsDbHelper mDbHelper;
|
||||||
|
|
||||||
|
public ShiftProvider() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreate() {
|
||||||
|
mDbHelper = new ShiftsDbHelper(getContext());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
|
||||||
|
String sortOrder) {
|
||||||
|
|
||||||
|
SQLiteDatabase database = mDbHelper.getReadableDatabase();
|
||||||
|
|
||||||
|
Cursor cursor;
|
||||||
|
|
||||||
|
int match = sUriMatcher.match(uri);
|
||||||
|
switch (match) {
|
||||||
|
case SHIFTS:
|
||||||
|
|
||||||
|
cursor = database.query(ShiftsEntry.TABLE_NAME, projection, selection, selectionArgs,
|
||||||
|
null, null, sortOrder);
|
||||||
|
break;
|
||||||
|
case SHIFT_ID:
|
||||||
|
|
||||||
|
selection = ShiftsEntry._ID + "=?";
|
||||||
|
selectionArgs = new String[] { String.valueOf(ContentUris.parseId(uri)) };
|
||||||
|
cursor = database.query(ShiftsEntry.TABLE_NAME, projection, selection, selectionArgs,
|
||||||
|
null, null, sortOrder);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Cannot query " + uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor.setNotificationUri(getContext().getContentResolver(), uri);
|
||||||
|
|
||||||
|
return cursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Uri insert(Uri uri, ContentValues contentValues) {
|
||||||
|
final int match = sUriMatcher.match(uri);
|
||||||
|
switch (match) {
|
||||||
|
case SHIFTS:
|
||||||
|
return insertShift(uri, contentValues);
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Insertion is not supported for " + uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Uri insertShift(Uri uri, ContentValues values) {
|
||||||
|
|
||||||
|
String description = values.getAsString(ShiftsEntry.COLUMN_SHIFT_DESCRIPTION);
|
||||||
|
if (description == null) {
|
||||||
|
throw new IllegalArgumentException("Description required");
|
||||||
|
}
|
||||||
|
|
||||||
|
String date = values.getAsString(ShiftsEntry.COLUMN_SHIFT_DATE);
|
||||||
|
if (date == null) {
|
||||||
|
throw new IllegalArgumentException("Date required");
|
||||||
|
}
|
||||||
|
|
||||||
|
String timeIn = values.getAsString(ShiftsEntry.COLUMN_SHIFT_TIME_IN);
|
||||||
|
if (timeIn == null) {
|
||||||
|
throw new IllegalArgumentException("Time In required");
|
||||||
|
}
|
||||||
|
|
||||||
|
String timeOut = values.getAsString(ShiftsEntry.COLUMN_SHIFT_TIME_OUT);
|
||||||
|
if (timeOut == null) {
|
||||||
|
throw new IllegalArgumentException("Time Out required");
|
||||||
|
}
|
||||||
|
|
||||||
|
Float duration = values.getAsFloat(ShiftsEntry.COLUMN_SHIFT_DURATION);
|
||||||
|
if (duration < 0) {
|
||||||
|
throw new IllegalArgumentException("Duration cannot be negative");
|
||||||
|
}
|
||||||
|
|
||||||
|
String shiftType = values.getAsString(ShiftsEntry.COLUMN_SHIFT_TYPE);
|
||||||
|
if (shiftType == null) {
|
||||||
|
throw new IllegalArgumentException("Shift type required");
|
||||||
|
}
|
||||||
|
|
||||||
|
Float shiftUnits = values.getAsFloat(ShiftsEntry.COLUMN_SHIFT_UNIT);
|
||||||
|
if (shiftUnits < 0) {
|
||||||
|
throw new IllegalArgumentException("Units cannot be negative");
|
||||||
|
}
|
||||||
|
|
||||||
|
Float payRate = values.getAsFloat(ShiftsEntry.COLUMN_SHIFT_PAYRATE);
|
||||||
|
if (payRate < 0) {
|
||||||
|
throw new IllegalArgumentException("Pay rate cannot be negative");
|
||||||
|
}
|
||||||
|
|
||||||
|
Float totalPay = values.getAsFloat(ShiftsEntry.COLUMN_SHIFT_TOTALPAY);
|
||||||
|
if (totalPay < 0) {
|
||||||
|
throw new IllegalArgumentException("Total Pay cannot be negative");
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer breakMins = values.getAsInteger(ShiftsEntry.COLUMN_SHIFT_BREAK);
|
||||||
|
if (breakMins < 0) {
|
||||||
|
throw new IllegalArgumentException("Break cannot be negative");
|
||||||
|
}
|
||||||
|
|
||||||
|
SQLiteDatabase database = mDbHelper.getWritableDatabase();
|
||||||
|
|
||||||
|
long id = database.insert(ShiftsEntry.TABLE_NAME, null, values);
|
||||||
|
|
||||||
|
if (id == -1) {
|
||||||
|
Log.e(LOG_TAG, "row failed " + uri);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
getContext().getContentResolver().notifyChange(uri, null);
|
||||||
|
|
||||||
|
return ContentUris.withAppendedId(uri, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int update(Uri uri, ContentValues contentValues, String selection,
|
||||||
|
String[] selectionArgs) {
|
||||||
|
final int match = sUriMatcher.match(uri);
|
||||||
|
switch (match) {
|
||||||
|
case SHIFTS:
|
||||||
|
return updateShift(uri, contentValues, selection, selectionArgs);
|
||||||
|
case SHIFT_ID:
|
||||||
|
|
||||||
|
selection = ShiftsEntry._ID + "=?";
|
||||||
|
selectionArgs = new String[] { String.valueOf(ContentUris.parseId(uri)) };
|
||||||
|
return updateShift(uri, contentValues, selection, selectionArgs);
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Update is not supported for " + uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private int updateShift(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
|
||||||
|
|
||||||
|
if (values.containsKey(ShiftsEntry.COLUMN_SHIFT_DESCRIPTION)) {
|
||||||
|
String description = values.getAsString(ShiftsEntry.COLUMN_SHIFT_DESCRIPTION);
|
||||||
|
if (description == null) {
|
||||||
|
throw new IllegalArgumentException("description required");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (values.containsKey(ShiftsEntry.COLUMN_SHIFT_DATE)) {
|
||||||
|
String date = values.getAsString(ShiftsEntry.COLUMN_SHIFT_DATE);
|
||||||
|
if (date == null) {
|
||||||
|
throw new IllegalArgumentException("date required");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (values.containsKey(ShiftsEntry.COLUMN_SHIFT_TIME_IN)) {
|
||||||
|
String timeIn = values.getAsString(ShiftsEntry.COLUMN_SHIFT_TIME_IN);
|
||||||
|
if (timeIn == null) {
|
||||||
|
throw new IllegalArgumentException("time in required");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (values.containsKey(ShiftsEntry.COLUMN_SHIFT_TIME_OUT)) {
|
||||||
|
String timeOut = values.getAsString(ShiftsEntry.COLUMN_SHIFT_TIME_OUT);
|
||||||
|
if (timeOut == null) {
|
||||||
|
throw new IllegalArgumentException("time out required");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (values.containsKey(ShiftsEntry.COLUMN_SHIFT_BREAK)) {
|
||||||
|
String breaks = values.getAsString(ShiftsEntry.COLUMN_SHIFT_BREAK);
|
||||||
|
if (breaks == null) {
|
||||||
|
throw new IllegalArgumentException("break required");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (values.size() == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SQLiteDatabase database = mDbHelper.getWritableDatabase();
|
||||||
|
int rowsUpdated = database.update(ShiftsEntry.TABLE_NAME, values, selection, selectionArgs);
|
||||||
|
if (rowsUpdated != 0) {
|
||||||
|
getContext().getContentResolver().notifyChange(uri, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rowsUpdated;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int delete(Uri uri, String selection, String[] selectionArgs) {
|
||||||
|
SQLiteDatabase database = mDbHelper.getWritableDatabase();
|
||||||
|
|
||||||
|
int rowsDeleted;
|
||||||
|
|
||||||
|
final int match = sUriMatcher.match(uri);
|
||||||
|
switch (match) {
|
||||||
|
case SHIFTS:
|
||||||
|
rowsDeleted = database.delete(ShiftsEntry.TABLE_NAME, selection, selectionArgs);
|
||||||
|
break;
|
||||||
|
case SHIFT_ID:
|
||||||
|
selection = ShiftsEntry._ID + "=?";
|
||||||
|
selectionArgs = new String[] { String.valueOf(ContentUris.parseId(uri)) };
|
||||||
|
rowsDeleted = database.delete(ShiftsEntry.TABLE_NAME, selection, selectionArgs);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Deletion is not supported for " + uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rowsDeleted != 0) {
|
||||||
|
getContext().getContentResolver().notifyChange(uri, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rowsDeleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType(Uri uri) {
|
||||||
|
final int match = sUriMatcher.match(uri);
|
||||||
|
switch (match) {
|
||||||
|
case SHIFTS:
|
||||||
|
return ShiftsEntry.CONTENT_LIST_TYPE;
|
||||||
|
case SHIFT_ID:
|
||||||
|
return ShiftsEntry.CONTENT_ITEM_TYPE;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException("Unknown URI " + uri + " with match " + match);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package com.example.h_mal.shift_tracker.Data;
|
||||||
|
|
||||||
|
import android.content.ContentResolver;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.provider.BaseColumns;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by h_mal on 26/12/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ShiftsContract {
|
||||||
|
|
||||||
|
private ShiftsContract() {}
|
||||||
|
|
||||||
|
public static final String CONTENT_AUTHORITY = "com.example.h_mal.shift_tracker";
|
||||||
|
|
||||||
|
public static final Uri BASE_CONTENT_URI = Uri.parse("content://" + CONTENT_AUTHORITY);
|
||||||
|
|
||||||
|
public static final String PATH_SHIFTS = "shifts";
|
||||||
|
|
||||||
|
public static final class ShiftsEntry implements BaseColumns {
|
||||||
|
|
||||||
|
public static final Uri CONTENT_URI = Uri.withAppendedPath(BASE_CONTENT_URI, PATH_SHIFTS);
|
||||||
|
|
||||||
|
public static final String CONTENT_LIST_TYPE =
|
||||||
|
ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_SHIFTS;
|
||||||
|
|
||||||
|
|
||||||
|
public static final String CONTENT_ITEM_TYPE =
|
||||||
|
ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_SHIFTS;
|
||||||
|
|
||||||
|
|
||||||
|
public final static String TABLE_NAME = "shifts";
|
||||||
|
|
||||||
|
public final static String TABLE_NAME_EXPORT = "shiftsexport";
|
||||||
|
|
||||||
|
public final static String _ID = BaseColumns._ID;
|
||||||
|
|
||||||
|
public final static String COLUMN_SHIFT_TYPE = "shifttype";
|
||||||
|
|
||||||
|
public final static String COLUMN_SHIFT_DESCRIPTION = "description";
|
||||||
|
|
||||||
|
public final static String COLUMN_SHIFT_DATE = "date";
|
||||||
|
|
||||||
|
public final static String COLUMN_SHIFT_TIME_IN = "timein";
|
||||||
|
|
||||||
|
public final static String COLUMN_SHIFT_TIME_OUT = "timeout";
|
||||||
|
|
||||||
|
public final static String COLUMN_SHIFT_BREAK = "break";
|
||||||
|
|
||||||
|
public final static String COLUMN_SHIFT_DURATION = "duration";
|
||||||
|
|
||||||
|
public final static String COLUMN_SHIFT_UNIT = "unit";
|
||||||
|
|
||||||
|
public final static String COLUMN_SHIFT_PAYRATE = "payrate";
|
||||||
|
|
||||||
|
public final static String COLUMN_SHIFT_TOTALPAY = "totalpay";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
package com.example.h_mal.shift_tracker.Data;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
|
||||||
|
import com.example.h_mal.shift_tracker.Data.ShiftsContract.ShiftsEntry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by h_mal on 26/12/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ShiftsDbHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
|
public static final String LOG_TAG = ShiftsDbHelper.class.getSimpleName();
|
||||||
|
|
||||||
|
private static final String DATABASE_NAME = "shifts.db";
|
||||||
|
|
||||||
|
private static final int DATABASE_VERSION = 4;
|
||||||
|
|
||||||
|
private static String DEFAULT_TEXT = "Hourly";
|
||||||
|
|
||||||
|
|
||||||
|
public ShiftsDbHelper(Context context) {
|
||||||
|
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(SQLiteDatabase db) {
|
||||||
|
|
||||||
|
String SQL_CREATE_PRODUCTS_TABLE = "CREATE TABLE " + ShiftsEntry.TABLE_NAME + " ("
|
||||||
|
+ ShiftsEntry._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_DESCRIPTION + " TEXT NOT NULL, "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_DATE + " DATE NOT NULL, "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_TIME_IN + " TIME NOT NULL, "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_TIME_OUT + " TIME NOT NULL, "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_BREAK + " INTEGER NOT NULL DEFAULT 0, "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_DURATION + " FLOAT NOT NULL DEFAULT 0, "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_TYPE + " TEXT NOT NULL DEFAULT " + DEFAULT_TEXT + ", "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_UNIT + " FLOAT NOT NULL DEFAULT 0, "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_PAYRATE + " FLOAT NOT NULL DEFAULT 0, "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_TOTALPAY + " FLOAT NOT NULL DEFAULT 0)";
|
||||||
|
|
||||||
|
|
||||||
|
db.execSQL(SQL_CREATE_PRODUCTS_TABLE);
|
||||||
|
db.execSQL(SQL_CREATE_PRODUCTS_TABLE_2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String SQL_CREATE_PRODUCTS_TABLE_2 = "CREATE TABLE " + ShiftsEntry.TABLE_NAME_EXPORT + " ("
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_DESCRIPTION + " TEXT NOT NULL, "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_DATE + " DATE NOT NULL, "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_TIME_IN + " TIME NOT NULL, "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_TIME_OUT + " TIME NOT NULL, "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_BREAK + " INTEGER NOT NULL DEFAULT 0, "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_DURATION + " FLOAT NOT NULL DEFAULT 0, "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_TYPE + " TEXT NOT NULL DEFAULT " + DEFAULT_TEXT + ", "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_UNIT + " FLOAT NOT NULL DEFAULT 0, "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_PAYRATE + " FLOAT NOT NULL DEFAULT 0, "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_TOTALPAY + " FLOAT NOT NULL DEFAULT 0)";
|
||||||
|
|
||||||
|
private static final String DATABASE_ALTER_1 =
|
||||||
|
"ALTER TABLE " + ShiftsEntry.TABLE_NAME + " ADD COLUMN "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_TYPE + " TEXT NOT NULL DEFAULT " + DEFAULT_TEXT + ";";
|
||||||
|
|
||||||
|
private static final String DATABASE_ALTER_2 =
|
||||||
|
"ALTER TABLE " + ShiftsEntry.TABLE_NAME + " ADD COLUMN "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_UNIT + " FLOAT NOT NULL DEFAULT 0;";
|
||||||
|
|
||||||
|
private static final String DATABASE_ALTER_3 =
|
||||||
|
"ALTER TABLE " + ShiftsEntry.TABLE_NAME + " ADD COLUMN "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_PAYRATE + " FLOAT NOT NULL DEFAULT 0;";
|
||||||
|
|
||||||
|
private static final String DATABASE_ALTER_4 =
|
||||||
|
"ALTER TABLE " + ShiftsEntry.TABLE_NAME + " ADD COLUMN "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_TOTALPAY + " FLOAT NOT NULL DEFAULT 0;";
|
||||||
|
|
||||||
|
private static final String DATABASE_UPDATE_1 =
|
||||||
|
"UPDATE " + ShiftsEntry.TABLE_NAME + " SET "
|
||||||
|
+ ShiftsEntry.COLUMN_SHIFT_TYPE + " = replace( " + ShiftsEntry.COLUMN_SHIFT_TYPE + ", 'hourly', 'Hourly' )" +
|
||||||
|
" WHERE " + ShiftsEntry.COLUMN_SHIFT_TYPE + " LIKE 'hourly%'";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
if (oldVersion < newVersion) {
|
||||||
|
db.execSQL(SQL_CREATE_PRODUCTS_TABLE_2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,198 @@
|
|||||||
|
package com.example.h_mal.shift_tracker;
|
||||||
|
|
||||||
|
import android.app.DatePickerDialog;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.DatePicker;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import com.example.h_mal.shift_tracker.Data.ShiftsContract;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.example.h_mal.shift_tracker.MainActivity.args;
|
||||||
|
import static com.example.h_mal.shift_tracker.MainActivity.selection;
|
||||||
|
|
||||||
|
|
||||||
|
public class FilterDataFragment extends Fragment {
|
||||||
|
|
||||||
|
private String[] spinnerList = new String[]{"","Hourly","Piece Rate"};
|
||||||
|
private List<String> listArgs = new ArrayList<String>();
|
||||||
|
private EditText LocationET;
|
||||||
|
private EditText dateFromET;
|
||||||
|
private EditText dateToET;
|
||||||
|
private Spinner typeSpinner;
|
||||||
|
Calendar mcurrentDate;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
View rootView = inflater.inflate(R.layout.fragment_filter_data, container, false);
|
||||||
|
MainActivity.setActionBarTitle(getString(R.string.title_activity_filter_data));
|
||||||
|
|
||||||
|
mcurrentDate = Calendar.getInstance();
|
||||||
|
|
||||||
|
LocationET = (EditText) rootView.findViewById(R.id.filterLocationEditText);
|
||||||
|
dateFromET = (EditText) rootView.findViewById(R.id.fromdateInEditText);
|
||||||
|
dateToET = (EditText) rootView.findViewById(R.id.filterDateOutEditText);
|
||||||
|
typeSpinner = (Spinner) rootView.findViewById(R.id.TypeFilterEditText);
|
||||||
|
|
||||||
|
if(selection != null && selection.contains(" AND " + ShiftsContract.ShiftsEntry.COLUMN_SHIFT_DESCRIPTION + " LIKE ?")){
|
||||||
|
String str = args[2];
|
||||||
|
str = str.replace("%", "");
|
||||||
|
LocationET.setText(str);
|
||||||
|
}
|
||||||
|
if(selection != null && !args[0].equals("2000-01-01")){
|
||||||
|
dateFromET.setText(args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(selection != null && args != null && !args[1].equals(String.valueOf(mcurrentDate.get(Calendar.YEAR) + "-"
|
||||||
|
+ String.format("%02d", (mcurrentDate.get(Calendar.MONTH) + 1)) + "-"
|
||||||
|
+ String.format("%02d", mcurrentDate.get(Calendar.DAY_OF_MONTH))))){
|
||||||
|
dateToET.setText(args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
dateFromET.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
//To show current date in the datepicker
|
||||||
|
|
||||||
|
int mYear = mcurrentDate.get(Calendar.YEAR);
|
||||||
|
int mMonth = mcurrentDate.get(Calendar.MONTH);
|
||||||
|
int mDay = mcurrentDate.get(Calendar.DAY_OF_MONTH);
|
||||||
|
|
||||||
|
if(!dateFromET.getText().toString().equals("")) {
|
||||||
|
String dateString = dateFromET.getText().toString().trim();
|
||||||
|
|
||||||
|
mYear = Integer.parseInt(dateString.substring(0, 4));
|
||||||
|
mMonth = Integer.parseInt(dateString.substring(5, 7));
|
||||||
|
if (mMonth == 1){
|
||||||
|
mMonth = 0;
|
||||||
|
}else{
|
||||||
|
mMonth = mMonth -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
mDay = Integer.parseInt(dateString.substring(8));
|
||||||
|
}
|
||||||
|
DatePickerDialog mDatePicker=new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {
|
||||||
|
public void onDateSet(DatePicker datepicker, int selectedyear, int selectedmonth, int selectedday) {
|
||||||
|
dateFromET.setText(
|
||||||
|
selectedyear + "-"
|
||||||
|
+ String.format("%02d", (selectedmonth + 1)) + "-"
|
||||||
|
+ String.format("%02d", selectedday)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},mYear, mMonth, mDay);
|
||||||
|
mDatePicker.setTitle("Select date");
|
||||||
|
mDatePicker.show(); }
|
||||||
|
});
|
||||||
|
|
||||||
|
dateToET.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
//To show current date in the datepicker
|
||||||
|
Calendar mcurrentDate = Calendar.getInstance();
|
||||||
|
int mYear = mcurrentDate.get(Calendar.YEAR);
|
||||||
|
int mMonth = mcurrentDate.get(Calendar.MONTH);
|
||||||
|
int mDay = mcurrentDate.get(Calendar.DAY_OF_MONTH);
|
||||||
|
|
||||||
|
if(!dateToET.getText().toString().equals("")) {
|
||||||
|
String dateString = dateToET.getText().toString().trim();
|
||||||
|
|
||||||
|
mYear = Integer.parseInt(dateString.substring(0, 4));
|
||||||
|
mMonth = Integer.parseInt(dateString.substring(5, 7));
|
||||||
|
if (mMonth == 1){
|
||||||
|
mMonth = 0;
|
||||||
|
}else{
|
||||||
|
mMonth = mMonth -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
mDay = Integer.parseInt(dateString.substring(8));
|
||||||
|
}
|
||||||
|
|
||||||
|
DatePickerDialog mDatePicker=new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {
|
||||||
|
public void onDateSet(DatePicker datepicker, int selectedyear, int selectedmonth, int selectedday) {
|
||||||
|
dateToET.setText(
|
||||||
|
selectedyear + "-"
|
||||||
|
+ String.format("%02d", (selectedmonth + 1)) + "-"
|
||||||
|
+ String.format("%02d", selectedday)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},mYear, mMonth, mDay);
|
||||||
|
mDatePicker.setTitle("Select date");
|
||||||
|
mDatePicker.show(); }
|
||||||
|
});
|
||||||
|
|
||||||
|
ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_dropdown_item, spinnerList);
|
||||||
|
typeSpinner.setAdapter(adapter);
|
||||||
|
if(selection != null && selection.contains(" AND " + ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TYPE + " IS ?")) {
|
||||||
|
int spinnerPosition = adapter.getPosition(args[args.length-1]);
|
||||||
|
typeSpinner.setSelection(spinnerPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
Button submit = (Button) rootView.findViewById(R.id.submitFiltered);
|
||||||
|
|
||||||
|
submit.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
|
||||||
|
BuildQuery();
|
||||||
|
args = listArgs.toArray(new String[0]);
|
||||||
|
FragmentMain.NEW_LOADER = 1;
|
||||||
|
MainActivity.fragmentManager.popBackStack();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BuildQuery() {
|
||||||
|
|
||||||
|
String dateQuery = ShiftsContract.ShiftsEntry.COLUMN_SHIFT_DATE + " BETWEEN ? AND ?";
|
||||||
|
String descQuery = " AND " + ShiftsContract.ShiftsEntry.COLUMN_SHIFT_DESCRIPTION + " LIKE ?";
|
||||||
|
String typeQuery = " AND " + ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TYPE + " IS ?";
|
||||||
|
|
||||||
|
String dateFrom = "2000-01-01";
|
||||||
|
|
||||||
|
Date c = Calendar.getInstance().getTime();
|
||||||
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
String dateTo = df.format(c);
|
||||||
|
|
||||||
|
if(!TextUtils.isEmpty(dateFromET.getText().toString().trim())){
|
||||||
|
dateFrom = dateFromET.getText().toString().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!TextUtils.isEmpty(dateToET.getText().toString().trim())){
|
||||||
|
dateTo = dateToET.getText().toString().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
selection = dateQuery;
|
||||||
|
listArgs.add(dateFrom);
|
||||||
|
listArgs.add(dateTo);
|
||||||
|
|
||||||
|
if (!TextUtils.isEmpty(LocationET.getText().toString().trim())){
|
||||||
|
selection = selection + descQuery;
|
||||||
|
listArgs.add("%" + LocationET.getText().toString().trim() + "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!typeSpinner.getSelectedItem().toString().equals("")){
|
||||||
|
selection = selection + typeQuery;
|
||||||
|
listArgs.add(typeSpinner.getSelectedItem().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,622 @@
|
|||||||
|
package com.example.h_mal.shift_tracker;
|
||||||
|
|
||||||
|
import android.app.DatePickerDialog;
|
||||||
|
import android.app.TimePickerDialog;
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.LoaderManager;
|
||||||
|
import android.support.v4.content.Loader;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.text.TextWatcher;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.DatePicker;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.RadioButton;
|
||||||
|
import android.widget.RadioGroup;
|
||||||
|
import android.widget.ScrollView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.TimePicker;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.example.h_mal.shift_tracker.Data.ShiftsContract;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
public class FragmentAddItem extends Fragment implements
|
||||||
|
LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
|
|
||||||
|
private static final int EXISTING_PRODUCT_LOADER = 0;
|
||||||
|
|
||||||
|
private Uri mCurrentProductUri;
|
||||||
|
|
||||||
|
public static RadioGroup mRadioGroup;
|
||||||
|
private RadioButton mRadioButtonOne;
|
||||||
|
private RadioButton mRadioButtonTwo;
|
||||||
|
private EditText mLocationEditText;
|
||||||
|
private EditText mDateEditText;
|
||||||
|
private TextView mDurationTextView;
|
||||||
|
private EditText mTimeInEditText;
|
||||||
|
private EditText mTimeOutEditText;
|
||||||
|
private EditText mBreakEditText;
|
||||||
|
private EditText mUnitEditText;
|
||||||
|
private EditText mPayRateEditText;
|
||||||
|
private TextView mTotalPayTextView;
|
||||||
|
private LinearLayout hourlyDataView;
|
||||||
|
private LinearLayout unitsHolder;
|
||||||
|
private LinearLayout durationHolder;
|
||||||
|
private LinearLayout wholeView;
|
||||||
|
private ScrollView scrollView;
|
||||||
|
private ProgressBar progressBarAI;
|
||||||
|
private int mBreaks;
|
||||||
|
|
||||||
|
private int mDay;
|
||||||
|
private int mMonth;
|
||||||
|
private int mYear;
|
||||||
|
private int mHoursIn;
|
||||||
|
private int mMinutesIn;
|
||||||
|
private int mHoursOut;
|
||||||
|
private int mMinutesOut;
|
||||||
|
private float mUnits;
|
||||||
|
private float mPayRate;
|
||||||
|
private String mType;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
View rootView = inflater.inflate(R.layout.fragment_add_item, container, false);
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
|
progressBarAI = (ProgressBar) rootView.findViewById(R.id.pd_ai);
|
||||||
|
scrollView = (ScrollView) rootView.findViewById(R.id.total_view);
|
||||||
|
mRadioGroup = (RadioGroup) rootView.findViewById(R.id.rg);
|
||||||
|
mRadioButtonOne = (RadioButton) rootView.findViewById(R.id.hourly);
|
||||||
|
mRadioButtonTwo = (RadioButton) rootView.findViewById(R.id.piecerate);
|
||||||
|
mLocationEditText = (EditText) rootView.findViewById(R.id.locationEditText);
|
||||||
|
mDateEditText = (EditText) rootView.findViewById(R.id.dateEditText);
|
||||||
|
mTimeInEditText = (EditText) rootView.findViewById(R.id.timeInEditText);
|
||||||
|
mBreakEditText = (EditText) rootView.findViewById(R.id.breakEditText);
|
||||||
|
mTimeOutEditText = (EditText) rootView.findViewById(R.id.timeOutEditText);
|
||||||
|
mDurationTextView = (TextView) rootView.findViewById(R.id.ShiftDuration);
|
||||||
|
mUnitEditText = (EditText) rootView.findViewById(R.id.unitET);
|
||||||
|
mPayRateEditText = (EditText) rootView.findViewById(R.id.payrateET);
|
||||||
|
mTotalPayTextView = (TextView) rootView.findViewById(R.id.totalpayval);
|
||||||
|
|
||||||
|
hourlyDataView = (LinearLayout) rootView.findViewById(R.id.hourly_data_holder);
|
||||||
|
unitsHolder = (LinearLayout) rootView.findViewById(R.id.units_holder);
|
||||||
|
durationHolder = (LinearLayout) rootView.findViewById(R.id.duration_holder);
|
||||||
|
wholeView = (LinearLayout) rootView.findViewById(R.id.whole_view);
|
||||||
|
|
||||||
|
mPayRate = 0.0f;
|
||||||
|
mUnits = 0.0f;
|
||||||
|
|
||||||
|
final Bundle b = getArguments();
|
||||||
|
if(b != null) {
|
||||||
|
mCurrentProductUri = Uri.parse(b.getString("uri"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mCurrentProductUri == null) {
|
||||||
|
MainActivity.setActionBarTitle(getString(R.string.add_item_title));
|
||||||
|
wholeView.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
MainActivity.setActionBarTitle(getString(R.string.edit_item_title));
|
||||||
|
getLoaderManager().initLoader(EXISTING_PRODUCT_LOADER, null, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
mBreakEditText.setHint("insert break in minutes");
|
||||||
|
|
||||||
|
mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(RadioGroup radioGroup, int i) {
|
||||||
|
if (mRadioButtonOne.isChecked()){
|
||||||
|
mType = mRadioButtonOne.getText().toString();
|
||||||
|
wholeView.setVisibility(View.VISIBLE);
|
||||||
|
unitsHolder.setVisibility(View.GONE);
|
||||||
|
hourlyDataView.setVisibility(View.VISIBLE);
|
||||||
|
durationHolder.setVisibility(View.VISIBLE);
|
||||||
|
}else if(mRadioButtonTwo.isChecked()){
|
||||||
|
mType = mRadioButtonTwo.getText().toString();
|
||||||
|
wholeView.setVisibility(View.VISIBLE);
|
||||||
|
unitsHolder.setVisibility(View.VISIBLE);
|
||||||
|
hourlyDataView.setVisibility(View.GONE);
|
||||||
|
durationHolder.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mDateEditText.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
//To show current date in the datepicker
|
||||||
|
if(TextUtils.isEmpty(mDateEditText.getText().toString().trim())) {
|
||||||
|
Calendar mcurrentDate = Calendar.getInstance();
|
||||||
|
mYear = mcurrentDate.get(Calendar.YEAR);
|
||||||
|
mMonth = mcurrentDate.get(Calendar.MONTH);
|
||||||
|
mDay = mcurrentDate.get(Calendar.DAY_OF_MONTH);
|
||||||
|
}else{
|
||||||
|
String dateString = mDateEditText.getText().toString().trim();
|
||||||
|
|
||||||
|
mYear = Integer.parseInt(dateString.substring(0, 4));
|
||||||
|
mMonth = Integer.parseInt(dateString.substring(5, 7));
|
||||||
|
if (mMonth == 1){
|
||||||
|
mMonth = 0;
|
||||||
|
}else{
|
||||||
|
mMonth = mMonth -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
mDay = Integer.parseInt(dateString.substring(8));
|
||||||
|
}
|
||||||
|
DatePickerDialog mDatePicker=new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {
|
||||||
|
public void onDateSet(DatePicker datepicker, int selectedyear, int selectedmonth, int selectedday) {
|
||||||
|
mDateEditText.setText(
|
||||||
|
selectedyear + "-"
|
||||||
|
+ String.format("%02d", (selectedmonth = selectedmonth + 1)) +"-"
|
||||||
|
+ String.format("%02d", selectedday)
|
||||||
|
);
|
||||||
|
setDate(selectedyear, selectedmonth, selectedday);
|
||||||
|
}
|
||||||
|
},mYear, mMonth, mDay);
|
||||||
|
mDatePicker.setTitle("Select date");
|
||||||
|
mDatePicker.show(); }
|
||||||
|
});
|
||||||
|
|
||||||
|
mTimeInEditText.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (mTimeInEditText.getText().toString().equals("")) {
|
||||||
|
Calendar mcurrentTime = Calendar.getInstance();
|
||||||
|
mHoursIn = mcurrentTime.get(Calendar.HOUR_OF_DAY);
|
||||||
|
mMinutesIn = mcurrentTime.get(Calendar.MINUTE);
|
||||||
|
} else {
|
||||||
|
mHoursIn = Integer.parseInt((mTimeInEditText.getText().toString().subSequence(0,2)).toString());
|
||||||
|
mMinutesIn = Integer.parseInt((mTimeInEditText.getText().toString().subSequence(3,5)).toString());
|
||||||
|
}
|
||||||
|
TimePickerDialog mTimePicker;
|
||||||
|
mTimePicker = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {
|
||||||
|
@Override
|
||||||
|
public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
|
||||||
|
String ddTime = String.format("%02d", selectedHour) + ":" + String.format("%02d", selectedMinute);
|
||||||
|
setTime(selectedMinute, selectedHour);
|
||||||
|
mTimeInEditText.setText(ddTime);
|
||||||
|
}
|
||||||
|
}, mHoursIn, mMinutesIn, true);//Yes 24 hour time
|
||||||
|
mTimePicker.setTitle("Select Time");
|
||||||
|
mTimePicker.show();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mTimeOutEditText.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (mTimeOutEditText.getText().toString().equals("")) {
|
||||||
|
Calendar mcurrentTime = Calendar.getInstance();
|
||||||
|
mHoursOut = mcurrentTime.get(Calendar.HOUR_OF_DAY);
|
||||||
|
mMinutesOut = mcurrentTime.get(Calendar.MINUTE);
|
||||||
|
}else {
|
||||||
|
mHoursOut = Integer.parseInt((mTimeOutEditText.getText().toString().subSequence(0,2)).toString());
|
||||||
|
mMinutesOut = Integer.parseInt((mTimeOutEditText.getText().toString().subSequence(3,5)).toString());
|
||||||
|
}
|
||||||
|
TimePickerDialog mTimePicker;
|
||||||
|
mTimePicker = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {
|
||||||
|
@Override
|
||||||
|
public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
|
||||||
|
String ddTime = String.format("%02d", selectedHour) + ":" + String.format("%02d", selectedMinute);
|
||||||
|
setTime2(selectedMinute,selectedHour);
|
||||||
|
mTimeOutEditText.setText(ddTime);
|
||||||
|
}
|
||||||
|
}, mHoursOut, mMinutesOut, true);//Yes 24 hour time
|
||||||
|
mTimePicker.setTitle("Select Time");
|
||||||
|
mTimePicker.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mTimeInEditText.addTextChangedListener(new TextWatcher()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before, int count)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count, int aft )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s)
|
||||||
|
{
|
||||||
|
setDuration();
|
||||||
|
calculateTotalPay();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mTimeOutEditText.addTextChangedListener(new TextWatcher()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before, int count)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count, int aft )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s)
|
||||||
|
{
|
||||||
|
setDuration();
|
||||||
|
calculateTotalPay();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mBreakEditText.addTextChangedListener(new TextWatcher()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before, int count)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count, int aft )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s)
|
||||||
|
{
|
||||||
|
setDuration();
|
||||||
|
calculateTotalPay();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mUnitEditText.addTextChangedListener(new TextWatcher() {
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable editable) {
|
||||||
|
// if(mRadioButtonTwo.isChecked()) {
|
||||||
|
// mUnits = 0.0f;
|
||||||
|
// if (!mUnitEditText.getText().toString().equals("")){
|
||||||
|
// mUnits = Float.parseFloat(mUnitEditText.getText().toString());
|
||||||
|
// }
|
||||||
|
// mPayRate = 0.0f;
|
||||||
|
// if (!mPayRateEditText.getText().toString().equals("")){
|
||||||
|
// mPayRate = Float.parseFloat(mPayRateEditText.getText().toString());
|
||||||
|
// }
|
||||||
|
// Float total = mPayRate * mUnits;
|
||||||
|
// mTotalPayTextView.setText(String.valueOf(total));
|
||||||
|
// }
|
||||||
|
calculateTotalPay();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mPayRateEditText.addTextChangedListener(new TextWatcher() {
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable editable) {
|
||||||
|
calculateTotalPay();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
Button SubmitProduct = (Button) rootView.findViewById(R.id.submit);
|
||||||
|
|
||||||
|
SubmitProduct.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
saveProduct();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void calculateTotalPay(){
|
||||||
|
Float total = 0.0f;
|
||||||
|
mPayRate = 0.0f;
|
||||||
|
if(mRadioButtonTwo.isChecked()) {
|
||||||
|
mUnits = 0.0f;
|
||||||
|
if (!mUnitEditText.getText().toString().equals("")) {
|
||||||
|
mUnits = Float.parseFloat(mUnitEditText.getText().toString());
|
||||||
|
}
|
||||||
|
if (!mPayRateEditText.getText().toString().equals("")) {
|
||||||
|
mPayRate = Float.parseFloat(mPayRateEditText.getText().toString());
|
||||||
|
}
|
||||||
|
total = mPayRate * mUnits;
|
||||||
|
mTotalPayTextView.setText(String.valueOf(total));
|
||||||
|
} else if(mRadioButtonOne.isChecked()){
|
||||||
|
if (!mPayRateEditText.getText().toString().equals("")){
|
||||||
|
mPayRate = Float.parseFloat(mPayRateEditText.getText().toString());
|
||||||
|
total = mPayRate * calculateDuration(mHoursIn,mMinutesIn,mHoursOut,mMinutesOut,mBreaks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mTotalPayTextView.setText(String.format("%.2f",total));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
menu.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveProduct() {
|
||||||
|
|
||||||
|
String typeString = mType;
|
||||||
|
String descriptionString = mLocationEditText.getText().toString().trim();
|
||||||
|
if (TextUtils.isEmpty(descriptionString)) {
|
||||||
|
Toast.makeText(getContext(), "please insert Location", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String dateString = mDateEditText.getText().toString().trim();
|
||||||
|
if (TextUtils.isEmpty(dateString)) {
|
||||||
|
Toast.makeText(getContext(), "please insert Date", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String timeInString = "";
|
||||||
|
String timeOutString = "";
|
||||||
|
int breaks = 0;
|
||||||
|
float units = 0;
|
||||||
|
float duration = 0;
|
||||||
|
float payRate = 0;
|
||||||
|
String payRateString = mPayRateEditText.getText().toString().trim();
|
||||||
|
if (!TextUtils.isEmpty(payRateString)) {
|
||||||
|
payRate = Float.parseFloat(payRateString);
|
||||||
|
}
|
||||||
|
float totalPay = 0;
|
||||||
|
if (typeString.equals("Hourly")) {
|
||||||
|
timeInString = mTimeInEditText.getText().toString().trim();
|
||||||
|
if (TextUtils.isEmpty(timeInString)) {
|
||||||
|
Toast.makeText(getContext(), "please insert Time in", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
timeOutString = mTimeOutEditText.getText().toString().trim();
|
||||||
|
if (TextUtils.isEmpty(timeOutString)) {
|
||||||
|
Toast.makeText(getContext(), "please insert Time out", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String breakMins = mBreakEditText.getText().toString().trim();
|
||||||
|
if (!TextUtils.isEmpty(breakMins)) {
|
||||||
|
breaks = Integer.parseInt(breakMins);
|
||||||
|
if(((float)breaks / 60) > calculateDurationWithoutBreak(mHoursIn, mMinutesIn, mHoursOut, mMinutesOut)){
|
||||||
|
Toast.makeText(getContext(), "Break larger than duration", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
duration = calculateDuration(mHoursIn, mMinutesIn, mHoursOut, mMinutesOut, breaks);
|
||||||
|
totalPay = duration * payRate;
|
||||||
|
}else if(typeString.equals("Piece Rate")){
|
||||||
|
String unitsString = mUnitEditText.getText().toString().trim();
|
||||||
|
if (TextUtils.isEmpty(unitsString) || Float.parseFloat(unitsString) <= 0) {
|
||||||
|
Toast.makeText(getContext(), "Insert Units", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}else{
|
||||||
|
units = Float.parseFloat(unitsString);
|
||||||
|
}
|
||||||
|
duration = 0;
|
||||||
|
totalPay = units * payRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TYPE, typeString);
|
||||||
|
values.put(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_DESCRIPTION, descriptionString);
|
||||||
|
values.put(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_DATE, dateString);
|
||||||
|
values.put(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TIME_IN, timeInString);
|
||||||
|
values.put(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TIME_OUT, timeOutString);
|
||||||
|
values.put(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_DURATION, duration);
|
||||||
|
values.put(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_BREAK, breaks);
|
||||||
|
values.put(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_UNIT, units);
|
||||||
|
values.put(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_PAYRATE, payRate);
|
||||||
|
values.put(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TOTALPAY, totalPay);
|
||||||
|
|
||||||
|
if (mCurrentProductUri == null) {
|
||||||
|
|
||||||
|
Uri newUri = getActivity().getContentResolver().insert(ShiftsContract.ShiftsEntry.CONTENT_URI, values);
|
||||||
|
|
||||||
|
if (newUri == null) {
|
||||||
|
Toast.makeText(getContext(), getString(R.string.insert_item_failed),
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
Toast.makeText(getContext(), getString(R.string.insert_item_successful),
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int rowsAffected = getActivity().getContentResolver().update(mCurrentProductUri, values, null, null);
|
||||||
|
|
||||||
|
if (rowsAffected == 0) {
|
||||||
|
Toast.makeText(getContext(), getString(R.string.update_item_failed),
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(getContext(), getString(R.string.update_item_successful),
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(MainActivity.fragmentManager).popBackStack("main",0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setDuration (){
|
||||||
|
Calendar mcurrentTime = Calendar.getInstance();
|
||||||
|
mBreaks = 0;
|
||||||
|
if (!mBreakEditText.getText().toString().equals("")){
|
||||||
|
mBreaks = Integer.parseInt(mBreakEditText.getText().toString());
|
||||||
|
}
|
||||||
|
if (mTimeOutEditText.getText().toString().equals("")) {
|
||||||
|
mHoursOut = mcurrentTime.get(Calendar.HOUR_OF_DAY);
|
||||||
|
mMinutesOut = mcurrentTime.get(Calendar.MINUTE);
|
||||||
|
}else {
|
||||||
|
mHoursOut = Integer.parseInt((mTimeOutEditText.getText().toString().subSequence(0,2)).toString());
|
||||||
|
mMinutesOut = Integer.parseInt((mTimeOutEditText.getText().toString().subSequence(3,5)).toString());
|
||||||
|
}
|
||||||
|
if (mTimeInEditText.getText().toString().equals("")) {
|
||||||
|
mHoursIn = mcurrentTime.get(Calendar.HOUR_OF_DAY);
|
||||||
|
mMinutesIn = mcurrentTime.get(Calendar.MINUTE);
|
||||||
|
} else {
|
||||||
|
mHoursIn = Integer.parseInt((mTimeInEditText.getText().toString().subSequence(0,2)).toString());
|
||||||
|
mMinutesIn = Integer.parseInt((mTimeInEditText.getText().toString().subSequence(3,5)).toString());
|
||||||
|
}
|
||||||
|
mDurationTextView.setText(calculateDuration(mHoursIn,mMinutesIn,mHoursOut,mMinutesOut,mBreaks) + " hours");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setDate (int year, int month, int day){
|
||||||
|
mYear = year;
|
||||||
|
mMonth = month;
|
||||||
|
mDay = day;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void setTime (int minutes, int hours){
|
||||||
|
mMinutesIn = minutes;
|
||||||
|
mHoursIn = hours;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setTime2 (int minutes, int hours){
|
||||||
|
mMinutesOut = minutes;
|
||||||
|
mHoursOut = hours;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private float calculateDuration (int hoursIn, int minutesIn, int hoursOut, int minutesOut, int breaks){
|
||||||
|
float duration;
|
||||||
|
if (hoursOut > hoursIn){
|
||||||
|
duration = (((float)hoursOut + ((float)minutesOut/60)) - ((float) hoursIn + ((float)minutesIn/60))) - ((float)breaks / 60);
|
||||||
|
}else{
|
||||||
|
duration = ((((float)hoursOut + ((float)minutesOut/60)) - ((float)hoursIn + ((float)minutesIn/60))) - ((float)breaks / 60) + 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
String s = String.format("%.2f",duration);
|
||||||
|
return Float.parseFloat(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
private float calculateDurationWithoutBreak (int hoursIn, int minutesIn, int hoursOut, int minutesOut){
|
||||||
|
float duration;
|
||||||
|
if (hoursOut > hoursIn){
|
||||||
|
duration = (((float)hoursOut + ((float)minutesOut/60)) - ((float) hoursIn + ((float)minutesIn/60)));
|
||||||
|
}else{
|
||||||
|
duration = ((((float)hoursOut + ((float)minutesOut/60)) - ((float)hoursIn + ((float)minutesIn/60))) + 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
String s = String.format("%.2f",duration);
|
||||||
|
return Float.parseFloat(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
|
progressBarAI.setVisibility(View.VISIBLE);
|
||||||
|
scrollView.setVisibility(View.GONE);
|
||||||
|
String[] projection = {
|
||||||
|
ShiftsContract.ShiftsEntry._ID,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_DESCRIPTION,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_DATE,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TIME_IN,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TIME_OUT,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_BREAK,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_DURATION,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TYPE,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_PAYRATE,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_UNIT,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TOTALPAY,};
|
||||||
|
|
||||||
|
return new android.support.v4.content.CursorLoader(getContext(),mCurrentProductUri,
|
||||||
|
projection,null,null,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
|
||||||
|
progressBarAI.setVisibility(View.GONE);
|
||||||
|
scrollView.setVisibility(View.VISIBLE);
|
||||||
|
if (cursor == null || cursor.getCount() < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cursor.moveToFirst()) {
|
||||||
|
int descriptionColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_DESCRIPTION);
|
||||||
|
int dateColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_DATE);
|
||||||
|
int timeInColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TIME_IN);
|
||||||
|
int timeOutColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TIME_OUT);
|
||||||
|
int breakColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_BREAK);
|
||||||
|
int durationColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_DURATION);
|
||||||
|
int typeColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TYPE);
|
||||||
|
int unitColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_UNIT);
|
||||||
|
int payrateColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_PAYRATE);
|
||||||
|
int totalPayColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TOTALPAY);
|
||||||
|
|
||||||
|
String type = cursor.getString(typeColumnIndex);
|
||||||
|
String description = cursor.getString(descriptionColumnIndex);
|
||||||
|
String date = cursor.getString(dateColumnIndex);
|
||||||
|
String timeIn = cursor.getString(timeInColumnIndex);
|
||||||
|
String timeOut = cursor.getString(timeOutColumnIndex);
|
||||||
|
int breaks = cursor.getInt(breakColumnIndex);
|
||||||
|
float duration = cursor.getFloat(durationColumnIndex);
|
||||||
|
float unit = cursor.getFloat(unitColumnIndex);
|
||||||
|
float payrate = cursor.getFloat(payrateColumnIndex);
|
||||||
|
float totalPay = cursor.getFloat(totalPayColumnIndex);
|
||||||
|
|
||||||
|
mLocationEditText.setText(description);
|
||||||
|
mDateEditText.setText(date);
|
||||||
|
if (type.equals("Hourly") || type.equals("hourly")) {
|
||||||
|
mRadioButtonOne.setChecked(true);
|
||||||
|
mRadioButtonTwo.setChecked(false);
|
||||||
|
mTimeInEditText.setText(timeIn);
|
||||||
|
mTimeOutEditText.setText(timeOut);
|
||||||
|
mBreakEditText.setText(Integer.toString(breaks));
|
||||||
|
mDurationTextView.setText(String.format("%.2f", duration) + " Hours");
|
||||||
|
} else if (type.equals("Piece Rate")) {
|
||||||
|
mRadioButtonOne.setChecked(false);
|
||||||
|
mRadioButtonTwo.setChecked(true);
|
||||||
|
mUnitEditText.setText(Float.toString(unit));
|
||||||
|
}
|
||||||
|
mPayRateEditText.setText(String.format("%.2f", payrate));
|
||||||
|
mTotalPayTextView.setText(String.format("%.2f", totalPay));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoaderReset(Loader<Cursor> loader) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,529 @@
|
|||||||
|
package com.example.h_mal.shift_tracker;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.os.StrictMode;
|
||||||
|
import android.support.design.widget.FloatingActionButton;
|
||||||
|
import android.support.v4.app.ActivityCompat;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
import android.support.v4.app.LoaderManager;
|
||||||
|
import android.support.v4.content.Loader;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.ajts.androidmads.library.SQLiteToExcel;
|
||||||
|
import com.example.h_mal.shift_tracker.Data.ShiftsContract.ShiftsEntry;
|
||||||
|
import com.example.h_mal.shift_tracker.Data.ShiftsDbHelper;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import static com.example.h_mal.shift_tracker.MainActivity.args;
|
||||||
|
import static com.example.h_mal.shift_tracker.MainActivity.filter;
|
||||||
|
import static com.example.h_mal.shift_tracker.MainActivity.selection;
|
||||||
|
import static com.example.h_mal.shift_tracker.MainActivity.sortOrder;
|
||||||
|
|
||||||
|
|
||||||
|
public class FragmentMain extends Fragment implements
|
||||||
|
LoaderManager.LoaderCallbacks<Cursor>{
|
||||||
|
|
||||||
|
public static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 1;
|
||||||
|
|
||||||
|
private static final int DEFAULT_LOADER = 0;
|
||||||
|
public static int NEW_LOADER = 0;
|
||||||
|
|
||||||
|
ShiftsCursorAdapter mCursorAdapter;
|
||||||
|
ShiftsDbHelper shiftsDbhelper;
|
||||||
|
LoaderManager.LoaderCallbacks defaultLoaderCallback;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
|
MainActivity.setActionBarTitle(getString(R.string.app_name));
|
||||||
|
|
||||||
|
filter = getActivity().getSharedPreferences("PREFS", 0);
|
||||||
|
sortOrder = filter.getString("Filter",null);
|
||||||
|
|
||||||
|
defaultLoaderCallback = this;
|
||||||
|
|
||||||
|
ListView productListView = (ListView) rootView.findViewById(R.id.list_item_view);
|
||||||
|
|
||||||
|
View emptyView = rootView.findViewById(R.id.empty_view);
|
||||||
|
productListView.setEmptyView(emptyView);
|
||||||
|
|
||||||
|
mCursorAdapter = new ShiftsCursorAdapter((MainActivity) getActivity(), null);
|
||||||
|
productListView.setAdapter(mCursorAdapter);
|
||||||
|
|
||||||
|
getLoaderManager().initLoader(DEFAULT_LOADER, null, defaultLoaderCallback);
|
||||||
|
|
||||||
|
FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab1);
|
||||||
|
fab.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
FragmentTransaction fragmentTransaction = (MainActivity.fragmentManager).beginTransaction();
|
||||||
|
fragmentTransaction.replace(R.id.container,new FragmentAddItem()).addToBackStack("additem").commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
|
||||||
|
case R.id.delete_all:
|
||||||
|
deleteAllProducts();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case R.id.help:
|
||||||
|
new AlertDialog.Builder(getContext())
|
||||||
|
.setTitle("Help & Support:")
|
||||||
|
.setView(R.layout.dialog_layout)
|
||||||
|
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface arg0, int arg1) {
|
||||||
|
}
|
||||||
|
}).create().show();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case R.id.filter_data:
|
||||||
|
FragmentTransaction fragmentTransaction = (MainActivity.fragmentManager).beginTransaction();
|
||||||
|
fragmentTransaction.replace(R.id.container,new FilterDataFragment()).addToBackStack("filterdata").commit();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case R.id.sort_data:
|
||||||
|
sortData();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case R.id.clear_filter:
|
||||||
|
args = null;
|
||||||
|
selection = null;
|
||||||
|
NEW_LOADER = 0;
|
||||||
|
getLoaderManager().restartLoader(DEFAULT_LOADER, null, this);
|
||||||
|
return true;
|
||||||
|
case R.id.export_data:
|
||||||
|
if(checkStoragePermissions(getActivity())){
|
||||||
|
new AlertDialog.Builder(getContext())
|
||||||
|
.setTitle("Export?")
|
||||||
|
.setMessage("Exporting current filtered data. Continue?")
|
||||||
|
.setNegativeButton(android.R.string.no, null)
|
||||||
|
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface arg0, int arg1) {
|
||||||
|
ExportData();
|
||||||
|
}
|
||||||
|
}).create().show();
|
||||||
|
}else{
|
||||||
|
Toast.makeText(getContext(), "Storage permissions required", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case R.id.action_favorite:
|
||||||
|
new AlertDialog.Builder(getContext())
|
||||||
|
.setTitle("Info:")
|
||||||
|
.setMessage(retrieveInfo())
|
||||||
|
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface arg0, int arg1) {
|
||||||
|
}
|
||||||
|
}).create().show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sortData(){
|
||||||
|
final String[] grpname = {"Added","Date","Name"};
|
||||||
|
final String[] sortQuery = {""};
|
||||||
|
int checkedItem = -1;
|
||||||
|
|
||||||
|
if(sortOrder != null && sortOrder.contains(ShiftsEntry._ID)){
|
||||||
|
checkedItem = 0;
|
||||||
|
sortQuery[0] = ShiftsEntry._ID;
|
||||||
|
}else if(sortOrder != null && sortOrder.contains(ShiftsEntry.COLUMN_SHIFT_DATE)){
|
||||||
|
checkedItem = 1;
|
||||||
|
sortQuery[0] = ShiftsEntry.COLUMN_SHIFT_DATE;
|
||||||
|
}else if(sortOrder != null && sortOrder.contains(ShiftsEntry.COLUMN_SHIFT_DESCRIPTION)){
|
||||||
|
checkedItem = 2;
|
||||||
|
sortQuery[0] = ShiftsEntry.COLUMN_SHIFT_DESCRIPTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
AlertDialog.Builder alt_bld = new AlertDialog.Builder(getContext());
|
||||||
|
//alt_bld.setIcon(R.drawable.icon);
|
||||||
|
alt_bld.setTitle("Sort by:");
|
||||||
|
alt_bld.setSingleChoiceItems(grpname, checkedItem, new DialogInterface
|
||||||
|
.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
|
|
||||||
|
switch (item) {
|
||||||
|
case 0:
|
||||||
|
sortQuery[0] = ShiftsEntry._ID;
|
||||||
|
return;
|
||||||
|
case 1:
|
||||||
|
sortQuery[0] = ShiftsEntry.COLUMN_SHIFT_DATE;
|
||||||
|
return;
|
||||||
|
case 2:
|
||||||
|
sortQuery[0] = ShiftsEntry.COLUMN_SHIFT_DESCRIPTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}).setPositiveButton("Ascending", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
sortOrder = sortQuery[0] + " ASC";
|
||||||
|
filter.edit().putString("Filter",sortOrder).apply();
|
||||||
|
getLoaderManager().restartLoader(DEFAULT_LOADER, null, defaultLoaderCallback);
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
}).setNegativeButton("Descending", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
sortOrder = sortQuery[0] + " DESC";
|
||||||
|
filter.edit().putString("Filter",sortOrder).apply();
|
||||||
|
getLoaderManager().restartLoader(DEFAULT_LOADER, null, defaultLoaderCallback);
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AlertDialog alert = alt_bld.create();
|
||||||
|
alert.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteAllProducts() {
|
||||||
|
new AlertDialog.Builder(getContext())
|
||||||
|
.setTitle("Delete?")
|
||||||
|
.setMessage("Are you sure you want to delete all date?")
|
||||||
|
.setNegativeButton(android.R.string.no, null)
|
||||||
|
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
|
public void onClick(DialogInterface arg0, int arg1) {
|
||||||
|
int rowsDeleted = getActivity().getContentResolver().delete(ShiftsEntry.CONTENT_URI, null, null);
|
||||||
|
Toast.makeText(getContext(), rowsDeleted + " Items Deleted", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}).create().show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
if(NEW_LOADER > DEFAULT_LOADER) {
|
||||||
|
getLoaderManager().restartLoader(DEFAULT_LOADER, null, defaultLoaderCallback);
|
||||||
|
System.out.println("reloading loader");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExportData() {
|
||||||
|
|
||||||
|
int permission = ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||||
|
|
||||||
|
if (permission != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
Toast.makeText(getContext(), "Storage permissions not granted", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
shiftsDbhelper = new ShiftsDbHelper(getContext());
|
||||||
|
SQLiteDatabase database = shiftsDbhelper.getWritableDatabase();
|
||||||
|
|
||||||
|
String[] projection_export = {
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_DESCRIPTION,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_DATE,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_TIME_IN,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_TIME_OUT,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_BREAK,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_DURATION,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_TYPE,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_UNIT,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_PAYRATE,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_TOTALPAY};
|
||||||
|
Cursor cursor = getActivity().getContentResolver().query(
|
||||||
|
ShiftsEntry.CONTENT_URI,
|
||||||
|
projection_export,
|
||||||
|
selection,
|
||||||
|
args,
|
||||||
|
sortOrder);
|
||||||
|
|
||||||
|
database.delete(ShiftsEntry.TABLE_NAME_EXPORT,null,null);
|
||||||
|
|
||||||
|
float totalDuration = 0.00f;
|
||||||
|
float totalUnits = 0.00f;
|
||||||
|
float totalPay= 0.00f;
|
||||||
|
|
||||||
|
try {
|
||||||
|
while (cursor.moveToNext()) {
|
||||||
|
final String descriptionColumnIndex = cursor.getString(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_DESCRIPTION));
|
||||||
|
final String dateColumnIndex = cursor.getString(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_DATE));
|
||||||
|
final String timeInColumnIndex = cursor.getString(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_TIME_IN));
|
||||||
|
final String timeOutColumnIndex = cursor.getString(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_TIME_OUT));
|
||||||
|
final Float durationColumnIndex = cursor.getFloat(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_DURATION));
|
||||||
|
final Integer breakOutColumnIndex = cursor.getInt(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_BREAK));
|
||||||
|
final String typeColumnIndex = cursor.getString(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_TYPE));
|
||||||
|
final Float unitColumnIndex = cursor.getFloat(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_UNIT));
|
||||||
|
final Float payrateColumnIndex = cursor.getFloat(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_PAYRATE));
|
||||||
|
final Float totalpayColumnIndex = cursor.getFloat(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_TOTALPAY));
|
||||||
|
|
||||||
|
totalUnits = totalUnits + unitColumnIndex;
|
||||||
|
totalDuration = totalDuration + durationColumnIndex;
|
||||||
|
totalPay = totalPay + totalpayColumnIndex;
|
||||||
|
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_DESCRIPTION, descriptionColumnIndex);
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_DATE, dateColumnIndex);
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_TIME_IN, timeInColumnIndex);
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_TIME_OUT, timeOutColumnIndex);
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_BREAK, breakOutColumnIndex);
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_DURATION, durationColumnIndex);
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_TYPE, typeColumnIndex);
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_UNIT, unitColumnIndex);
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_PAYRATE, payrateColumnIndex);
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_TOTALPAY, totalpayColumnIndex);
|
||||||
|
|
||||||
|
database.insert(ShiftsEntry.TABLE_NAME_EXPORT, null, values);
|
||||||
|
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_DESCRIPTION, "");
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_DATE, "");
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_TIME_IN, "");
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_TIME_OUT, "");
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_BREAK, "Total duration:");
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_DURATION, totalDuration);
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_TYPE, "Total units:");
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_UNIT, totalUnits);
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_PAYRATE, "Total pay:");
|
||||||
|
values.put(ShiftsEntry.COLUMN_SHIFT_TOTALPAY, totalPay);
|
||||||
|
|
||||||
|
database.insert(ShiftsEntry.TABLE_NAME_EXPORT, null, values);
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
final String savePath = Environment.getExternalStorageDirectory() + "/ShifttrackerTemp";
|
||||||
|
File file = new File(savePath);
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.mkdirs();
|
||||||
|
}
|
||||||
|
SQLiteToExcel sqLiteToExcel = new SQLiteToExcel(getContext(), "shifts.db",savePath);
|
||||||
|
|
||||||
|
sqLiteToExcel.exportSingleTable("shiftsexport","shifthistory.xls", new SQLiteToExcel.ExportListener() {
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onCompleted(String filePath) {
|
||||||
|
Toast.makeText(getContext(), filePath, Toast.LENGTH_SHORT).show();
|
||||||
|
Uri newPath = Uri.parse("file://" + savePath + "/" +"shifthistory.xls");
|
||||||
|
|
||||||
|
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
|
||||||
|
StrictMode.setVmPolicy(builder.build());
|
||||||
|
|
||||||
|
Intent emailintent = new Intent(Intent.ACTION_SEND);
|
||||||
|
|
||||||
|
emailintent.setType("application/vnd.ms-excel");
|
||||||
|
emailintent.putExtra(Intent.EXTRA_SUBJECT, "historic shifts");
|
||||||
|
emailintent.putExtra(Intent.EXTRA_TEXT, "I'm email body.");
|
||||||
|
emailintent.putExtra(Intent.EXTRA_STREAM,newPath);
|
||||||
|
|
||||||
|
startActivity(Intent.createChooser(emailintent, "Send Email"));
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onError(Exception e) {
|
||||||
|
System.out.println("Error msg: " + e);
|
||||||
|
Toast.makeText(getContext(), "Failed to Export data", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private String retrieveInfo(){
|
||||||
|
String[] projection = {
|
||||||
|
ShiftsEntry._ID,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_DESCRIPTION,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_DATE,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_TIME_IN,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_TIME_OUT,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_BREAK,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_DURATION,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_TYPE,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_UNIT,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_PAYRATE,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_TOTALPAY};
|
||||||
|
Cursor cursor = getActivity().getContentResolver().query(
|
||||||
|
ShiftsEntry.CONTENT_URI,
|
||||||
|
projection,
|
||||||
|
selection,
|
||||||
|
args,
|
||||||
|
sortOrder);
|
||||||
|
float totalDuration = 0.0f;
|
||||||
|
int countOfTypeH = 0;
|
||||||
|
int countOfTypeP = 0;
|
||||||
|
float totalUnits = 0;
|
||||||
|
float totalPay = 0;
|
||||||
|
int lines = 0;
|
||||||
|
try {
|
||||||
|
while (cursor.moveToNext()) {
|
||||||
|
final Float durationColumnIndex = cursor.getFloat(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_DURATION));
|
||||||
|
final String typeColumnIndex = cursor.getString(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_TYPE));
|
||||||
|
final Float unitColumnIndex = cursor.getFloat(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_UNIT));
|
||||||
|
final Float totalpayColumnIndex = cursor.getFloat(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_TOTALPAY));
|
||||||
|
|
||||||
|
totalDuration = totalDuration + durationColumnIndex;
|
||||||
|
if (typeColumnIndex.contains("Hourly")){
|
||||||
|
countOfTypeH = countOfTypeH + 1;
|
||||||
|
}else if (typeColumnIndex.contains("Piece")){
|
||||||
|
countOfTypeP = countOfTypeP +1;
|
||||||
|
}
|
||||||
|
totalUnits= totalUnits + unitColumnIndex;
|
||||||
|
totalPay = totalPay + totalpayColumnIndex;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
|
||||||
|
if ((cursor != null) && (cursor.getCount() > 0)) {
|
||||||
|
lines = cursor.getCount();
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return buildInfoString(totalDuration,countOfTypeH,countOfTypeP,totalUnits,totalPay,lines);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String buildInfoString(float totalDuration, int countOfTypeH, int countOfTypeP, float totalUnits, float totalPay, int lines){
|
||||||
|
String textString;
|
||||||
|
textString = lines + " Shifts";
|
||||||
|
if (countOfTypeH != 0 && countOfTypeP != 0){
|
||||||
|
textString = textString + " (" + countOfTypeH + " Hourly" + "/" + countOfTypeP + " Piece Rate)";
|
||||||
|
}
|
||||||
|
if(countOfTypeH != 0){
|
||||||
|
textString = textString
|
||||||
|
+ "\n" + "Total Hours: " + String.format("%.2f",totalDuration);
|
||||||
|
}
|
||||||
|
if(countOfTypeP != 0){
|
||||||
|
textString = textString
|
||||||
|
+ "\n" + "Total Units: " + String.format("%.2f",totalUnits);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalPay != 0){
|
||||||
|
textString = textString
|
||||||
|
+ "\n" + "Total Pay: " + "$" + String.format("%.2f",totalPay);
|
||||||
|
}
|
||||||
|
|
||||||
|
return textString;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
|
||||||
|
String[] projection = {
|
||||||
|
ShiftsEntry._ID,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_DESCRIPTION,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_DATE,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_TIME_IN,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_TIME_OUT,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_BREAK,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_DURATION,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_TYPE,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_PAYRATE,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_UNIT,
|
||||||
|
ShiftsEntry.COLUMN_SHIFT_TOTALPAY,};
|
||||||
|
|
||||||
|
return new android.support.v4.content.CursorLoader(getContext(),
|
||||||
|
ShiftsEntry.CONTENT_URI,
|
||||||
|
projection,
|
||||||
|
selection,
|
||||||
|
args,
|
||||||
|
sortOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
|
||||||
|
mCursorAdapter.swapCursor(cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoaderReset(Loader<Cursor> loader) {
|
||||||
|
mCursorAdapter.swapCursor(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
|
||||||
|
System.out.println("request code" + requestCode);
|
||||||
|
switch (requestCode) {
|
||||||
|
case MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE: {
|
||||||
|
if (grantResults.length > 0
|
||||||
|
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
exportDialog();
|
||||||
|
}else{
|
||||||
|
Toast.makeText(getContext(), "Storage Permissions denied", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void exportDialog(){
|
||||||
|
new AlertDialog.Builder(getContext())
|
||||||
|
.setTitle("Export?")
|
||||||
|
.setMessage("Exporting current filtered data. Continue?")
|
||||||
|
.setNegativeButton(android.R.string.no, null)
|
||||||
|
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface arg0, int arg1) {
|
||||||
|
ExportData();
|
||||||
|
}
|
||||||
|
}).create().show();
|
||||||
|
}
|
||||||
|
// // Storage Permissions
|
||||||
|
// private static final int REQUEST_EXTERNAL_STORAGE = 1;
|
||||||
|
// private static String[] PERMISSIONS_STORAGE = {
|
||||||
|
// Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||||
|
// Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||||
|
// };
|
||||||
|
// /**
|
||||||
|
// * Checks if the app has permission to write to device storage
|
||||||
|
// *
|
||||||
|
// * If the app does not has permission then the user will be prompted to grant permissions
|
||||||
|
// *
|
||||||
|
// * @param activity
|
||||||
|
// */
|
||||||
|
// public static void verifyStoragePermissions(Activity activity) {
|
||||||
|
// // Check if we have write permission
|
||||||
|
// int permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||||
|
//
|
||||||
|
// if (permission != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
// // We don't have permission so prompt the user
|
||||||
|
// ActivityCompat.requestPermissions(
|
||||||
|
// activity,
|
||||||
|
// PERMISSIONS_STORAGE,
|
||||||
|
// REQUEST_EXTERNAL_STORAGE
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
public static boolean checkStoragePermissions(Activity activity){
|
||||||
|
boolean status = false;
|
||||||
|
int permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||||
|
|
||||||
|
if (permission == PackageManager.PERMISSION_GRANTED ){
|
||||||
|
status = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,184 @@
|
|||||||
|
package com.example.h_mal.shift_tracker;
|
||||||
|
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
import android.support.v4.app.LoaderManager;
|
||||||
|
import android.support.v4.content.Loader;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.example.h_mal.shift_tracker.Data.ShiftsContract;
|
||||||
|
|
||||||
|
|
||||||
|
public class FurtherInfoFragment extends Fragment implements
|
||||||
|
LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
|
|
||||||
|
private static final int DEFAULT_LOADER = 0;
|
||||||
|
|
||||||
|
private TextView typeTV;
|
||||||
|
private TextView descriptionTV;
|
||||||
|
private TextView dateTV;
|
||||||
|
private TextView times;
|
||||||
|
private TextView breakTV;
|
||||||
|
private TextView durationTV;
|
||||||
|
private TextView unitsTV;
|
||||||
|
private TextView payRateTV;
|
||||||
|
private TextView totalPayTV;
|
||||||
|
private LinearLayout hourlyDetailHolder;
|
||||||
|
private LinearLayout unitsHolder;
|
||||||
|
private LinearLayout wholeView;
|
||||||
|
private ProgressBar progressBarFI;
|
||||||
|
private Button editButton;
|
||||||
|
|
||||||
|
private Uri CurrentUri;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
View rootView = inflater.inflate(R.layout.fragment_futher_info, container, false);
|
||||||
|
|
||||||
|
MainActivity.setActionBarTitle(getString(R.string.further_info_title));
|
||||||
|
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
|
progressBarFI = (ProgressBar) rootView.findViewById(R.id.progressBar_info);
|
||||||
|
wholeView = (LinearLayout) rootView.findViewById(R.id.further_info_view);
|
||||||
|
typeTV = (TextView)rootView.findViewById(R.id.details_shift);
|
||||||
|
descriptionTV = (TextView)rootView.findViewById(R.id.details_desc);
|
||||||
|
dateTV = (TextView)rootView.findViewById(R.id.details_date);
|
||||||
|
times = (TextView)rootView.findViewById(R.id.details_time);
|
||||||
|
breakTV = (TextView)rootView.findViewById(R.id.details_breaks);
|
||||||
|
durationTV = (TextView)rootView.findViewById(R.id.details_duration);
|
||||||
|
unitsTV = (TextView)rootView.findViewById(R.id.details_units);
|
||||||
|
payRateTV = (TextView)rootView.findViewById(R.id.details_pay_rate);
|
||||||
|
totalPayTV = (TextView)rootView.findViewById(R.id.details_totalpay);
|
||||||
|
editButton = (Button) rootView.findViewById(R.id.details_edit);
|
||||||
|
hourlyDetailHolder = (LinearLayout) rootView.findViewById(R.id.details_hourly_details);
|
||||||
|
unitsHolder = (LinearLayout) rootView.findViewById(R.id.details_units_holder);
|
||||||
|
|
||||||
|
final Bundle b = getArguments();
|
||||||
|
CurrentUri = Uri.parse(b.getString("uri"));
|
||||||
|
|
||||||
|
getLoaderManager().initLoader(DEFAULT_LOADER, null, this);
|
||||||
|
|
||||||
|
editButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
FragmentTransaction fragmentTransaction = (MainActivity.fragmentManager).beginTransaction();
|
||||||
|
Fragment fragment = new FragmentAddItem();
|
||||||
|
fragment.setArguments(b);
|
||||||
|
fragmentTransaction.replace(R.id.container,fragment).addToBackStack("additem").commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
menu.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
|
progressBarFI.setVisibility(View.VISIBLE);
|
||||||
|
wholeView.setVisibility(View.GONE);
|
||||||
|
String[] projection = {
|
||||||
|
ShiftsContract.ShiftsEntry._ID,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_DESCRIPTION,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_DATE,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TIME_IN,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TIME_OUT,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_BREAK,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_DURATION,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TYPE,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_PAYRATE,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_UNIT,
|
||||||
|
ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TOTALPAY,};
|
||||||
|
|
||||||
|
return new android.support.v4.content.CursorLoader(getContext(),CurrentUri,
|
||||||
|
projection,null,null,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadFinished(android.support.v4.content.Loader<Cursor> loader, Cursor cursor) {
|
||||||
|
progressBarFI.setVisibility(View.GONE);
|
||||||
|
wholeView.setVisibility(View.VISIBLE);
|
||||||
|
if (cursor == null || cursor.getCount() < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cursor.moveToFirst()) {
|
||||||
|
int descriptionColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_DESCRIPTION);
|
||||||
|
int dateColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_DATE);
|
||||||
|
int timeInColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TIME_IN);
|
||||||
|
int timeOutColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TIME_OUT);
|
||||||
|
int breakColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_BREAK);
|
||||||
|
int durationColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_DURATION);
|
||||||
|
int typeColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TYPE);
|
||||||
|
int unitColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_UNIT);
|
||||||
|
int payrateColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_PAYRATE);
|
||||||
|
int totalPayColumnIndex = cursor.getColumnIndex(ShiftsContract.ShiftsEntry.COLUMN_SHIFT_TOTALPAY);
|
||||||
|
|
||||||
|
String type = cursor.getString(typeColumnIndex);
|
||||||
|
String description = cursor.getString(descriptionColumnIndex);
|
||||||
|
String date = cursor.getString(dateColumnIndex);
|
||||||
|
String timeIn = cursor.getString(timeInColumnIndex);
|
||||||
|
String timeOut = cursor.getString(timeOutColumnIndex);
|
||||||
|
int breaks = cursor.getInt(breakColumnIndex);
|
||||||
|
float duration = cursor.getFloat(durationColumnIndex);
|
||||||
|
float unit = cursor.getFloat(unitColumnIndex);
|
||||||
|
float payrate = cursor.getFloat(payrateColumnIndex);
|
||||||
|
float totalPay = cursor.getFloat(totalPayColumnIndex);
|
||||||
|
|
||||||
|
String durationString = ShiftsCursorAdapter.timeValues(duration)[0] + " Hours " + ShiftsCursorAdapter.timeValues(duration)[1] + " Minutes ";
|
||||||
|
if(breaks != 0){
|
||||||
|
durationString = durationString + " (+ " + Integer.toString(breaks) + " minutes break)";
|
||||||
|
}
|
||||||
|
|
||||||
|
typeTV.setText(type);
|
||||||
|
descriptionTV.setText(description);
|
||||||
|
dateTV.setText(date);
|
||||||
|
String totalPaid = "";
|
||||||
|
String currency = "$";
|
||||||
|
if(type.equals("Hourly")){
|
||||||
|
hourlyDetailHolder.setVisibility(View.VISIBLE);
|
||||||
|
unitsHolder.setVisibility(View.GONE);
|
||||||
|
times.setText(timeIn + " - " + timeOut);
|
||||||
|
breakTV.setText(Integer.toString(breaks) + "mins");
|
||||||
|
durationTV.setText(durationString);
|
||||||
|
totalPaid = String.format("%.2f",duration) + " Hours @ " + currency + String.format("%.2f",payrate) + " per Hour" + "\n"
|
||||||
|
+ "Equals: " + currency + String.format("%.2f",totalPay);
|
||||||
|
}else if(type.equals("Piece Rate")){
|
||||||
|
hourlyDetailHolder.setVisibility(View.GONE);
|
||||||
|
unitsHolder.setVisibility(View.VISIBLE);
|
||||||
|
unitsTV.setText(String.format("%.2f",unit));
|
||||||
|
totalPaid = String.format("%.2f",unit) + " Units @ " + currency + String.format("%.2f",payrate) + " per Unit" + "\n"
|
||||||
|
+ "Equals: " + currency + String.format("%.2f",totalPay);
|
||||||
|
}
|
||||||
|
|
||||||
|
payRateTV.setText(String.format("%.2f",payrate));
|
||||||
|
totalPayTV.setText(totalPaid);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoaderReset(android.support.v4.content.Loader<Cursor> loader) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,236 @@
|
|||||||
|
package com.example.h_mal.shift_tracker;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.ActivityCompat;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
|
||||||
|
import com.google.android.gms.ads.AdListener;
|
||||||
|
import com.google.android.gms.ads.AdRequest;
|
||||||
|
import com.google.android.gms.ads.AdView;
|
||||||
|
import com.google.android.gms.ads.MobileAds;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
public static SharedPreferences filter;
|
||||||
|
public static Context context;
|
||||||
|
static String sortOrder;
|
||||||
|
public static String selection;
|
||||||
|
public static String[] args;
|
||||||
|
private static Toolbar toolbar;
|
||||||
|
public static FragmentManager fragmentManager;
|
||||||
|
private AdView adView;
|
||||||
|
private ProgressBar progressBar;
|
||||||
|
private String currentFragment;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.main_view);
|
||||||
|
|
||||||
|
verifyStoragePermissions(this);
|
||||||
|
|
||||||
|
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
|
fragmentManager = getSupportFragmentManager();
|
||||||
|
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
||||||
|
fragmentTransaction.replace(R.id.container,new FragmentMain()).addToBackStack("main").commit();
|
||||||
|
|
||||||
|
progressBar = (ProgressBar) findViewById(R.id.progressBar2);
|
||||||
|
|
||||||
|
fragmentManager.addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() {
|
||||||
|
@Override
|
||||||
|
public void onBackStackChanged() {
|
||||||
|
List<Fragment> f = fragmentManager.getFragments();
|
||||||
|
Fragment frag = f.get(0);
|
||||||
|
currentFragment = frag.getClass().getSimpleName();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Initialize the Mobile Ads SDK.
|
||||||
|
MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713");
|
||||||
|
|
||||||
|
// Gets the ad view defined in layout/ad_fragment.xml with ad unit ID set in
|
||||||
|
// values/strings.xml.
|
||||||
|
adView = (AdView) findViewById(R.id.adView);
|
||||||
|
adView.setAdListener(new AdListener(){
|
||||||
|
@Override
|
||||||
|
public void onAdOpened() {
|
||||||
|
// Code to be executed when an ad opens an overlay that
|
||||||
|
// covers the screen.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdLeftApplication() {
|
||||||
|
// Code to be executed when the user has left the app.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdClosed() {
|
||||||
|
// Code to be executed when when the user is about to return
|
||||||
|
// to the app after tapping on an ad.
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onAdFailedToLoad(int i) {
|
||||||
|
super.onAdFailedToLoad(i);
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdLoaded() {
|
||||||
|
super.onAdLoaded();
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Create an ad request. Check your logcat output for the hashed device ID to
|
||||||
|
// get test ads on a physical device. e.g.
|
||||||
|
// "Use AdRequest.Builder.addTestDevice("ABCDEF012345") to get test ads on this device."
|
||||||
|
|
||||||
|
AdRequest adRequest = new AdRequest.Builder()
|
||||||
|
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Start loading the ad in the background.
|
||||||
|
adView.loadAd(adRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
public static void setActionBarTitle(String title){
|
||||||
|
toolbar.setTitle(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
|
getMenuInflater().inflate(R.menu.menu_main, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
|
||||||
|
switch (currentFragment) {
|
||||||
|
case "FragmentMain":
|
||||||
|
new AlertDialog.Builder(this)
|
||||||
|
.setTitle("Leave?")
|
||||||
|
.setMessage("Are you sure you want to exit Farmr?")
|
||||||
|
.setNegativeButton(android.R.string.no, null)
|
||||||
|
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface arg0, int arg1) {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
intent.addCategory(Intent.CATEGORY_HOME);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
}).create().show();
|
||||||
|
return;
|
||||||
|
case "FragmentAddItem":
|
||||||
|
if(FragmentAddItem.mRadioGroup.getCheckedRadioButtonId() == -1) {
|
||||||
|
fragmentManager.popBackStack();
|
||||||
|
}else{
|
||||||
|
new AlertDialog.Builder(this)
|
||||||
|
.setTitle("Discard Changes?")
|
||||||
|
.setMessage("Are you sure you want to discard changes?")
|
||||||
|
.setNegativeButton(android.R.string.no, null)
|
||||||
|
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface arg0, int arg1) {
|
||||||
|
fragmentManager.popBackStack();
|
||||||
|
}
|
||||||
|
}).create().show();
|
||||||
|
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
if (fragmentManager.getBackStackEntryCount() > 1) {
|
||||||
|
fragmentManager.popBackStack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Storage Permissions
|
||||||
|
private static final int REQUEST_EXTERNAL_STORAGE = 1;
|
||||||
|
private static String[] PERMISSIONS_STORAGE = {
|
||||||
|
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||||
|
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Checks if the app has permission to write to device storage
|
||||||
|
*
|
||||||
|
* If the app does not has permission then the user will be prompted to grant permissions
|
||||||
|
*
|
||||||
|
* @param activity
|
||||||
|
*/
|
||||||
|
public static void verifyStoragePermissions(Activity activity) {
|
||||||
|
// Check if we have write permission
|
||||||
|
int permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||||
|
|
||||||
|
if (permission != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
// We don't have permission so prompt the user
|
||||||
|
ActivityCompat.requestPermissions(
|
||||||
|
activity,
|
||||||
|
PERMISSIONS_STORAGE,
|
||||||
|
REQUEST_EXTERNAL_STORAGE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// protected void onUserLeaveHint() {
|
||||||
|
// super.onUserLeaveHint();
|
||||||
|
//
|
||||||
|
// Intent intent = getIntent();
|
||||||
|
// String activity = intent.getStringExtra("activity");
|
||||||
|
//
|
||||||
|
// if (activity == null || !activity.equals("first") || !activity.equals("firsttime")) {
|
||||||
|
// NavUtils.navigateUpFromSameTask(MainActivity.this);
|
||||||
|
// } else {
|
||||||
|
// getIntent().removeExtra("activity");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// protected void onPause() {
|
||||||
|
// super.onPause();
|
||||||
|
// // If the screen is off then the device has been locked
|
||||||
|
// PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
||||||
|
// boolean isScreenOn;
|
||||||
|
// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
|
||||||
|
// isScreenOn = powerManager.isInteractive();
|
||||||
|
// } else {
|
||||||
|
// isScreenOn = powerManager.isScreenOn();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (!isScreenOn) {
|
||||||
|
// Intent intent = getIntent();
|
||||||
|
// String activity = intent.getStringExtra("activity");
|
||||||
|
// if (activity == null || !activity.equals("first") || !activity.equals("firsttime")){
|
||||||
|
// NavUtils.navigateUpFromSameTask(MainActivity.this);
|
||||||
|
// }else {
|
||||||
|
// getIntent().removeExtra("activity");
|
||||||
|
// }
|
||||||
|
// System.out.println("mainactivity");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
package com.example.h_mal.shift_tracker;
|
||||||
|
|
||||||
|
import android.content.ContentUris;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.CursorAdapter;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.example.h_mal.shift_tracker.Data.ShiftProvider;
|
||||||
|
import com.example.h_mal.shift_tracker.Data.ShiftsContract.ShiftsEntry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by h_mal on 26/12/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ShiftsCursorAdapter extends CursorAdapter {
|
||||||
|
|
||||||
|
private final MainActivity activity;
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
ShiftProvider shiftProvider;
|
||||||
|
|
||||||
|
public ShiftsCursorAdapter(MainActivity context, Cursor c) {
|
||||||
|
super(context, c, 0);
|
||||||
|
this.activity = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
||||||
|
return LayoutInflater.from(context).inflate(R.layout.list_item_1, parent, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bindView(View view, Context context, Cursor cursor) {
|
||||||
|
mContext = context;
|
||||||
|
|
||||||
|
TextView descriptionTextView = (TextView) view.findViewById(R.id.location);
|
||||||
|
TextView dateTextView = (TextView) view.findViewById(R.id.date);
|
||||||
|
TextView totalPay = (TextView) view.findViewById(R.id.total_pay);
|
||||||
|
TextView hoursView = (TextView) view.findViewById(R.id.hours);
|
||||||
|
TextView h = (TextView) view.findViewById(R.id.h);
|
||||||
|
TextView minutesView = (TextView) view.findViewById(R.id.minutes);
|
||||||
|
TextView m = (TextView) view.findViewById(R.id.m);
|
||||||
|
ImageView editView = (ImageView) view.findViewById(R.id.imageView);
|
||||||
|
|
||||||
|
h.setText("h");
|
||||||
|
m.setText("m");
|
||||||
|
|
||||||
|
final String typeColumnIndex = cursor.getString(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_TYPE));
|
||||||
|
final String descriptionColumnIndex = cursor.getString(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_DESCRIPTION));
|
||||||
|
final String dateColumnIndex = cursor.getString(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_DATE));
|
||||||
|
final Float durationColumnIndex = cursor.getFloat(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_DURATION));
|
||||||
|
final Float unitsColumnIndex = cursor.getFloat(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_UNIT));
|
||||||
|
final Float totalpayColumnIndex = cursor.getFloat(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_TOTALPAY));
|
||||||
|
|
||||||
|
descriptionTextView.setText(descriptionColumnIndex);
|
||||||
|
dateTextView.setText(newDate(dateColumnIndex));
|
||||||
|
totalPay.setText(String.format("%.2f",totalpayColumnIndex));
|
||||||
|
|
||||||
|
if (typeColumnIndex.equals("Piece Rate") && durationColumnIndex == 0){
|
||||||
|
hoursView.setText(String.valueOf(unitsColumnIndex));
|
||||||
|
h.setText("");
|
||||||
|
minutesView.setText("");
|
||||||
|
m.setText("pcs");
|
||||||
|
}else
|
||||||
|
// if(typeColumnIndex.equals("Hourly") || typeColumnIndex.equals("hourly"))
|
||||||
|
{
|
||||||
|
hoursView.setText(timeValues(durationColumnIndex)[0]);
|
||||||
|
minutesView.setText(timeValues(durationColumnIndex)[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
final long ID = cursor.getLong(cursor.getColumnIndexOrThrow(ShiftsEntry._ID));
|
||||||
|
final Uri currentProductUri = ContentUris.withAppendedId(ShiftsEntry.CONTENT_URI, ID);
|
||||||
|
|
||||||
|
final Bundle b = new Bundle();
|
||||||
|
b.putString("uri",String.valueOf(currentProductUri));
|
||||||
|
|
||||||
|
view.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
// activity.clickOnViewItem(ID);
|
||||||
|
FragmentTransaction fragmentTransaction = (MainActivity.fragmentManager).beginTransaction();
|
||||||
|
FurtherInfoFragment fragment2 = new FurtherInfoFragment();
|
||||||
|
fragment2.setArguments(b);
|
||||||
|
fragmentTransaction.replace(R.id.container,fragment2).addToBackStack("furtherinfo").commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
editView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
FragmentTransaction fragmentTransaction = (MainActivity.fragmentManager).beginTransaction();
|
||||||
|
FragmentAddItem fragment3 = new FragmentAddItem();
|
||||||
|
fragment3.setArguments(b);
|
||||||
|
fragmentTransaction.replace(R.id.container,fragment3).addToBackStack("additem").commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
view.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View view) {
|
||||||
|
System.out.println("long click: " + ID);
|
||||||
|
|
||||||
|
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(mContext);
|
||||||
|
builder.setMessage("Are you sure you want to delete");
|
||||||
|
builder.setPositiveButton("delete", new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
deleteProduct(ID);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
|
||||||
|
if (dialog != null) {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
android.app.AlertDialog alertDialog = builder.create();
|
||||||
|
alertDialog.show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteProduct(Long id) {
|
||||||
|
String[] args = new String [] {String.valueOf(id)};
|
||||||
|
// String whereClause = String.format(ShiftsEntry._ID + " in (%s)", new Object[] { TextUtils.join(",", Collections.nCopies(args.length, "?")) }); //for deleting multiple lines
|
||||||
|
|
||||||
|
mContext.getContentResolver().delete(ShiftsEntry.CONTENT_URI, ShiftsEntry._ID + "=?", args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String newDate(String dateString){
|
||||||
|
|
||||||
|
String returnString = "01/01/2010";
|
||||||
|
|
||||||
|
String year = dateString.substring(0, 4);
|
||||||
|
String month = dateString.substring(5, 7);
|
||||||
|
String day = dateString.substring(8);
|
||||||
|
|
||||||
|
returnString = day + "-" + month + "-" + year;
|
||||||
|
|
||||||
|
return returnString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] timeValues(Float duration){
|
||||||
|
|
||||||
|
int hours = (int) Math.floor(duration);
|
||||||
|
int minutes = (int) ((duration - hours)*60);
|
||||||
|
|
||||||
|
String hoursString = hours + "";
|
||||||
|
String minutesString = String.format("%02d", minutes);
|
||||||
|
|
||||||
|
return new String[]{hoursString,minutesString};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.example.h_mal.shift_tracker;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.support.v4.app.ActivityOptionsCompat;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by h_mal on 27/06/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SplashScreen extends Activity {
|
||||||
|
|
||||||
|
// Splash screen timer
|
||||||
|
private static int SPLASH_TIME_OUT = 2000;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_splash);
|
||||||
|
|
||||||
|
final Bundle bundle = ActivityOptionsCompat.makeCustomAnimation(this, R.anim.hyperspace_jump, android.R.anim.fade_out).toBundle();
|
||||||
|
|
||||||
|
final RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.splash_layout);
|
||||||
|
|
||||||
|
final Intent i = new Intent(SplashScreen.this,MainActivity.class);
|
||||||
|
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
|
|
||||||
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// This method will be executed once the timer is over
|
||||||
|
// Start your app main activity
|
||||||
|
// startActivity(i,bundle);
|
||||||
|
startActivity(i);
|
||||||
|
overridePendingTransition(android.R.anim.fade_in,R.anim.hyperspace_jump);
|
||||||
|
// finish();
|
||||||
|
}
|
||||||
|
}, SPLASH_TIME_OUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
30
app/src/main/res/anim/hyperspace_jump.xml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false">
|
||||||
|
<scale
|
||||||
|
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
|
||||||
|
android:fromXScale="1.0"
|
||||||
|
android:toXScale="2.0"
|
||||||
|
android:fromYScale="1.0"
|
||||||
|
android:toYScale="2.0"
|
||||||
|
android:pivotX="50%"
|
||||||
|
android:pivotY="50%"
|
||||||
|
android:fillAfter="false"
|
||||||
|
android:duration="450" />
|
||||||
|
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<alpha android:fromAlpha="1.0" android:toAlpha="0.0"
|
||||||
|
android:interpolator="@android:anim/accelerate_interpolator"
|
||||||
|
android:duration="450"/>
|
||||||
|
</set>
|
||||||
|
<set android:interpolator="@android:anim/decelerate_interpolator">
|
||||||
|
<scale
|
||||||
|
android:fromXScale="1.4"
|
||||||
|
android:toXScale="0.8"
|
||||||
|
android:fromYScale="1.4"
|
||||||
|
android:toYScale="0.8"
|
||||||
|
android:pivotX="50%"
|
||||||
|
android:pivotY="50%"
|
||||||
|
android:startOffset="700"
|
||||||
|
android:duration="450"
|
||||||
|
android:fillBefore="false" />
|
||||||
|
</set>
|
||||||
|
</set>
|
||||||
BIN
app/src/main/res/drawable/add.png
Normal file
|
After Width: | Height: | Size: 661 B |
BIN
app/src/main/res/drawable/farm.jpg
Normal file
|
After Width: | Height: | Size: 90 KiB |
BIN
app/src/main/res/drawable/farmr.jpg
Normal file
|
After Width: | Height: | Size: 23 KiB |
9
app/src/main/res/drawable/ic_info_black_24dp.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportHeight="24.0"
|
||||||
|
android:viewportWidth="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zm1,15h-2v-6h2v6zm0,-8h-2V7h2v2z" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportHeight="24.0"
|
||||||
|
android:viewportWidth="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M11.5,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.9,2 2,2zm6.5,-6v-5.5c0,-3.07 -2.13,-5.64 -5,-6.32V3.5c0,-0.83 -0.67,-1.5 -1.5,-1.5S10,2.67 10,3.5v0.68c-2.87,0.68 -5,3.25 -5,6.32V16l-2,2v1h17v-1l-2,-2z" />
|
||||||
|
</vector>
|
||||||
9
app/src/main/res/drawable/ic_sync_black_24dp.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportHeight="24.0"
|
||||||
|
android:viewportWidth="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01,-.25 1.97,-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0,-4.42,-3.58,-8,-8,-8zm0 14c-3.31 0,-6,-2.69,-6,-6 0,-1.01.25,-1.97.7,-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4,-4,-4,-4v3z" />
|
||||||
|
</vector>
|
||||||
BIN
app/src/main/res/drawable/image_i_64.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
app/src/main/res/drawable/img_i_full.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
app/src/main/res/drawable/info.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
46
app/src/main/res/layout/activity_splash.xml
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/splash_layout">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:src="@drawable/farm"
|
||||||
|
android:tint="#6f000000" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_centerVertical="true">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:text="@string/app_name"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:textColor="#cacaca"
|
||||||
|
android:textSize="28sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:id="@+id/textView3" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView4"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="50dp"
|
||||||
|
android:paddingRight="50dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:text="The backerpacker rural days tracker"
|
||||||
|
android:textColor="#b1a8a8"
|
||||||
|
android:textSize="24sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
</RelativeLayout>
|
||||||
180
app/src/main/res/layout/dialog_layout.xml
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ScrollView 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:padding="12dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingLeft="12dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ems="10"
|
||||||
|
android:text="Clicking on a shift will load up further details. Long click will display the option to delete the selected shift." />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="6dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:background="@color/colorPrimaryDark"
|
||||||
|
app:srcCompat="@drawable/info" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/timeOutEditText"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:ems="10"
|
||||||
|
android:focusable="false"
|
||||||
|
android:text="This displays a summary of current (filtered or unfiltered) shifts." />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="6dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/filter"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:ems="10"
|
||||||
|
android:text="In this activity you can specify the parameters to filter data in the main screen. You can filter the shifts by the location name, dates and type of shift (Hourly or Piece rate).
|
||||||
|
If filtering by name - you can search by only part of the name, does not have to be full.
|
||||||
|
If filtering by date - if you leave the 'select date from' option empty it will default to the earliest date of shift. If you leave the 'select date to' option empty it will default to todays date." />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/units_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="6dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/clear"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:ems="10"
|
||||||
|
android:text="This will clear any current filters applied and load all shifts." />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="6dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/export"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:ems="10"
|
||||||
|
android:text="This will take your current selection of shifts (filtered of unfiltered) in its current sorting order and export the data to and excel file which will open up the sharing options (to share via email or other). The excel file is stored on your device in the shifttracker folder on your storage." />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="6dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/sort"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:ems="10"
|
||||||
|
android:text="Sort your shifts by order of it being added, date of shift or by name in an ascending and descending order." />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="6dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/delete"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:ems="10"
|
||||||
|
android:text="This will remove all the shifts you have currently saved. This cannot be undone so be sure if you are to delete all data." />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
328
app/src/main/res/layout/fragment_add_item.xml
Normal file
@@ -0,0 +1,328 @@
|
|||||||
|
<?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:id="@+id/activity_add_product"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
tools:context="com.example.h_mal.shift_tracker.FragmentAddItem"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/pd_ai"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/total_view">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/typeTV"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Work Type"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:id="@+id/rg"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/hourly"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="@string/hourly" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/piecerate"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="@string/pr" />
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Location"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/locationEditText"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:ems="10"
|
||||||
|
android:hint="Location name"
|
||||||
|
android:inputType="textMultiLine"
|
||||||
|
android:lines="1" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dateTextView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Date"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/dateEditText"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:ems="10"
|
||||||
|
android:hint="Date"
|
||||||
|
android:inputType="date"
|
||||||
|
android:focusable="false" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/whole_view"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/hourly_data_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView2"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Start"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/timeInEditText"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:ems="10"
|
||||||
|
android:focusable="false"
|
||||||
|
android:hint="Start Time"
|
||||||
|
android:inputType="time" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/finishTime"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Finish"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/timeOutEditText"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:ems="10"
|
||||||
|
android:focusable="false"
|
||||||
|
android:hint="Finish Time"
|
||||||
|
android:inputType="time" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/Break"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Break"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/breakEditText"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:ems="10"
|
||||||
|
android:hint="Break in minutes"
|
||||||
|
android:inputType="number"
|
||||||
|
android:selectAllOnFocus="true" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/units_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/Unit"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Units"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/unitET"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:ems="10"
|
||||||
|
android:hint="Insert units"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
|
android:selectAllOnFocus="true" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/payRate"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat"
|
||||||
|
android:text="Pay Rate" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/payrateET"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:ems="10"
|
||||||
|
android:hint="Insert Pay Rate"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
|
android:selectAllOnFocus="true" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/totalpay"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat"
|
||||||
|
android:text="Total Pay" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/totalpayval"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"/>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/duration_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/Duration"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Duration"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/ShiftDuration"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="right"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/submit"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:text="submit" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
</RelativeLayout>
|
||||||
133
app/src/main/res/layout/fragment_filter_data.xml
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
<?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:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
tools:context="com.example.h_mal.shift_tracker.FilterDataActivity">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/filterlocation"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.49"
|
||||||
|
android:text="Filter Location"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/filterLocationEditText"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:ems="10"
|
||||||
|
android:hint="Location name"
|
||||||
|
android:inputType="textMultiLine" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/filterDateInTextView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.49"
|
||||||
|
android:text="Filter Date"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/fromdateInEditText"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:ems="10"
|
||||||
|
android:focusable="false"
|
||||||
|
android:hint="Select Date From"
|
||||||
|
android:inputType="date" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/filterDateOutEditText"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:ems="10"
|
||||||
|
android:focusable="false"
|
||||||
|
android:hint="Select Date To"
|
||||||
|
android:inputType="date" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.49"
|
||||||
|
android:text="Filter Work Type"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/TypeFilterEditText"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:ems="10"
|
||||||
|
android:focusable="false"
|
||||||
|
android:hint="Select Type"
|
||||||
|
android:inputType="time" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="right"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:id="@+id/final_layout">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/submitFiltered"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:text="submit" />
|
||||||
|
</LinearLayout>
|
||||||
|
</RelativeLayout>
|
||||||
255
app/src/main/res/layout/fragment_futher_info.xml
Normal file
@@ -0,0 +1,255 @@
|
|||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
tools:context="com.example.h_mal.shift_tracker.FurtherInfoFragment">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:visibility="gone"
|
||||||
|
android:id="@+id/progressBar_info"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true"/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/further_info_view"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/typeTV"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.49"
|
||||||
|
android:text="Work Type"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/details_shift"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.49"
|
||||||
|
android:text="Location"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/details_desc"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dateTextView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.49"
|
||||||
|
android:text="Date"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/details_date"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:id="@+id/details_hourly_details">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView2"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.49"
|
||||||
|
android:text="Time"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/details_time"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/finishTime"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.49"
|
||||||
|
android:text="Break"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/details_breaks"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/Duration"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.49"
|
||||||
|
android:text="Duration"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/details_duration"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/details_units_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/Unit"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.49"
|
||||||
|
android:text="Units"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/details_units"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/payRate"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.49"
|
||||||
|
android:text="Pay Rate"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/details_pay_rate"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/totalpay"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.49"
|
||||||
|
android:text="Total Pay"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/details_totalpay"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="right"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/details_edit"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:text="Edit" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
54
app/src/main/res/layout/fragment_main.xml
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
xmlns:ads="http://schemas.android.com/apk/res-auto"
|
||||||
|
tools:context="com.example.h_mal.shift_tracker.FragmentMain">
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/list_item_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_above="@+id/adView">
|
||||||
|
</ListView>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/empty_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/empty_title_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:fontFamily="sans-serif-medium"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:text="Shift list empty"
|
||||||
|
android:textAppearance="?android:textAppearanceMedium"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/empty_subtitle_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/empty_title_text"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:fontFamily="sans-serif"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:text="add shift to begin"
|
||||||
|
android:textAppearance="?android:textAppearanceSmall"
|
||||||
|
android:textColor="#A2AAB0"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<android.support.design.widget.FloatingActionButton
|
||||||
|
android:id="@+id/fab1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_margin="@dimen/fab_margin"
|
||||||
|
android:src="@drawable/add"
|
||||||
|
ads:backgroundTint="@color/colorPrimary" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
136
app/src/main/res/layout/list_item_1.xml
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
<?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"
|
||||||
|
android:id="@+id/linearLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:divider="#656565"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="24dp"
|
||||||
|
android:paddingTop="24dp"
|
||||||
|
android:showDividers="end">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="87dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/time_holder"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/hours"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="00"
|
||||||
|
android:textColor="#143d66"
|
||||||
|
android:textSize="30sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/h"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="h"
|
||||||
|
android:textColor="#143d66"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/minutes"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="00"
|
||||||
|
android:textColor="#143d66"
|
||||||
|
android:textSize="30sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/m"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="m"
|
||||||
|
android:textColor="#143d66"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/totalpay_holder"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/currency"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="$"
|
||||||
|
android:textColor="#728fcc"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/total_pay"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="000.00"
|
||||||
|
android:textColor="#728fcc"
|
||||||
|
android:textSize="20sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/line"
|
||||||
|
android:layout_width="1dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginLeft="6dp"
|
||||||
|
android:layout_marginRight="6dp"
|
||||||
|
android:background="@android:color/darker_gray" />
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="12dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/location"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_below="@+id/date"
|
||||||
|
android:maxLines="3"
|
||||||
|
android:text="Location Name"
|
||||||
|
android:textSize="20sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/date"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_marginBottom="3dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="01-05-2010"
|
||||||
|
android:textColor="#000000"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/imageView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
app:srcCompat="@android:drawable/ic_menu_edit" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
58
app/src/main/res/layout/main_view.xml
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:ads="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
tools:context=".MainActivity"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<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_above="@id/adView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/container">
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<com.google.android.gms.ads.AdView
|
||||||
|
android:id="@+id/adView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
ads:adSize="BANNER"
|
||||||
|
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
|
||||||
|
</com.google.android.gms.ads.AdView>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar2"
|
||||||
|
style="?android:attr/progressBarStyle"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
</RelativeLayout>
|
||||||
42
app/src/main/res/menu/menu_main.xml
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<menu 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"
|
||||||
|
tools:context="com.example.h_mal.shift_tracker.MainActivity">
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_favorite"
|
||||||
|
android:icon="@drawable/image_i_64"
|
||||||
|
android:orderInCategory="300"
|
||||||
|
android:title="User"
|
||||||
|
app:showAsAction="ifRoom"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/filter_data"
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:title="@string/filter"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/clear_filter"
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:title="@string/clear"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/export_data"
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:title="@string/export"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/sort_data"
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:title="@string/sort"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/delete_all"
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:title="@string/delete"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/help"
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:title="@string/help"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
</menu>
|
||||||
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/farmicon.png
Normal file
|
After Width: | Height: | Size: 130 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 9.0 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
6
app/src/main/res/values/colors.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="colorPrimary">#3f51b5</color>
|
||||||
|
<color name="colorPrimaryDark">#303f9f</color>
|
||||||
|
<color name="colorAccent">#FF4081</color>
|
||||||
|
</resources>
|
||||||
7
app/src/main/res/values/dimens.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||||
|
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||||
|
<dimen name="fab_margin">16dp</dimen>
|
||||||
|
<dimen name="appbar_padding_top">8dp</dimen>
|
||||||
|
</resources>
|
||||||
105
app/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">Farmr</string>
|
||||||
|
<string name="action_settings">Settings</string>
|
||||||
|
<string name="category_ach">Shifts</string>
|
||||||
|
|
||||||
|
<string name="add_item_title">Add Shift</string>
|
||||||
|
<string name="edit_item_title">Edit Shift</string>
|
||||||
|
<string name="delete_item">Delete Shift</string>
|
||||||
|
<string name="insert_item_failed">failed to insert Shift</string>
|
||||||
|
<string name="insert_item_successful">Shift successfully added</string>
|
||||||
|
<string name="update_item_failed">Update Failed</string>
|
||||||
|
<string name="update_item_successful">Update Successful</string>
|
||||||
|
<string name="add">Add Shift</string>
|
||||||
|
<string name="insert">Insert Dummy Data</string>
|
||||||
|
<string name="delete">Delete All</string>
|
||||||
|
<string name="filter">Filter Data</string>
|
||||||
|
<string name="clear">Clear Filter</string>
|
||||||
|
<string name="title_activity_filter_data">Filter Data</string>
|
||||||
|
|
||||||
|
<string name="hourly">Hourly</string>
|
||||||
|
<string name="pr">Piece Rate</string>
|
||||||
|
|
||||||
|
<!-- Strings related to Settings -->
|
||||||
|
|
||||||
|
<!-- Example General settings -->
|
||||||
|
<string name="pref_header_general">General</string>
|
||||||
|
|
||||||
|
<string name="pref_title_social_recommendations">Enable social recommendations</string>
|
||||||
|
<string name="pref_description_social_recommendations">Recommendations for people to contact
|
||||||
|
based on your message history
|
||||||
|
</string>
|
||||||
|
|
||||||
|
<string name="pref_title_display_name">Display name</string>
|
||||||
|
<string name="pref_default_display_name">John Smith</string>
|
||||||
|
|
||||||
|
<string name="pref_title_add_friends_to_messages">Add friends to messages</string>
|
||||||
|
<string-array name="pref_example_list_titles">
|
||||||
|
<item>Always</item>
|
||||||
|
<item>When possible</item>
|
||||||
|
<item>Never</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="pref_example_list_values">
|
||||||
|
<item>1</item>
|
||||||
|
<item>0</item>
|
||||||
|
<item>-1</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Example settings for Data & Sync -->
|
||||||
|
<string name="pref_header_data_sync">Data & sync</string>
|
||||||
|
|
||||||
|
<string name="pref_title_sync_frequency">Sync frequency</string>
|
||||||
|
<string-array name="pref_sync_frequency_titles">
|
||||||
|
<item>15 minutes</item>
|
||||||
|
<item>30 minutes</item>
|
||||||
|
<item>1 hour</item>
|
||||||
|
<item>3 hours</item>
|
||||||
|
<item>6 hours</item>
|
||||||
|
<item>Never</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="pref_sync_frequency_values">
|
||||||
|
<item>15</item>
|
||||||
|
<item>30</item>
|
||||||
|
<item>60</item>
|
||||||
|
<item>180</item>
|
||||||
|
<item>360</item>
|
||||||
|
<item>-1</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="list_preference_entries">
|
||||||
|
<item>Entry 1</item>
|
||||||
|
<item>Entry 2</item>
|
||||||
|
<item>Entry 3</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="list_preference_entry_values">
|
||||||
|
<item>1</item>
|
||||||
|
<item>2</item>
|
||||||
|
<item>3</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="multi_select_list_preference_default_value" />
|
||||||
|
|
||||||
|
<string name="pref_title_system_sync_settings">System sync settings</string>
|
||||||
|
|
||||||
|
<!-- Example settings for Notifications -->
|
||||||
|
<string name="pref_header_notifications">Notifications</string>
|
||||||
|
|
||||||
|
<string name="pref_title_new_message_notifications">New message notifications</string>
|
||||||
|
|
||||||
|
<string name="pref_title_ringtone">Ringtone</string>
|
||||||
|
<string name="pref_ringtone_silent">Silent</string>
|
||||||
|
|
||||||
|
<string name="pref_title_vibrate">Vibrate</string>
|
||||||
|
<string name="export">Export Data</string>
|
||||||
|
<string name="sort">Sort</string>
|
||||||
|
|
||||||
|
<string name="admob_unit_id">ca-app-pub-3406791512187471/7557456476</string>
|
||||||
|
<string name="banner_home_footer">ca-app-pub-3406791512187471~9541579845</string>
|
||||||
|
|
||||||
|
<string name="help">Help & Support</string>
|
||||||
|
|
||||||
|
<!-- TODO: Remove or change this placeholder text -->
|
||||||
|
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||||
|
<string name="further_info_title">Shift Details</string>
|
||||||
|
</resources>
|
||||||
20
app/src/main/res/values/styles.xml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<resources>
|
||||||
|
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="AppTheme.NoActionBar">
|
||||||
|
<item name="windowActionBar">false</item>
|
||||||
|
<item name="windowNoTitle">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||||
|
|
||||||
|
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||||
|
|
||||||
|
</resources>
|
||||||
21
app/src/main/res/xml/pref_data_sync.xml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<!-- NOTE: Hide buttons to simplify the UI. Users can touch outside the dialog to
|
||||||
|
dismiss it. -->
|
||||||
|
<!-- NOTE: ListPreference's summary should be set to its value by the activity code. -->
|
||||||
|
<ListPreference
|
||||||
|
android:defaultValue="180"
|
||||||
|
android:entries="@array/pref_sync_frequency_titles"
|
||||||
|
android:entryValues="@array/pref_sync_frequency_values"
|
||||||
|
android:key="sync_frequency"
|
||||||
|
android:negativeButtonText="@null"
|
||||||
|
android:positiveButtonText="@null"
|
||||||
|
android:title="@string/pref_title_sync_frequency" />
|
||||||
|
|
||||||
|
<!-- This preference simply launches an intent when selected. Use this UI sparingly, per
|
||||||
|
design guidelines. -->
|
||||||
|
<Preference android:title="@string/pref_title_system_sync_settings">
|
||||||
|
<intent android:action="android.settings.SYNC_SETTINGS" />
|
||||||
|
</Preference>
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
||||||
33
app/src/main/res/xml/pref_general.xml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="example_switch"
|
||||||
|
android:summary="@string/pref_description_social_recommendations"
|
||||||
|
android:title="@string/pref_title_social_recommendations" />
|
||||||
|
|
||||||
|
<!-- NOTE: EditTextPreference accepts EditText attributes. -->
|
||||||
|
<!-- NOTE: EditTextPreference's summary should be set to its value by the activity code. -->
|
||||||
|
<EditTextPreference
|
||||||
|
android:capitalize="words"
|
||||||
|
android:defaultValue="@string/pref_default_display_name"
|
||||||
|
android:inputType="textCapWords"
|
||||||
|
android:key="example_text"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:title="@string/pref_title_display_name" />
|
||||||
|
|
||||||
|
<!-- NOTE: Hide buttons to simplify the UI. Users can touch outside the dialog to
|
||||||
|
dismiss it. -->
|
||||||
|
<!-- NOTE: ListPreference's summary should be set to its value by the activity code. -->
|
||||||
|
<ListPreference
|
||||||
|
android:defaultValue="-1"
|
||||||
|
android:entries="@array/pref_example_list_titles"
|
||||||
|
android:entryValues="@array/pref_example_list_values"
|
||||||
|
android:key="example_list"
|
||||||
|
android:negativeButtonText="@null"
|
||||||
|
android:positiveButtonText="@null"
|
||||||
|
android:title="@string/pref_title_add_friends_to_messages" />
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
||||||
20
app/src/main/res/xml/pref_headers.xml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<!-- These settings headers are only used on tablets. -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:fragment="com.example.h_mal.shift_tracker.FilterDataActivity$GeneralPreferenceFragment"
|
||||||
|
android:icon="@drawable/ic_info_black_24dp"
|
||||||
|
android:title="@string/pref_header_general" />
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:fragment="com.example.h_mal.shift_tracker.FilterDataActivity$NotificationPreferenceFragment"
|
||||||
|
android:icon="@drawable/ic_notifications_black_24dp"
|
||||||
|
android:title="@string/pref_header_notifications" />
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:fragment="com.example.h_mal.shift_tracker.FilterDataActivity$DataSyncPreferenceFragment"
|
||||||
|
android:icon="@drawable/ic_sync_black_24dp"
|
||||||
|
android:title="@string/pref_header_data_sync" />
|
||||||
|
|
||||||
|
</preference-headers>
|
||||||
27
app/src/main/res/xml/pref_notification.xml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<!-- A 'parent' preference, which enables/disables child preferences (below)
|
||||||
|
when checked/unchecked. -->
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="notifications_new_message"
|
||||||
|
android:title="@string/pref_title_new_message_notifications" />
|
||||||
|
|
||||||
|
<!-- Allows the user to choose a ringtone in the 'notification' category. -->
|
||||||
|
<!-- NOTE: This preference will be enabled only when the checkbox above is checked. -->
|
||||||
|
<!-- NOTE: RingtonePreference's summary should be set to its value by the activity code. -->
|
||||||
|
<RingtonePreference
|
||||||
|
android:defaultValue="content://settings/system/notification_sound"
|
||||||
|
android:dependency="notifications_new_message"
|
||||||
|
android:key="notifications_new_message_ringtone"
|
||||||
|
android:ringtoneType="notification"
|
||||||
|
android:title="@string/pref_title_ringtone" />
|
||||||
|
|
||||||
|
<!-- NOTE: This preference will be enabled only when the checkbox above is checked. -->
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:dependency="notifications_new_message"
|
||||||
|
android:key="notifications_new_message_vibrate"
|
||||||
|
android:title="@string/pref_title_vibrate" />
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.example.h_mal.shift_tracker;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example local unit test, which will execute on the development machine (host).
|
||||||
|
*
|
||||||
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||||
|
*/
|
||||||
|
public class ExampleUnitTest {
|
||||||
|
@Test
|
||||||
|
public void addition_isCorrect() throws Exception {
|
||||||
|
assertEquals(4, 2 + 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
25
build.gradle
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
google()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||||
|
|
||||||
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
// in the individual module build.gradle files
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
google()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task clean(type: Delete) {
|
||||||
|
delete rootProject.buildDir
|
||||||
|
}
|
||||||
17
gradle.properties
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Project-wide Gradle settings.
|
||||||
|
|
||||||
|
# IDE (e.g. Android Studio) users:
|
||||||
|
# Gradle settings configured through the IDE *will override*
|
||||||
|
# any settings specified in this file.
|
||||||
|
|
||||||
|
# For more details on how to configure your build environment visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
|
|
||||||
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
org.gradle.jvmargs=-Xmx1536m
|
||||||
|
|
||||||
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
|
# org.gradle.parallel=true
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#Mon Feb 05 21:21:28 AEDT 2018
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
|
||||||
160
gradlew
vendored
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn ( ) {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die ( ) {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||||
|
function splitJvmOpts() {
|
||||||
|
JVM_OPTS=("$@")
|
||||||
|
}
|
||||||
|
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||||
|
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||||
|
|
||||||
|
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||||
90
gradlew.bat
vendored
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windowz variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
goto execute
|
||||||
|
|
||||||
|
:4NT_args
|
||||||
|
@rem Get arguments from the 4NT Shell from JP Software
|
||||||
|
set CMD_LINE_ARGS=%$
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
1
settings.gradle
Normal file
@@ -0,0 +1 @@
|
|||||||
|
include ':app'
|
||||||