diff --git a/.gitignore b/.gitignore index 39ce959..9c10a36 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ app/google-services.json *.iws # Mac -.DS_Store \ No newline at end of file +.DS_Store +app/release/ diff --git a/app-release.apk b/app-release.apk index 07d5b18..00ee538 100644 Binary files a/app-release.apk and b/app-release.apk differ diff --git a/app/build.gradle b/app/build.gradle index 2a46cae..28a8596 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "xyz.appmaker.keralarescue.v2" minSdkVersion 16 targetSdkVersion 27 - versionCode 11 - versionName "1.4" + versionCode 12 + versionName "1.5" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" javaCompileOptions { annotationProcessorOptions { diff --git a/app/schemas/xyz.appmaker.keralarescue.Room.CampDatabase/3.json b/app/schemas/xyz.appmaker.keralarescue.Room.CampDatabase/3.json new file mode 100644 index 0000000..1e9613d --- /dev/null +++ b/app/schemas/xyz.appmaker.keralarescue.Room.CampDatabase/3.json @@ -0,0 +1,125 @@ +{ + "formatVersion": 1, + "database": { + "version": 3, + "identityHash": "3e81e3e6d7a1b95613f7fa5850988ca2", + "entities": [ + { + "tableName": "camp_names", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `camp_id` INTEGER NOT NULL, `district` TEXT NOT NULL, PRIMARY KEY(`camp_id`))", + "fields": [ + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "camp_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "district", + "columnName": "district", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "camp_id" + ], + "autoGenerate": false + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "person_data", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT, `camp_id` TEXT, `age` TEXT, `gender` TEXT, `address` TEXT, `district` TEXT, `mobile` TEXT, `note` TEXT, `status` TEXT, `checkin_date` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "camped_at", + "columnName": "camp_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "age", + "columnName": "age", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "gender", + "columnName": "gender", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "address", + "columnName": "address", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "district", + "columnName": "district", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "mobile", + "columnName": "mobile", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "note", + "columnName": "note", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "syncStatus", + "columnName": "status", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "checkinDate", + "columnName": "checkin_date", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + } + ], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"3e81e3e6d7a1b95613f7fa5850988ca2\")" + ] + } +} \ No newline at end of file diff --git a/app/schemas/xyz.appmaker.keralarescue.Room.CampDatabase/4.json b/app/schemas/xyz.appmaker.keralarescue.Room.CampDatabase/4.json new file mode 100644 index 0000000..fcc235e --- /dev/null +++ b/app/schemas/xyz.appmaker.keralarescue.Room.CampDatabase/4.json @@ -0,0 +1,125 @@ +{ + "formatVersion": 1, + "database": { + "version": 4, + "identityHash": "3e81e3e6d7a1b95613f7fa5850988ca2", + "entities": [ + { + "tableName": "camp_names", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `camp_id` INTEGER NOT NULL, `district` TEXT NOT NULL, PRIMARY KEY(`camp_id`))", + "fields": [ + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "camp_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "district", + "columnName": "district", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "camp_id" + ], + "autoGenerate": false + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "person_data", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT, `camp_id` TEXT, `age` TEXT, `gender` TEXT, `address` TEXT, `district` TEXT, `mobile` TEXT, `note` TEXT, `status` TEXT, `checkin_date` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "camped_at", + "columnName": "camp_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "age", + "columnName": "age", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "gender", + "columnName": "gender", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "address", + "columnName": "address", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "district", + "columnName": "district", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "mobile", + "columnName": "mobile", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "note", + "columnName": "note", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "syncStatus", + "columnName": "status", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "checkinDate", + "columnName": "checkin_date", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + } + ], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"3e81e3e6d7a1b95613f7fa5850988ca2\")" + ] + } +} \ No newline at end of file diff --git a/app/src/main/java/xyz/appmaker/keralarescue/Activities/FieldsActivity.java b/app/src/main/java/xyz/appmaker/keralarescue/Activities/FieldsActivity.java index 4cca3ea..f46bdbb 100644 --- a/app/src/main/java/xyz/appmaker/keralarescue/Activities/FieldsActivity.java +++ b/app/src/main/java/xyz/appmaker/keralarescue/Activities/FieldsActivity.java @@ -1,22 +1,30 @@ package xyz.appmaker.keralarescue.Activities; +import android.app.DatePickerDialog; +import android.app.Dialog; import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.support.v4.app.DialogFragment; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.Menu; import android.view.MenuItem; +import android.view.MotionEvent; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; +import android.widget.DatePicker; import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; + +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Calendar; import java.util.HashMap; import java.util.List; import retrofit2.Call; @@ -39,7 +47,7 @@ public class FieldsActivity extends AppCompatActivity { - EditText nameEdt, ageEdt, addressEdt, mobileEdt, notesEdt; + EditText nameEdt, ageEdt, addressEdt, mobileEdt, notesEdt, checkinEdit; TextView syncDetailsTextView; Spinner campNameSpn, genderSpn, districtSpn; HashMap distMap = new HashMap<>(); @@ -133,8 +141,27 @@ public void onNothingSelected(AdapterView parent) { addressEdt = (EditText) findViewById(R.id.address); mobileEdt = (EditText) findViewById(R.id.mobile); notesEdt = (EditText) findViewById(R.id.note); + checkinEdit = findViewById(R.id.checkin); + checkinEdit.setKeyListener(null); + checkinEdit.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + if (event.getAction() == MotionEvent.ACTION_UP) { + showDatePickerDialog(v); + return true; + } + return false; + } + }); + checkinEdit.setOnFocusChangeListener(new View.OnFocusChangeListener() { + @Override + public void onFocusChange(View v, boolean hasFocus) { + if (hasFocus) + showDatePickerDialog(v); + } + }); + checkinEdit.setFocusable(false); submitBtn = (Button) findViewById(R.id.submit); - submitBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -152,6 +179,7 @@ public void onClick(View v) { mobileEdt.getText().toString(), notesEdt.getText().toString(), "new", + checkinEdit.getText().toString(), "0"); insetPersonDb(personDataModel); } @@ -222,6 +250,60 @@ public void onFailure(Call call, Throwable t) { } + public static class DatePickerFragment extends DialogFragment + implements DatePickerDialog.OnDateSetListener { + private Calendar defaultDate; + private DateChangeListner dateChangeListner; + + public DatePickerFragment() { + } + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + // Use the current date as the default date in the picker + int year = defaultDate.get(Calendar.YEAR); + int month = defaultDate.get(Calendar.MONTH); + int day = defaultDate.get(Calendar.DAY_OF_MONTH); + + // Create a new instance of DatePickerDialog and return it + return new DatePickerDialog(getActivity(), this, year, month, day); + } + + public void setDefaultDate(Calendar defaultDate) { + this.defaultDate = defaultDate; + } + + public void setDateChangeListner(DateChangeListner dateChangeListner) { + this.dateChangeListner = dateChangeListner; + } + + @Override + public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { + Calendar cal = Calendar.getInstance(); + cal.set(year, monthOfYear, dayOfMonth); + if(dateChangeListner!=null) + dateChangeListner.onChange(cal); + } + } + + public interface DateChangeListner { + void onChange(Calendar newDate); + } + + private void showDatePickerDialog(View view) { + final EditText editText = (EditText) view; + DatePickerFragment newFragment = new DatePickerFragment(); + newFragment.setDefaultDate(Calendar.getInstance()); + newFragment.setDateChangeListner(new DateChangeListner() { + @Override + public void onChange(Calendar newDate) { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + editText.setText(dateFormat.format(newDate.getTime())); + } + }); + newFragment.show(getSupportFragmentManager(), "datePicker"); + } + public boolean validateData() { if (nameEdt.getText().toString().equals("")) { // || ageEdt.getText().toString().equals("") || addressEdt.getText().toString().equals("") || @@ -261,6 +343,7 @@ private void personAdded() { addressEdt.setText(""); mobileEdt.setText(""); notesEdt.setText(""); + checkinEdit.setText(""); nameEdt.requestFocus(); // nameEdt.setText(""); diff --git a/app/src/main/java/xyz/appmaker/keralarescue/Room/CampDatabase.java b/app/src/main/java/xyz/appmaker/keralarescue/Room/CampDatabase.java index 4876fbf..6f5c11e 100644 --- a/app/src/main/java/xyz/appmaker/keralarescue/Room/CampDatabase.java +++ b/app/src/main/java/xyz/appmaker/keralarescue/Room/CampDatabase.java @@ -10,7 +10,7 @@ import xyz.appmaker.keralarescue.Room.PersonData.PersonDataDao; import xyz.appmaker.keralarescue.Room.PersonData.PersonDataEntity; -@Database(entities = {CampNames.class, PersonDataEntity.class}, version = 3) +@Database(entities = {CampNames.class, PersonDataEntity.class}, version = 4) public abstract class CampDatabase extends RoomDatabase { private static CampDatabase INSTANCE; diff --git a/app/src/main/java/xyz/appmaker/keralarescue/Room/PersonData/PersonDataEntity.java b/app/src/main/java/xyz/appmaker/keralarescue/Room/PersonData/PersonDataEntity.java index 6296e17..729d573 100644 --- a/app/src/main/java/xyz/appmaker/keralarescue/Room/PersonData/PersonDataEntity.java +++ b/app/src/main/java/xyz/appmaker/keralarescue/Room/PersonData/PersonDataEntity.java @@ -47,10 +47,14 @@ public class PersonDataEntity { @ColumnInfo(name="person_status") public String personStatus = "new"; + @SerializedName("checkin_date") + @ColumnInfo(name="checkin_date") + public String checkinDate; + public PersonDataEntity() { } - public PersonDataEntity(String name, String campName, String age, String gender, String address, String district, String mobile, String note, String personStatus,String syncStatus) { + public PersonDataEntity(String name, String campName, String age, String gender, String address, String district, String mobile, String note, String personStatus,String checkinDate, String syncStatus) { this.name = name; this.camped_at = campName; this.age = age; @@ -60,6 +64,7 @@ public PersonDataEntity(String name, String campName, String age, String gender, this.mobile = mobile; this.note = note; this.personStatus = personStatus; + this.checkinDate = checkinDate; this.syncStatus = syncStatus; } diff --git a/app/src/main/res/layout/content_fields.xml b/app/src/main/res/layout/content_fields.xml index 9cf8cf5..1f49461 100644 --- a/app/src/main/res/layout/content_fields.xml +++ b/app/src/main/res/layout/content_fields.xml @@ -131,11 +131,21 @@ android:layout_marginTop="20dp" android:hint="@string/note" /> + + +