Commit 88051476 authored by ankitasingh's avatar ankitasingh

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	.gradle/5.4.1/executionHistory/executionHistory.bin
#	.gradle/5.4.1/executionHistory/executionHistory.lock
#	.gradle/5.4.1/fileHashes/fileHashes.bin
#	.gradle/5.4.1/fileHashes/fileHashes.lock
#	.gradle/5.4.1/javaCompile/classAnalysis.bin
#	.gradle/5.4.1/javaCompile/javaCompile.lock
#	.gradle/buildOutputCleanup/buildOutputCleanup.lock
#	.gradle/buildOutputCleanup/outputFiles.bin
#	.idea/caches/build_file_checksums.ser
#	.idea/workspace.xml
#	app/app.iml
parents 3594c48d b3b02262
......@@ -3,6 +3,9 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<compositeConfiguration>
<compositeBuild compositeDefinitionSource="SCRIPT" />
</compositeConfiguration>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
......
<component name="libraryTable">
<library name="Gradle: __local_aars__:/home/abc/AndroidStudioProjects/InstiLostAndFound/app/libs/activation.jar:unspecified@jar">
<CLASSES>
<root url="jar://$PROJECT_DIR$/app/libs/activation.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Gradle: __local_aars__:/home/abc/AndroidStudioProjects/InstiLostAndFound/app/libs/additionnal.jar:unspecified@jar">
<CLASSES>
<root url="jar://$PROJECT_DIR$/app/libs/additionnal.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Gradle: __local_aars__:/home/abc/AndroidStudioProjects/InstiLostAndFound/app/libs/mail.jar:unspecified@jar">
<CLASSES>
<root url="jar://$PROJECT_DIR$/app/libs/mail.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Gradle: com.google.android.gms:play-services-basement:17.0.0@aar">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/17b5cdcb3e31a36e8bde86f3754af349/jetified-play-services-basement-17.0.0/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/17b5cdcb3e31a36e8bde86f3754af349/jetified-play-services-basement-17.0.0/res" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/5b44a467ef215ace407b0f6cf221c780/jetified-play-services-basement-17.0.0/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/5b44a467ef215ace407b0f6cf221c780/jetified-play-services-basement-17.0.0/res" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.android.gms/play-services-basement/17.0.0/4faccf8c10bad282388a4067b8ef53d8476bbbc8/play-services-basement-17.0.0-javadoc.jar!/" />
......
......@@ -44,7 +44,7 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha09'
// implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha09'
implementation files('libs/activation.jar')
implementation files('libs/additionnal.jar')
implementation files('libs/mail.jar')
......
......@@ -18,8 +18,10 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ItemClaim"></activity>
<activity android:name=".NewsFeedLost"></activity>
<activity android:name=".MyPostsLostRV" />
<activity android:name=".NewsFeedFound" />
<activity android:name=".ItemClaim"></activity>
<activity android:name=".MyPostsFoundRV" />
<activity android:name=".RedirectMyPosts" />
<activity android:name=".ItemDetails" />
......
......@@ -2,6 +2,7 @@ package com.example.instilostandfound;
import android.app.DatePickerDialog;
import android.app.ProgressDialog;
import android.content.ContentResolver;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
......@@ -9,31 +10,42 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.StorageTask;
import com.google.firebase.storage.UploadTask;
import com.squareup.picasso.Picasso;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.os.Handler;
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.Serializable;
import java.util.Calendar;
import java.util.Date;
public class LostItem extends AppCompatActivity implements View.OnClickListener, Serializable {
private static final String TAG = FoundItem.class.getSimpleName(); ;
private static final String TAG = LostItem.class.getSimpleName(); ;
EditText title;
EditText place;
EditText desc;
......@@ -55,6 +67,11 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener,
private boolean updatedata;
public String tempUri;
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = FirebaseDatabase.getInstance().getReference("LostData");
StorageReference mStorage = FirebaseStorage.getInstance().getReference("Images");
FirebaseStorage mStorageRef = FirebaseStorage.getInstance();
DatePickerDialog.OnDateSetListener dateSetListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -76,19 +93,185 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener,
date.setOnClickListener(this);
/*FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});*/
if(callingclass.equals("MyPosts"))
{
CreateFoundObject objectfound = (CreateFoundObject)getIntent().getSerializableExtra("FoundObject");
Log.v("desc",objectfound.getmDescription());
title.setText(objectfound.getmTitle());
place.setText(objectfound.getmLocation());
desc.setText(objectfound.getmDescription());
date.setText(objectfound.getmDateFound());
Picasso.with(LostItem.this).load(objectfound.getImageUrl())
.fit()
.centerCrop()
.into(camera);
}
findViewById(R.id.submit).setOnClickListener(this);
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, items);
category.setAdapter(adapter);
}
private void SubmitLost() {
final String Title = title.getText().toString().trim();
final String Place = place.getText().toString().trim();
final String Desc = desc.getText().toString().trim();
final String Date = date.getText().toString().trim();
updatedata = false;
if (title.getText().toString().trim().isEmpty()) {
title.setError("Please enter title");
title.requestFocus();
return;
}
if (place.toString().trim().isEmpty()) {
place.setError("Please enter location");
place.requestFocus();
return;
}
if(callingclass.equals("MyPosts"))
{
final CreateFoundObject objectfound = (CreateFoundObject)getIntent().getSerializableExtra("LostObject");
if(objectfound.getImageUrl().equals("NO-IMAGE"))
{
myRef.child(objectfound.getKey()).removeValue();
Toast.makeText(LostItem.this, "Item Updated", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(LostItem.this, MyPostsFoundRV.class);
intent.putExtra("username", username);
startActivity(intent);
finish();
}
else
{
StorageReference imageRef = mStorageRef.getReferenceFromUrl(objectfound.getImageUrl());
tempUri = objectfound.getImageUrl();
updatedata = true;
imageRef.delete().addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
myRef.child(objectfound.getKey()).removeValue();
Toast.makeText(LostItem.this, "Item Updated", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(LostItem.this, MyPostsFoundRV.class);
intent.putExtra("username", username);
startActivity(intent);
finish();
}
});
}
}
if (mImageUri != null ) {
pd.show();
final StorageReference fileReference = mStorage.child(System.currentTimeMillis()
+ "." + getExtension(mImageUri));
mUploadTask = fileReference.putFile(mImageUri)
.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
}
}, 500);
mImageUri = null;
Toast.makeText(LostItem.this, "Upload successful", Toast.LENGTH_LONG).show();
taskSnapshot.getMetadata().getReference().getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
uploadSessionUri = uri;
CreateFoundObject upload;
java.util.Date datef = new Date();
if(updatedata)
{
upload = new CreateFoundObject(username,Title ,tempUri,Place, Desc,
"category", Date,"lost");
}
else {
upload = new CreateFoundObject(username, Title, uri.toString(), Place, Desc,
"category",Date, "lost");
}
String uploadId = myRef.push().getKey();
Log.v("UploadID", uploadId);
myRef.child(uploadId).setValue(upload);
title.setText("");
place.setText("");
desc.setText("");
date.setText("");
pd.dismiss();
Toast.makeText(LostItem.this,"SUBMIT SUCCESSFUL",Toast.LENGTH_LONG).show();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(LostItem.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(LostItem.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
} else {
Date datef = new Date();
Toast.makeText(LostItem.this, "No file selected", Toast.LENGTH_SHORT).show();
CreateFoundObject upload = new CreateFoundObject(username,Title ,"NO-IMAGE","location", Desc,
"category", Date,"lost");
String uploadId = myRef.push().getKey();
Log.v("UploadID", uploadId);
myRef.child(uploadId).setValue(upload);
title.setText("");
place.setText("");
desc.setText("");
date.setText("");
Toast.makeText(LostItem.this,"SUBMIT SUCCESSFUL -NO IMAGE UPLOADED!",Toast.LENGTH_LONG).show();
Intent intent = new Intent(LostItem.this, MyPostsLostRV.class);
intent.putExtra("username", username);
startActivity(intent);
finish();
}
// String uploadurl = uploadSessionUri.toString();
// Log.v("Upload url",uploadurl);
/* 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();*/
}
private String getExtension(Uri uri)
{
ContentResolver cr = getContentResolver();
MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
return mimeTypeMap.getExtensionFromMimeType(cr.getType(uri));
}
@RequiresApi(api = Build.VERSION_CODES.N)
public void onClick(View view)
......@@ -96,7 +279,7 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener,
switch (view.getId())
{
case R.id.submit:
//SubmitFound();
SubmitLost();
break;
case R.id.camera:
Intent intent = new Intent();
......
......@@ -71,6 +71,7 @@ public class Navigation extends AppCompatActivity implements NavigationView.OnNa
case R.id.post_lost:
intent = new Intent(Navigation.this, LostItem.class);
intent.putExtra("username", username);
intent.putExtra("CallingClass","Navigation");
startActivity(intent);
break;
case R.id.home:
......@@ -97,7 +98,7 @@ public class Navigation extends AppCompatActivity implements NavigationView.OnNa
public void onClick(View v) {
switch (v.getId()){
case R.id.lost_button_newsfeed:
Intent intent = new Intent(Navigation.this, MyPosts.class);
Intent intent = new Intent(Navigation.this, NewsFeedLost.class);
intent.putExtra("type", "lost");
intent.putExtra("username", username);
startActivity(intent);
......
......@@ -23,7 +23,7 @@ public class RedirectMyPosts extends AppCompatActivity implements View.OnClickLi
public void onClick(View v) {
switch (v.getId()){
case R.id.lost_button:
Intent intent = new Intent(RedirectMyPosts.this, MyPosts.class);
Intent intent = new Intent(RedirectMyPosts.this, MyPostsLostRV.class);
intent.putExtra("type", "lost");
intent.putExtra("username", username);
startActivity(intent);
......
......@@ -9,7 +9,9 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/my_posts_rv"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true">
</androidx.recyclerview.widget.RecyclerView>
......
......@@ -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.
#Fri Nov 22 12:15:22 IST 2019
sdk.dir=/home/chikki/Android/Sdk
#Tue Nov 26 09:55:15 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