Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
InstiLostAndFound
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
MUTTINENI NAVYA
InstiLostAndFound
Commits
8b32ffc8
Commit
8b32ffc8
authored
Oct 29, 2019
by
ankitasingh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added basic code for pushing data to DB
parent
eb4f27bf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
79 deletions
+38
-79
app/src/main/java/com/example/instilostandfound/FoundItem.java
...rc/main/java/com/example/instilostandfound/FoundItem.java
+32
-73
app/src/main/java/com/example/instilostandfound/createDemo.java
...c/main/java/com/example/instilostandfound/createDemo.java
+4
-4
local.properties
local.properties
+2
-2
No files found.
app/src/main/java/com/example/instilostandfound/FoundItem.java
View file @
8b32ffc8
package
com.example.instilostandfound
;
import
com.example.instilostandfound.R
;
import
com.google.android.gms.tasks.OnFailureListener
;
import
com.google.android.gms.tasks.OnSuccessListener
;
import
com.google.firebase.auth.FirebaseAuth
;
import
com.google.firebase.database.DatabaseReference
;
import
com.google.firebase.database.FirebaseDatabase
;
...
...
@@ -31,7 +33,9 @@ import androidx.appcompat.widget.Toolbar;
import
androidx.core.content.FileProvider
;
import
android.os.Environment
;
import
android.os.Handler
;
import
android.provider.MediaStore
;
import
android.util.Log
;
import
android.view.View
;
import
android.webkit.MimeTypeMap
;
import
android.widget.ArrayAdapter
;
...
...
@@ -53,11 +57,12 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener
EditText
desc
;
EditText
date
;
Spinner
category
;
String
username
;
ImageView
camera
;
String
[]
items
=
new
String
[]{
"Others"
,
"Electronic"
,
"2"
,
"three"
};
/*
static final int REQUEST_IMAGE_CAPTURE = 1;
static
final
int
REQUEST_IMAGE_CAPTURE
=
1
;
private
static
final
int
REQUEST_CAMERARESULT
=
201
;
private static final int PICK_IMAGE_REQUEST = 1;
*/
private
static
final
int
PICK_IMAGE_REQUEST
=
1
;
private
static
final
int
CAMERA_REQUEST
=
1888
;
private
ImageView
imageView
;
private
static
final
int
MY_CAMERA_PERMISSION_CODE
=
100
;
...
...
@@ -69,7 +74,8 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener
// ...
FirebaseDatabase
database
=
FirebaseDatabase
.
getInstance
();
DatabaseReference
myRef
=
database
.
getReference
(
"FoundData"
);
//DatabaseReference myRef = database.getReference("/FoundData/");
DatabaseReference
myRef
=
FirebaseDatabase
.
getInstance
().
getReference
(
"FoundData"
);
@Override
...
...
@@ -78,6 +84,7 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener
setContentView
(
R
.
layout
.
activity_found_item
);
Toolbar
toolbar
=
findViewById
(
R
.
id
.
toolbar
);
setSupportActionBar
(
toolbar
);
username
=
getIntent
().
getStringExtra
(
"username"
);
title
=
findViewById
(
R
.
id
.
title
);
place
=
findViewById
(
R
.
id
.
place
);
desc
=
findViewById
(
R
.
id
.
desc
);
...
...
@@ -97,88 +104,40 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener
ArrayAdapter
<
String
>
adapter
=
new
ArrayAdapter
<>(
this
,
android
.
R
.
layout
.
simple_spinner_dropdown_item
,
items
);
category
.
setAdapter
(
adapter
);
}
/*
private void openFileChooser() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, PICK_IMAGE_REQUEST);
}
@Override
public 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();
//cropImage();
Picasso.with(getActivity()).load(mImageUri).into(mImageView);
}
}
private String getFileExtension(Uri uri) {
ContentResolver cR = getActivity().getContentResolver();
MimeTypeMap mime = MimeTypeMap.getSingleton();
return mime.getExtensionFromMimeType(cR.getType(uri));
}*/
private
void
SubmitFound
()
{
String
Title
=
title
.
getText
().
toString
().
trim
();
String
Place
=
place
.
getText
().
toString
().
trim
();
String
Desc
=
desc
.
getText
().
toString
().
trim
();
String
Date
=
date
.
getText
().
toString
().
trim
();
Toast
.
makeText
(
FoundItem
.
this
,
"SUBMIT SUCCESSFUL"
,
Toast
.
LENGTH_LONG
).
show
();
}
/*
private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
if
(
title
.
getText
().
toString
().
trim
().
isEmpty
())
{
title
.
setError
(
"Please enter title"
);
title
.
requestFocus
();
return
;
}
}*/
/*
String currentPhotoPath;
@RequiresApi(api = Build.VERSION_CODES.N)
private File createImageFile() throws IOException {
// Create an image file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
File image = File.createTempFile(
imageFileName,
".jpg",
storageDir
);
// Save a file: path for use with ACTION_VIEW intents
currentPhotoPath = image.getAbsolutePath();
return image;
}
static final int REQUEST_TAKE_PHOTO = 1;
@RequiresApi(api = Build.VERSION_CODES.N)
private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// Ensure that there's a camera activity to handle the intent
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
// Create the File where the photo should go
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException ex) {
// Error occurred while creating the File
System.out.println(ex);
}
// Continue only if the File was successfully created
if (photoFile != null) {
Uri photoURI = FileProvider.getUriForFile(this,"com.example.instilostandfound.fileprovider", photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
if
(
place
.
toString
().
trim
().
isEmpty
())
{
place
.
setError
(
"Please enter location"
);
place
.
requestFocus
();
return
;
}
createDemo
upload
=
new
createDemo
(
username
,
Title
,
Desc
,
Place
,
Date
);
String
uploadId
=
myRef
.
push
().
getKey
();
Log
.
v
(
"UploadID"
,
uploadId
);
myRef
.
child
(
uploadId
).
setValue
(
upload
);
title
.
setText
(
""
);
place
.
setText
(
""
);
desc
.
setText
(
""
);
Toast
.
makeText
(
FoundItem
.
this
,
"SUBMIT SUCCESSFUL"
,
Toast
.
LENGTH_LONG
).
show
();
}
}*/
@Override
public
void
onRequestPermissionsResult
(
int
requestCode
,
@NonNull
String
[]
permissions
,
@NonNull
int
[]
grantResults
)
{
...
...
app/src/main/java/com/example/instilostandfound/createDemo.java
View file @
8b32ffc8
...
...
@@ -15,14 +15,14 @@ public class createDemo {
private
String
mDescription
;
private
String
mLocation
;
// private String mCategory;
private
Date
mDateFound
;
private
String
mDateFound
;
public
createDemo
()
{
}
public
createDemo
(
String
LDAPID
,
String
title
,
String
desc
,
String
location
,
Date
datefound
)
{
String
datefound
)
{
if
(
LDAPID
.
trim
().
equals
(
""
))
{
mLDAP
=
"No Name"
;
}
...
...
@@ -59,9 +59,9 @@ public class createDemo {
public
Date
getmDateFound
()
public
String
getmDateFound
()
{
return
mDateFound
;
}
public
void
setmDateFound
(
Date
dateFound
)
public
void
setmDateFound
(
String
dateFound
)
{
mDateFound
=
dateFound
;
}
public
String
getmDescription
()
...
...
local.properties
View file @
8b32ffc8
...
...
@@ -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.
#
Mon Oct 28 13:39:36
IST 2019
sdk.dir
=
/home/
abc
/Android/Sdk
#
Tue Oct 29 11:38:34
IST 2019
sdk.dir
=
/home/
chikki
/Android/Sdk
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment