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 @@ ...@@ -3,6 +3,9 @@
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<compositeConfiguration>
<compositeBuild compositeDefinitionSource="SCRIPT" />
</compositeConfiguration>
<option name="distributionType" value="DEFAULT_WRAPPED" /> <option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules"> <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"> <component name="libraryTable">
<library name="Gradle: com.google.android.gms:play-services-basement:17.0.0@aar"> <library name="Gradle: com.google.android.gms:play-services-basement:17.0.0@aar">
<CLASSES> <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="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/17b5cdcb3e31a36e8bde86f3754af349/jetified-play-services-basement-17.0.0/res" /> <root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/5b44a467ef215ace407b0f6cf221c780/jetified-play-services-basement-17.0.0/res" />
</CLASSES> </CLASSES>
<JAVADOC> <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!/" /> <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 { ...@@ -44,7 +44,7 @@ dependencies {
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 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/activation.jar')
implementation files('libs/additionnal.jar') implementation files('libs/additionnal.jar')
implementation files('libs/mail.jar') implementation files('libs/mail.jar')
......
...@@ -18,8 +18,10 @@ ...@@ -18,8 +18,10 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> 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=".NewsFeedFound" />
<activity android:name=".ItemClaim"></activity>
<activity android:name=".MyPostsFoundRV" /> <activity android:name=".MyPostsFoundRV" />
<activity android:name=".RedirectMyPosts" /> <activity android:name=".RedirectMyPosts" />
<activity android:name=".ItemDetails" /> <activity android:name=".ItemDetails" />
......
...@@ -2,6 +2,7 @@ package com.example.instilostandfound; ...@@ -2,6 +2,7 @@ package com.example.instilostandfound;
import android.app.DatePickerDialog; import android.app.DatePickerDialog;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.ContentResolver;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
...@@ -9,31 +10,42 @@ import android.net.Uri; ...@@ -9,31 +10,42 @@ import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; 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.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.google.firebase.database.DatabaseReference; 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.StorageTask;
import com.google.firebase.storage.UploadTask;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import android.os.Handler;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.webkit.MimeTypeMap;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.DatePicker; import android.widget.DatePicker;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import java.io.Serializable; import java.io.Serializable;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
public class LostItem extends AppCompatActivity implements View.OnClickListener, Serializable { 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 title;
EditText place; EditText place;
EditText desc; EditText desc;
...@@ -55,6 +67,11 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener, ...@@ -55,6 +67,11 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener,
private boolean updatedata; private boolean updatedata;
public String tempUri; 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; DatePickerDialog.OnDateSetListener dateSetListener;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -76,19 +93,185 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener, ...@@ -76,19 +93,185 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener,
date.setOnClickListener(this); date.setOnClickListener(this);
/*FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() { if(callingclass.equals("MyPosts"))
@Override {
public void onClick(View view) { CreateFoundObject objectfound = (CreateFoundObject)getIntent().getSerializableExtra("FoundObject");
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) Log.v("desc",objectfound.getmDescription());
.setAction("Action", null).show(); 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); findViewById(R.id.submit).setOnClickListener(this);
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, items); ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, items);
category.setAdapter(adapter); 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) @RequiresApi(api = Build.VERSION_CODES.N)
public void onClick(View view) public void onClick(View view)
...@@ -96,7 +279,7 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener, ...@@ -96,7 +279,7 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener,
switch (view.getId()) switch (view.getId())
{ {
case R.id.submit: case R.id.submit:
//SubmitFound(); SubmitLost();
break; break;
case R.id.camera: case R.id.camera:
Intent intent = new Intent(); Intent intent = new Intent();
......
...@@ -71,6 +71,7 @@ public class Navigation extends AppCompatActivity implements NavigationView.OnNa ...@@ -71,6 +71,7 @@ public class Navigation extends AppCompatActivity implements NavigationView.OnNa
case R.id.post_lost: case R.id.post_lost:
intent = new Intent(Navigation.this, LostItem.class); intent = new Intent(Navigation.this, LostItem.class);
intent.putExtra("username", username); intent.putExtra("username", username);
intent.putExtra("CallingClass","Navigation");
startActivity(intent); startActivity(intent);
break; break;
case R.id.home: case R.id.home:
...@@ -97,7 +98,7 @@ public class Navigation extends AppCompatActivity implements NavigationView.OnNa ...@@ -97,7 +98,7 @@ public class Navigation extends AppCompatActivity implements NavigationView.OnNa
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()){ switch (v.getId()){
case R.id.lost_button_newsfeed: 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("type", "lost");
intent.putExtra("username", username); intent.putExtra("username", username);
startActivity(intent); startActivity(intent);
......
...@@ -23,7 +23,7 @@ public class RedirectMyPosts extends AppCompatActivity implements View.OnClickLi ...@@ -23,7 +23,7 @@ public class RedirectMyPosts extends AppCompatActivity implements View.OnClickLi
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()){ switch (v.getId()){
case R.id.lost_button: 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("type", "lost");
intent.putExtra("username", username); intent.putExtra("username", username);
startActivity(intent); startActivity(intent);
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/my_posts_rv" android:id="@+id/my_posts_rv"
android:layout_width="match_parent" 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> </androidx.recyclerview.widget.RecyclerView>
......
...@@ -4,5 +4,5 @@ ...@@ -4,5 +4,5 @@
# Location of the SDK. This is only used by Gradle. # Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the # For customization when using a Version Control System, please read the
# header note. # header note.
#Fri Nov 22 12:15:22 IST 2019 #Tue Nov 26 09:55:15 IST 2019
sdk.dir=/home/chikki/Android/Sdk 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