Initial commit

This commit is contained in:
2017-12-29 14:05:32 +11:00
commit f8235dbfa5
51 changed files with 2397 additions and 0 deletions

9
.gitignore vendored Normal file
View 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
View 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
View File

@@ -0,0 +1,3 @@
<component name="CopyrightManager">
<settings default="" />
</component>

18
.idea/gradle.xml generated Normal file
View 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>

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

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<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="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="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
View 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
View File

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

1
app/.gitignore vendored Normal file
View File

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

31
app/build.gradle Normal file
View File

@@ -0,0 +1,31 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.h_mal.shift_tracker"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
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.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}

25
app/proguard-rules.pro vendored Normal file
View 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

View File

@@ -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());
}
}

View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.h_mal.shift_tracker">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<!-- 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">
</activity>
<activity
android:name=".AddItem"
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<activity
android:name=".LoginSetup"
android:parentActivityName=".SplashScreen">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".SplashScreen" />
</activity>
<activity
android:name=".LoginScreen"
android:parentActivityName=".SplashScreen">
<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>

View File

@@ -0,0 +1,500 @@
package com.example.h_mal.shift_tracker;
import android.app.DatePickerDialog;
import android.app.LoaderManager;
import android.app.TimePickerDialog;
import android.content.ContentValues;
import android.content.CursorLoader;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.Loader;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import com.example.h_mal.shift_tracker.Data.ShiftsContract.ShiftsEntry;
/**
* Created by h_mal on 26/12/2017.
*/
public class AddItem extends AppCompatActivity implements
LoaderManager.LoaderCallbacks<Cursor>{
private static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 1;
private static final int EXISTING_PRODUCT_LOADER = 0;
private Uri mCurrentProductUri;
private EditText mLocationEditText;
private EditText mDateEditText;
private TextView mDurationTextView;
private EditText mTimeInEditText;
private EditText mTimeOutEditText;
private EditText mBreakEditText;
private static final int RESULT_LOAD_IMAGE = 1;
private boolean mProductHasChanged = false;
private static final int PICK_IMAGE_REQUEST = 0;
private View.OnTouchListener mTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
mProductHasChanged = true;
return false;
}
};
private int mDay;
private int mMonth;
private int mYear;
private int mHoursIn;
private int mMinutesIn;
private int mHoursOut;
private int mMinutesOut;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_item);
mLocationEditText = (EditText) findViewById(R.id.locationEditText);
mDateEditText = (EditText) findViewById(R.id.dateEditText);
mTimeInEditText = (EditText) findViewById(R.id.timeInEditText);
mBreakEditText = (EditText) findViewById(R.id.breakEditText);
mTimeOutEditText = (EditText) findViewById(R.id.timeOutEditText);
mDurationTextView = (TextView) findViewById(R.id.ShiftDuration);
Intent intent = getIntent();
mCurrentProductUri = intent.getData();
if (mCurrentProductUri == null) {
setTitle(getString(R.string.add_item_title));
invalidateOptionsMenu();
} else {
setTitle(getString(R.string.edit_item_title));
getLoaderManager().initLoader(EXISTING_PRODUCT_LOADER, null, this);
}
if (mDateEditText.getText().toString().equals("")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
mDateEditText.setText(sdf.format(new Date()));
}
mBreakEditText.setText("0");
mDateEditText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//To show current date in the datepicker
Calendar mcurrentDate=Calendar.getInstance();
mYear=mcurrentDate.get(Calendar.YEAR);
mMonth=mcurrentDate.get(Calendar.MONTH);
mDay=mcurrentDate.get(Calendar.DAY_OF_MONTH);
DatePickerDialog mDatePicker=new DatePickerDialog(AddItem.this, new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker datepicker, int selectedyear, int selectedmonth, int selectedday) {
mDateEditText.setText(String.format("%02d", selectedday) + "/" + String.format("%02d", (selectedmonth = selectedmonth + 1)) + "/" + selectedyear);
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(AddItem.this, 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(AddItem.this, 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();
}
});
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();
}
});
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();
}
});
Button SubmitProduct = (Button) findViewById(R.id.submit);
SubmitProduct.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
saveProduct();
}
});
mLocationEditText.setOnTouchListener(mTouchListener);
}
@Override
public void onBackPressed() {
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) {
AddItem.super.onBackPressed();
}
}).create().show();
}
private void saveProduct() {
String descriptionString = mLocationEditText.getText().toString().trim();
String dateString = mDateEditText.getText().toString().trim();
String timeInString = mTimeInEditText.getText().toString().trim();
String timeOutString = mTimeOutEditText.getText().toString().trim();
String breakMins = mBreakEditText.getText().toString().trim();
int breaks = Integer.parseInt(breakMins);
float duration = calculateDuration(mHoursIn,mMinutesIn,mHoursOut,mMinutesOut,breaks);
if (
TextUtils.isEmpty(descriptionString)) {
Toast.makeText(AddItem.this, "please insert all product data", Toast.LENGTH_SHORT).show();
return;
}
ContentValues values = new ContentValues();
values.put(ShiftsEntry.COLUMN_SHIFT_DESCRIPTION, descriptionString);
values.put(ShiftsEntry.COLUMN_SHIFT_DATE, dateString);
values.put(ShiftsEntry.COLUMN_SHIFT_TIME_IN, timeInString);
values.put(ShiftsEntry.COLUMN_SHIFT_TIME_OUT, timeOutString);
values.put(ShiftsEntry.COLUMN_SHIFT_DURATION, duration);
values.put(ShiftsEntry.COLUMN_SHIFT_BREAK, breaks);
if (mCurrentProductUri == null) {
Uri newUri = getContentResolver().insert(ShiftsEntry.CONTENT_URI, values);
if (newUri == null) {
Toast.makeText(this, getString(R.string.insert_item_failed),
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, getString(R.string.insert_item_successful),
Toast.LENGTH_SHORT).show();
}
} else {
int rowsAffected = getContentResolver().update(mCurrentProductUri, values, null, null);
if (rowsAffected == 0) {
Toast.makeText(this, getString(R.string.update_item_failed),
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, getString(R.string.update_item_successful),
Toast.LENGTH_SHORT).show();
}
}
NavUtils.navigateUpFromSameTask(AddItem.this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
private void setDuration (){
int breaks = 0;
if (!mBreakEditText.getText().toString().equals("")){
breaks = Integer.parseInt(mBreakEditText.getText().toString());
}
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());
}
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());
}
mDurationTextView.setText(calculateDuration(mHoursIn,mMinutesIn,mHoursOut,mMinutesOut,breaks) + " hours");
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.delete_all:
DeleteDialog();
return true;
}
return super.onOptionsItemSelected(item);
}
private void DeleteDialog() {
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(this);
builder.setMessage("Are you sure you want to delete");
builder.setPositiveButton("delete", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
deleteProduct();
}
});
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();
}
private void deleteProduct() {
if (mCurrentProductUri != null) {
int rowsDeleted = getContentResolver().delete(mCurrentProductUri, null, null);
if (rowsDeleted == 0) {
Toast.makeText(this, "error deleting product", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "Product deleted", Toast.LENGTH_SHORT).show();
}
}
finish();
}
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);
}
@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};
return new CursorLoader(this,
mCurrentProductUri,
projection,
null,
null,
null);
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
if (cursor == null || cursor.getCount() < 1) {
return;
}
if (cursor.moveToFirst()) {
int descriptionColumnIndex = cursor.getColumnIndex(ShiftsEntry.COLUMN_SHIFT_DESCRIPTION);
int dateColumnIndex = cursor.getColumnIndex(ShiftsEntry.COLUMN_SHIFT_DATE);
int timeInColumnIndex = cursor.getColumnIndex(ShiftsEntry.COLUMN_SHIFT_TIME_IN);
int timeOutColumnIndex = cursor.getColumnIndex(ShiftsEntry.COLUMN_SHIFT_TIME_OUT);
int breakColumnIndex = cursor.getColumnIndex(ShiftsEntry.COLUMN_SHIFT_BREAK);
int durationColumnIndex = cursor.getColumnIndex(ShiftsEntry.COLUMN_SHIFT_DURATION);
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);
mLocationEditText.setText(description);
mDateEditText.setText(date);
mTimeInEditText.setText(timeIn);
mTimeOutEditText.setText(timeOut);
mBreakEditText.setText(Integer.toString(breaks));
mDurationTextView.setText(Float.toString(duration) + " Hours");
}
}
@Override
public void onLoaderReset(Loader<Cursor> loader) {
}
}

View File

@@ -0,0 +1,236 @@
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;
@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");
}
values.getAsFloat(ShiftsEntry.COLUMN_SHIFT_DURATION);
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);
}
}
}

View File

@@ -0,0 +1,52 @@
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 _ID = BaseColumns._ID;
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";
}
}

View File

@@ -0,0 +1,47 @@
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 = 1;
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)";
db.execSQL(SQL_CREATE_PRODUCTS_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}

View File

@@ -0,0 +1,76 @@
package com.example.h_mal.shift_tracker;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
/**
* Created by h_mal on 27/06/2017.
*/
public class LoginScreen extends AppCompatActivity{
private EditText mPasswordEditText;
String password;
int count = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_screen);
SharedPreferences settings = getSharedPreferences("PREFS", 0);
password = settings.getString("password", "");
mPasswordEditText = (EditText) findViewById(R.id.loginPassword);
Button login = (Button) findViewById(R.id.loginButton);
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
login();
mPasswordEditText.getText().clear();
}
});
}
private void login() {
String PasswordString = mPasswordEditText.getText().toString().trim();
if (
TextUtils.isEmpty(PasswordString) ) {
Toast.makeText(LoginScreen.this, "please enter password", Toast.LENGTH_SHORT).show();
return;
}
if(PasswordString.equals(password)){
Intent i = new Intent(LoginScreen.this, MainActivity.class);
startActivity(i);
}else{
addCount();
Toast.makeText(LoginScreen.this, "password incorrect " + (4 - count) + " tries left", Toast.LENGTH_SHORT).show();
}
}
private void addCount(){
count = count + 1;
if (count == 4){
finish();
System.exit(0);
}
}
}

View File

@@ -0,0 +1,73 @@
package com.example.h_mal.shift_tracker;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
/**
* Created by h_mal on 27/06/2017.
*/
public class LoginSetup extends Activity {
private EditText mPasswordInitialEditText;
private EditText mPasswordCheckEditText;
public SharedPreferences prefs = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_setup);
mPasswordInitialEditText = (EditText) findViewById(R.id.loginPasswordInitial);
mPasswordCheckEditText = (EditText) findViewById(R.id.loginPasswordCheck);
Button login = (Button) findViewById(R.id.loginButton);
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
clickLogin();
}
});
}
private void clickLogin() {
String initialPasswordString = mPasswordInitialEditText.getText().toString().trim();
String checkPasswordString = mPasswordCheckEditText.getText().toString().trim();
if (
TextUtils.isEmpty(initialPasswordString) ||
TextUtils.isEmpty(checkPasswordString) ) {
Toast.makeText(LoginSetup.this, "please set password", Toast.LENGTH_SHORT).show();
return;
}
if (!initialPasswordString.equals(checkPasswordString)){
Toast.makeText(LoginSetup.this, "Passwords do not match", Toast.LENGTH_SHORT).show();
return;}
if(initialPasswordString.equals(checkPasswordString)){
SharedPreferences settings = getSharedPreferences("PREFS", 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("password", initialPasswordString);
editor.apply();
}
Intent i = new Intent(LoginSetup.this, MainActivity.class);
startActivity(i);
}
}

View File

@@ -0,0 +1,157 @@
package com.example.h_mal.shift_tracker;
import android.app.LoaderManager;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.CursorLoader;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.Loader;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;
import android.support.design.widget.FloatingActionButton;
import com.example.h_mal.shift_tracker.Data.ShiftsContract.ShiftsEntry;
import com.example.h_mal.shift_tracker.Data.ShiftsDbHelper;
public class MainActivity extends AppCompatActivity implements LoaderManager.LoaderCallbacks<Cursor> {
private static final int ACHIEVEMENT_LOADER = 0;
ShiftsCursorAdapter mCursorAdapter;
ShiftsDbHelper shiftsDbhelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_view);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab1);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this, AddItem.class);
startActivity(intent);
}
});
ListView productListView = (ListView) findViewById(R.id.list_item_view);
View emptyView = findViewById(R.id.empty_view);
productListView.setEmptyView(emptyView);
mCursorAdapter = new ShiftsCursorAdapter(this, null);
productListView.setAdapter(mCursorAdapter);
getLoaderManager().initLoader(ACHIEVEMENT_LOADER, null, this);
}
private void insertProduct() {
ContentValues values = new ContentValues();
values.put(ShiftsEntry.COLUMN_SHIFT_DESCRIPTION, "Random Location");
values.put(ShiftsEntry.COLUMN_SHIFT_DATE, "1970/01/01");
values.put(ShiftsEntry.COLUMN_SHIFT_TIME_IN, "00:00");
values.put(ShiftsEntry.COLUMN_SHIFT_TIME_OUT, "12:00");
values.put(ShiftsEntry.COLUMN_SHIFT_BREAK, 30);
values.put(ShiftsEntry.COLUMN_SHIFT_DURATION, 12);
getContentResolver().insert(ShiftsEntry.CONTENT_URI, values);
}
private void deleteAllProducts() {
int rowsDeleted = getContentResolver().delete(ShiftsEntry.CONTENT_URI, null, null);
Log.v("MainActivity", rowsDeleted + " rows deleted");
}
@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;
}
public void clickOnViewItem(long id) {
Intent intent = new Intent(MainActivity.this, AddItem.class);
Uri currentProductUri = ContentUris.withAppendedId(ShiftsEntry.CONTENT_URI, id);
intent.setData(currentProductUri);
startActivity(intent);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.delete_all:
deleteAllProducts();
return true;
case R.id.insert_placeholder_data:
insertProduct();
return true;
}
return super.onOptionsItemSelected(item);
}
@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};
return new CursorLoader(this,
ShiftsEntry.CONTENT_URI,
projection,
null,
null,
null);
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
mCursorAdapter.swapCursor(data);
}
@Override
public void onLoaderReset(Loader<Cursor> loader) {
mCursorAdapter.swapCursor(null);
}
@Override
public void onBackPressed() {
new AlertDialog.Builder(this)
.setTitle("Leave?")
.setMessage("Are you sure you want to exit Shifts?")
.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();
}
}

View File

@@ -0,0 +1,65 @@
package com.example.h_mal.shift_tracker;
import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.TextView;
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;
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, parent, false);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
mContext = context;
TextView descriptionTextView = (TextView) view.findViewById(R.id.editText);
TextView dateTextView = (TextView) view.findViewById(R.id.textView5);
TextView timeTextView = (TextView) view.findViewById(R.id.textView5out);
TextView durationTextView = (TextView) view.findViewById(R.id.textView7);
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 String durationColumnIndex = cursor.getString(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_DURATION));
final String breakOutColumnIndex = cursor.getString(cursor.getColumnIndexOrThrow(ShiftsEntry.COLUMN_SHIFT_BREAK));
descriptionTextView.setText(descriptionColumnIndex);
dateTextView.setText(dateColumnIndex);
timeTextView.setText(timeInColumnIndex + "-" + timeOutColumnIndex);
durationTextView.setText(durationColumnIndex + " Hours worked (+ "+ breakOutColumnIndex +" minutes break)");
final long id = cursor.getLong(cursor.getColumnIndexOrThrow(ShiftsEntry._ID));
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
activity.clickOnViewItem(id);
}
});
}
}

View File

@@ -0,0 +1,57 @@
package com.example.h_mal.shift_tracker;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
/**
* Created by h_mal on 27/06/2017.
*/
public class SplashScreen extends Activity {
// Splash screen timer
private static int SPLASH_TIME_OUT = 3000;
String password;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
SharedPreferences settings = getSharedPreferences("PREFS", 0);
password = settings.getString("password", "");
new Handler().postDelayed(new Runnable() {
/*
* Showing splash screen with a timer. This will be useful when you
* want to show case your app logo / company
*/
@Override
public void run() {
// This method will be executed once the timer is over
// Start your app main activity
if (password.equals("")) {
Intent i = new Intent(SplashScreen.this, LoginSetup.class);
startActivity(i);
}else {
Intent i = new Intent(SplashScreen.this, LoginScreen.class);
startActivity(i);
}
// close this activity
finish();
}
}, SPLASH_TIME_OUT);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

View File

@@ -0,0 +1,194 @@
<?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: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.AddItem"
android:orientation="vertical">
<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/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.49"
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="1"
android:ems="10"
android:hint="Location name"
android:inputType="textMultiLine"
android:lines="3" />
</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" />
<EditText
android:id="@+id/dateEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:hint="Date"
android:inputType="date"
android:focusable="false" />
</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/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.49"
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="1"
android:ems="10"
android:hint="Start Time"
android:inputType="time"
android:focusable="false"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.49"
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="Finish"
android:textAppearance="@style/TextAppearance.AppCompat" />
<EditText
android:id="@+id/timeOutEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:hint="Finish Time"
android:inputType="time"
android:focusable="false" />
</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" />
<EditText
android:id="@+id/breakEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:ems="10"
android:selectAllOnFocus="true"
android:hint="Break in minutes"
android:inputType="number" />
</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/Duration"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Duration" />
<TextView
android:id="@+id/ShiftDuration"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="##:##"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
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>
</ScrollView>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:gravity="center_horizontal"
android:text="Shift Tracker"
android:textColor="#454545"
android:textAllCaps="true"
android:textStyle="bold"
android:textSize="28dp" />
</RelativeLayout>

View File

@@ -0,0 +1,86 @@
<?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:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/linearLayout"
android:paddingTop="24dp"
android:divider="#656565"
android:showDividers="end">
<TextView
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="12dp"
android:layout_marginLeft="12dp"
android:layout_marginBottom="8dp"
android:text="Location"
android:textSize="20sp" />
<LinearLayout
android:id="@+id/linview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:orientation="horizontal">
<TextView
android:id="@+id/dateTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_weight="2"
android:text="Date:"
android:textSize="20sp" />
<TextView
android:id="@+id/textView5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="12dp"
android:layout_weight="3"
android:text="##/##/####"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linview2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:orientation="horizontal">
<TextView
android:id="@+id/dateTextView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_weight="2"
android:text="Time:"
android:textSize="20sp" />
<TextView
android:id="@+id/textView5out"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="12dp"
android:layout_weight="3"
android:text="##:## - ##:##"
android:textSize="20sp" />
</LinearLayout>
<TextView
android:id="@+id/textView7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="24dp"
android:text="## Hours worked (+ ## minutes break)"
android:textSize="20sp" />
</LinearLayout>

View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_horizontal_margin">
<TextView
android:text="Password"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="@style/TextAppearance.AppCompat" />
<EditText
android:id="@+id/loginPassword"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:ems="10"
android:hint="Password"
android:inputType="numberPassword" />
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="Login" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>

View File

@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_horizontal_margin">
<TextView
android:text="Password"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="@style/TextAppearance.AppCompat" />
<EditText
android:id="@+id/loginPasswordInitial"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:ems="10"
android:hint="Password"
android:inputType="numberPassword" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_horizontal_margin">
<TextView
android:text="Repeat Password"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="@style/TextAppearance.AppCompat" />
<EditText
android:id="@+id/loginPasswordCheck"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:ems="10"
android:hint="Repeat Password"
android:inputType="numberPassword" />
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="Login" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>

View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/list_item_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</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_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_menu_add" />
</RelativeLayout>

View File

@@ -0,0 +1,16 @@
<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/insert_placeholder_data"
android:orderInCategory="100"
android:title="@string/insert"
app:showAsAction="never" />
<item
android:id="@+id/delete_all"
android:orderInCategory="100"
android:title="@string/delete"
app:showAsAction="never" />
</menu>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View 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>

View 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>

View File

@@ -0,0 +1,18 @@
<resources>
<string name="app_name">Shift Tracker</string>
<string name="action_settings">Settings</string>
<string name="section_format">Hello World from section: %1$d</string>
<string name="category_ach">Achievements</string>
<string name="category_tar">Target</string>
<string name="add_item_title">Add Achievement</string>
<string name="edit_item_title">Edit Achievement</string>
<string name="delete_item">Delete Item</string>
<string name="insert_item_failed">failed to insert item</string>
<string name="insert_item_successful">Item successfully added</string>
<string name="update_item_failed">Update Filed</string>
<string name="update_item_successful">Update Successful</string>
<string name="add">Add Item</string>
<string name="insert">Insert Dummy Data</string>
<string name="delete">Delete All</string>
</resources>

View 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>

View File

@@ -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);
}
}

23
build.gradle Normal file
View File

@@ -0,0 +1,23 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

17
gradle.properties Normal file
View 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

Binary file not shown.

View File

@@ -0,0 +1,6 @@
#Tue Dec 26 22:52:55 AEDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

160
gradlew vendored Normal file
View 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
View 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
View File

@@ -0,0 +1 @@
include ':app'