Commit bee5f9cd authored by MUDRA SAHU's avatar MUDRA SAHU

date feature

parent 4cb4265b
......@@ -18,7 +18,7 @@ public class CreateFoundObject implements Serializable {
private String mDescription;
private String mLocation;
private String mCategory;
private Date mDateFound;
private String mDateFound;
private String mtype;
public CreateFoundObject() {
......@@ -26,7 +26,7 @@ public class CreateFoundObject implements Serializable {
}
public CreateFoundObject(String LDAPID,String title ,String imageUrl, String location, String desc,
String category, Date datefound,String type) {
String category, String datefound,String type) {
if (LDAPID.trim().equals("")) {
mLDAP = "No Name";
}
......@@ -76,9 +76,9 @@ public class CreateFoundObject implements Serializable {
public void setmCategory(String category)
{ mCategory = category; }
public Date getmDateFound()
public String getmDateFound()
{ return mDateFound; }
public void setmDateFound(Date dateFound)
public void setmDateFound(String dateFound)
{ mDateFound = dateFound; }
public String getmDescription()
......
......@@ -13,6 +13,8 @@ import com.google.firebase.storage.UploadTask;
import android.Manifest;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.ContentResolver;
import android.content.Context;
......@@ -20,6 +22,8 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.icu.text.SimpleDateFormat;
import android.net.Uri;
import android.os.Build;
......@@ -43,9 +47,11 @@ import android.util.Log;
import android.view.View;
import android.webkit.MimeTypeMap;
import android.widget.ArrayAdapter;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import java.io.ByteArrayOutputStream;
......@@ -55,17 +61,19 @@ import java.io.IOException;
import java.io.Serializable;
import java.net.URI;
import java.net.URL;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;
//import static android.app.Activity.RESULT_OK;
//import com.squareup.picasso.Picasso;
public class FoundItem extends AppCompatActivity implements View.OnClickListener, Serializable {
private static final String TAG = FoundItem.class.getSimpleName(); ;
//private FirebaseAuth mAuth;
EditText title;
EditText place;
EditText desc;
EditText date;
TextView date;
Spinner category;
String username;
ImageView camera;
......@@ -83,7 +91,7 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener
private boolean updatedata;
public String tempUri;
DatePickerDialog.OnDateSetListener dateSetListener;
// ...
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = FirebaseDatabase.getInstance().getReference("FoundData");
......@@ -109,6 +117,7 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener
pd = new ProgressDialog(this);
pd.setMessage("Uploading....");
date.setOnClickListener(this);
if(callingclass.equals("MyPosts"))
{
CreateFoundObject objectfound = (CreateFoundObject)getIntent().getSerializableExtra("FoundObject");
......@@ -116,7 +125,7 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener
title.setText(objectfound.getmTitle());
place.setText(objectfound.getmLocation());
desc.setText(objectfound.getmDescription());
date.setText(objectfound.getDate());
date.setText(objectfound.getmDateFound());
Picasso.with(FoundItem.this).load(objectfound.getImageUrl())
.fit()
.centerCrop()
......@@ -208,12 +217,12 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener
Date datef = new Date();
if(updatedata)
{
upload = new CreateFoundObject(username,Title ,tempUri,"location", Desc,
"category", datef,"found");
upload = new CreateFoundObject(username,Title ,tempUri,Place, Desc,
"category", Date,"found");
}
else {
upload = new CreateFoundObject(username, Title, uri.toString(), "location", Desc,
"category", datef, "found");
upload = new CreateFoundObject(username, Title, uri.toString(), Place, Desc,
"category",Date, "found");
}
String uploadId = myRef.push().getKey();
Log.v("UploadID", uploadId);
......@@ -250,7 +259,7 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener
Date datef = new Date();
Toast.makeText(FoundItem.this, "No file selected", Toast.LENGTH_SHORT).show();
CreateFoundObject upload = new CreateFoundObject(username,Title ,"NO-IMAGE","location", Desc,
"category", datef,"found");
"category", Date,"found");
String uploadId = myRef.push().getKey();
Log.v("UploadID", uploadId);
myRef.child(uploadId).setValue(upload);
......@@ -305,8 +314,33 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener
intent.setAction(Intent.ACTION_PICK);
startActivityForResult(Intent.createChooser(intent, "Select Image"), PICK_IMAGE_REQUEST);
break;
case R.id.date:
Calendar cal= Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH);
int day = cal.get(Calendar.DAY_OF_MONTH);
DatePickerDialog dialog = new DatePickerDialog(FoundItem.this
,android.R.style.Theme_Black,
dateSetListener, year, month, day);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.show();
dateSetListener = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datePicker, int year, int month, int day) {
month = month +1;
Log.d(TAG,"onDateSet: mm/dd/yyy: "+ month + "/" + day +"/" +year);
String dt= month+"/"+day+"/"+year;
date.setText(dt);
}
};
break;
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
......
package com.example.instilostandfound;
import android.app.DatePickerDialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.storage.StorageTask;
import com.squareup.picasso.Picasso;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
public class LostItem extends AppCompatActivity {
import java.io.Serializable;
import java.util.Calendar;
public class LostItem extends AppCompatActivity implements View.OnClickListener, Serializable {
private static final String TAG = FoundItem.class.getSimpleName(); ;
EditText title;
EditText place;
EditText desc;
TextView date;
Spinner category;
String username;
ImageView camera;
String[] items = new String[]{"Others","Electronics", "Documents", "Clothes"};
private static final int CAMERA_REQUEST = 1888;
private ImageView imageView;
private static final int MY_CAMERA_PERMISSION_CODE = 100;
private DatabaseReference mDatabase;
public Uri mImageUri;
public Uri uploadSessionUri;
int PICK_IMAGE_REQUEST = 111;
public String callingclass;
ProgressDialog pd;
private StorageTask mUploadTask;
private boolean updatedata;
public String tempUri;
DatePickerDialog.OnDateSetListener dateSetListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lost_item);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
username = getIntent().getStringExtra("username");
callingclass = getIntent().getStringExtra("CallingClass");
title = findViewById(R.id.title);
place = findViewById(R.id.place);
desc = findViewById(R.id.desc);
date = findViewById(R.id.date);
category = findViewById(R.id.category);
camera = findViewById(R.id.camera);
camera.setOnClickListener(this);
pd = new ProgressDialog(this);
pd.setMessage("Uploading....");
date.setOnClickListener(this);
/*FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
......@@ -27,6 +84,71 @@ public class LostItem extends AppCompatActivity {
.setAction("Action", null).show();
}
});*/
findViewById(R.id.submit).setOnClickListener(this);
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, items);
category.setAdapter(adapter);
}
@RequiresApi(api = Build.VERSION_CODES.N)
public void onClick(View view)
{
switch (view.getId())
{
case R.id.submit:
//SubmitFound();
break;
case R.id.camera:
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_PICK);
startActivityForResult(Intent.createChooser(intent, "Select Image"), PICK_IMAGE_REQUEST);
break;
case R.id.date:
Calendar cal= Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH);
int day = cal.get(Calendar.DAY_OF_MONTH);
DatePickerDialog dialog = new DatePickerDialog(LostItem.this
,android.R.style.Theme_Black,
dateSetListener, year, month, day);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.show();
dateSetListener = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datePicker, int year, int month, int day) {
month = month +1;
Log.d(TAG,"onDateSet: mm/dd/yyy: "+ month + "/" + day +"/" +year);
String dt= month+"/"+day+"/"+year;
date.setText(dt);
}
};
break;
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) {
mImageUri = data.getData();
try {
//getting image from gallery
//Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), mImageUri);
//Setting image to ImageView
//camera.setImageBitmap(bitmap);
Picasso.with(LostItem.this).load(mImageUri)
.fit()
.centerCrop()
.into(camera);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LostItem">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="192dp"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/camera"
android:src="@drawable/cameraup"
android:minWidth="80dp"
android:minHeight="100dp"
/>
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</com.google.android.material.appbar.AppBarLayout>
<include layout="@layout/content_lost_item" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<!--<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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"
......@@ -30,4 +66,4 @@
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@android:drawable/ic_dialog_email" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file
</androidx.coordinatorlayout.widget.CoordinatorLayout>-->
......@@ -7,8 +7,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".LostItem"
tools:showIn="@layout/activity_lost_item"
tools:context=".FoundItem"
tools:showIn="@layout/activity_found_item"
android:paddingLeft= "@dimen/activity_horizontal_margin"
android:paddingRight = "@dimen/activity_horizontal_margin"
android:paddingTop = "@dimen/activity_vertical_margin"
......@@ -85,7 +85,7 @@
android:background="@color/colorPrimary"
/>
<EditText
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
<?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"
......@@ -15,16 +16,6 @@
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/camera"
android:src="@drawable/camera"
android:minWidth="80dp"
android:minHeight="80dp"
android:layout_marginTop = "40dp"
android:layout_marginLeft="40dp"
/>
<Spinner
android:id="@+id/category"
android:layout_width="match_parent"
......@@ -32,7 +23,7 @@
android:layout_below = "@+id/camera"
android:background="@android:drawable/btn_dropdown"
android:spinnerMode="dropdown"
android:layout_marginTop = "20dp"
android:layout_marginTop = "15dp"
android:layout_alignParentLeft = "true"
android:layout_alignParentStart = "true"
android:layout_alignParentRight = "true"
......@@ -40,12 +31,12 @@
<EditText
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:id = "@+id/TITLE"
android:id = "@+id/title"
android:hint = "@string/title"
android:focusable = "true"
android:textColorHighlight = "#ff7eff15"
android:textColorHint = "@color/hint_color"
android:layout_marginTop = "20dp"
android:layout_marginTop = "15dp"
android:layout_below = "@+id/category"
android:layout_alignParentLeft = "true"
android:layout_alignParentStart = "true"
......@@ -55,13 +46,13 @@
<EditText
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:id = "@+id/PLACE"
android:id = "@+id/place"
android:hint = "@string/place"
android:focusable = "true"
android:textColorHighlight = "#ff7eff15"
android:textColorHint = "@color/hint_color"
android:layout_marginTop = "20dp"
android:layout_below = "@+id/TITLE"
android:layout_marginTop = "15dp"
android:layout_below = "@+id/title"
android:layout_alignParentLeft = "true"
android:layout_alignParentStart = "true"
android:layout_alignParentRight = "true"
......@@ -69,7 +60,7 @@
<EditText
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:id = "@+id/DESC"
android:id = "@+id/desc"
android:hint = "@string/desc"
android:focusable = "true"
android:ems="10"
......@@ -77,8 +68,8 @@
android:inputType="textMultiLine"
android:textColorHighlight = "#ff7eff15"
android:textColorHint = "@color/hint_color"
android:layout_marginTop = "20dp"
android:layout_below = "@+id/PLACE"
android:layout_marginTop = "15dp"
android:layout_below = "@+id/place"
android:layout_alignParentLeft = "true"
android:layout_alignParentStart = "true"
android:layout_alignParentRight = "true"
......@@ -92,21 +83,134 @@
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@color/colorPrimary"
android:layout_marginBottom = "40dp"
/>
<EditText
android:id="@+id/DATE"
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="date"
android:hint = "@string/date"
android:layout_below = "@+id/DESC"
android:layout_marginTop = "20dp"
android:layout_below = "@+id/desc"
android:layout_marginTop = "15dp"
android:layout_alignParentLeft = "true"
android:layout_alignParentStart = "true"
android:layout_alignParentRight = "true"
android:layout_alignParentEnd = "true"/>
</RelativeLayout>
<!--<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".LostItem"
tools:showIn="@layout/activity_lost_item"
android:paddingLeft= "@dimen/activity_horizontal_margin"
android:paddingRight = "@dimen/activity_horizontal_margin"
android:paddingTop = "@dimen/activity_vertical_margin"
android:paddingBottom = "@dimen/activity_vertical_margin"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/camera"
android:src="@drawable/camera"
android:minWidth="80dp"
android:minHeight="80dp"
android:layout_marginTop = "40dp"
android:layout_marginLeft="40dp"
/>
<Spinner
android:id="@+id/category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below = "@+id/camera"
android:background="@android:drawable/btn_dropdown"
android:spinnerMode="dropdown"
android:layout_marginTop = "20dp"
android:layout_alignParentLeft = "true"
android:layout_alignParentStart = "true"
android:layout_alignParentRight = "true"
android:layout_alignParentEnd = "true"/>
<EditText
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:id = "@+id/TITLE"
android:hint = "@string/title"
android:focusable = "true"
android:textColorHighlight = "#ff7eff15"
android:textColorHint = "@color/hint_color"
android:layout_marginTop = "20dp"
android:layout_below = "@+id/category"
android:layout_alignParentLeft = "true"
android:layout_alignParentStart = "true"
android:layout_alignParentRight = "true"
android:layout_alignParentEnd = "true"
/>
<EditText
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:id = "@+id/PLACE"
android:hint = "@string/place"
android:focusable = "true"
android:textColorHighlight = "#ff7eff15"
android:textColorHint = "@color/hint_color"
android:layout_marginTop = "20dp"
android:layout_below = "@+id/TITLE"
android:layout_alignParentLeft = "true"
android:layout_alignParentStart = "true"
android:layout_alignParentRight = "true"
android:layout_alignParentEnd = "true" />
<EditText
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:id = "@+id/DESC"
android:hint = "@string/desc"
android:focusable = "true"
android:ems="10"
android:gravity="start|top"
android:inputType="textMultiLine"
android:textColorHighlight = "#ff7eff15"
android:textColorHint = "@color/hint_color"
android:layout_marginTop = "20dp"
android:layout_below = "@+id/PLACE"
android:layout_alignParentLeft = "true"
android:layout_alignParentStart = "true"
android:layout_alignParentRight = "true"
android:layout_alignParentEnd = "true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/submit"
android:id="@+id/submit"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@color/colorPrimary"
android:layout_marginBottom = "40dp"
/>
<EditText
android:id="@+id/DATE"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="date"
android:hint = "@string/date"
android:layout_below = "@+id/DESC"
android:layout_marginTop = "20dp"
android:layout_alignParentLeft = "true"
android:layout_alignParentStart = "true"
android:layout_alignParentRight = "true"
android:layout_alignParentEnd = "true"/>
</RelativeLayout>
\ No newline at end of file
</RelativeLayout>-->
......@@ -4,5 +4,5 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Tue Nov 05 08:12:27 IST 2019
sdk.dir=/home/chikki/Android/Sdk
#Wed Nov 06 11:55:27 IST 2019
sdk.dir=/home/abc/Android/Sdk
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment