diff --git a/.gradle/7.0.2/executionHistory/executionHistory.bin b/.gradle/7.0.2/executionHistory/executionHistory.bin
index 65fd5af..df1a5d9 100644
Binary files a/.gradle/7.0.2/executionHistory/executionHistory.bin and b/.gradle/7.0.2/executionHistory/executionHistory.bin differ
diff --git a/.gradle/7.0.2/executionHistory/executionHistory.lock b/.gradle/7.0.2/executionHistory/executionHistory.lock
index 9864263..040f676 100644
Binary files a/.gradle/7.0.2/executionHistory/executionHistory.lock and b/.gradle/7.0.2/executionHistory/executionHistory.lock differ
diff --git a/.gradle/7.0.2/fileHashes/fileHashes.bin b/.gradle/7.0.2/fileHashes/fileHashes.bin
index bb3597d..3e7f5e2 100644
Binary files a/.gradle/7.0.2/fileHashes/fileHashes.bin and b/.gradle/7.0.2/fileHashes/fileHashes.bin differ
diff --git a/.gradle/7.0.2/fileHashes/fileHashes.lock b/.gradle/7.0.2/fileHashes/fileHashes.lock
index c0a554a..3a5c263 100644
Binary files a/.gradle/7.0.2/fileHashes/fileHashes.lock and b/.gradle/7.0.2/fileHashes/fileHashes.lock differ
diff --git a/.gradle/7.0.2/fileHashes/resourceHashesCache.bin b/.gradle/7.0.2/fileHashes/resourceHashesCache.bin
index d56a0ec..b29da9e 100644
Binary files a/.gradle/7.0.2/fileHashes/resourceHashesCache.bin and b/.gradle/7.0.2/fileHashes/resourceHashesCache.bin differ
diff --git a/.gradle/7.0.2/javaCompile/classAnalysis.bin b/.gradle/7.0.2/javaCompile/classAnalysis.bin
index d468772..b3b8b9c 100644
Binary files a/.gradle/7.0.2/javaCompile/classAnalysis.bin and b/.gradle/7.0.2/javaCompile/classAnalysis.bin differ
diff --git a/.gradle/7.0.2/javaCompile/jarAnalysis.bin b/.gradle/7.0.2/javaCompile/jarAnalysis.bin
index c63011e..bd15719 100644
Binary files a/.gradle/7.0.2/javaCompile/jarAnalysis.bin and b/.gradle/7.0.2/javaCompile/jarAnalysis.bin differ
diff --git a/.gradle/7.0.2/javaCompile/javaCompile.lock b/.gradle/7.0.2/javaCompile/javaCompile.lock
index 3ce0522..6eeb140 100644
Binary files a/.gradle/7.0.2/javaCompile/javaCompile.lock and b/.gradle/7.0.2/javaCompile/javaCompile.lock differ
diff --git a/.gradle/7.0.2/javaCompile/taskHistory.bin b/.gradle/7.0.2/javaCompile/taskHistory.bin
index 2471cde..e299480 100644
Binary files a/.gradle/7.0.2/javaCompile/taskHistory.bin and b/.gradle/7.0.2/javaCompile/taskHistory.bin differ
diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
index 1fe6ff4..8e6ae90 100644
Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin
index 25d6cce..439efdb 100644
Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ
diff --git a/.gradle/checksums/checksums.lock b/.gradle/checksums/checksums.lock
index ad07a3a..14870be 100644
Binary files a/.gradle/checksums/checksums.lock and b/.gradle/checksums/checksums.lock differ
diff --git a/.gradle/checksums/sha1-checksums.bin b/.gradle/checksums/sha1-checksums.bin
index 15cac2a..456fe9a 100644
Binary files a/.gradle/checksums/sha1-checksums.bin and b/.gradle/checksums/sha1-checksums.bin differ
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 526b4c2..35ffc65 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -7,6 +7,7 @@
+
-
+
diff --git a/.idea/modules/app/mobilprog.app.iml b/.idea/modules/app/mobilprog.app.iml
index 5205e1b..89dbfe7 100644
--- a/.idea/modules/app/mobilprog.app.iml
+++ b/.idea/modules/app/mobilprog.app.iml
@@ -30,9 +30,11 @@
+
+
diff --git a/app/src/main/java/com/example/mobilprog/MainActivity.java b/app/src/main/java/com/example/mobilprog/MainActivity.java
index d70d043..b633f44 100644
--- a/app/src/main/java/com/example/mobilprog/MainActivity.java
+++ b/app/src/main/java/com/example/mobilprog/MainActivity.java
@@ -1,22 +1,13 @@
package com.example.mobilprog;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.core.app.ActivityCompat;
-import androidx.core.content.FileProvider;
-
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.pm.PackageManager;
-import android.graphics.Bitmap;
-import android.location.Location;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
-import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
@@ -24,28 +15,23 @@
import android.widget.ProgressBar;
import android.widget.Toast;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.app.ActivityCompat;
+import androidx.core.content.FileProvider;
+
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
-import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.tasks.CancellationTokenSource;
-import com.google.android.gms.tasks.OnFailureListener;
-import com.google.android.gms.tasks.OnSuccessListener;
-import com.google.android.gms.tasks.Task;
import com.google.firebase.storage.FirebaseStorage;
-import com.google.firebase.storage.ListResult;
-import com.google.firebase.storage.OnProgressListener;
import com.google.firebase.storage.StorageMetadata;
import com.google.firebase.storage.StorageReference;
-import com.google.firebase.storage.UploadTask;
-import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
-import java.util.SimpleTimeZone;
-import java.util.UUID;
public class MainActivity extends AppCompatActivity {
@@ -83,6 +69,7 @@ public void onMap(View view) {
startActivity(i);
}
+ @SuppressWarnings("deprecation")
public void onImage(View view) {
Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (i.resolveActivity(getPackageManager()) != null) {
@@ -110,29 +97,18 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten
StorageReference ref = storageReference.child("Images/" + f.getName());
ref.putFile(Uri.fromFile(f))
- .addOnProgressListener(new OnProgressListener() {
- @Override
- public void onProgress(@NonNull UploadTask.TaskSnapshot snapshot) {
- double progress = (100.0 * snapshot.getBytesTransferred()) / snapshot.getTotalByteCount();
- progressBar.setVisibility(View.VISIBLE);
- progressBar.setProgress((int) progress);
- }
+ .addOnProgressListener(snapshot -> {
+ double progress = (100.0 * snapshot.getBytesTransferred()) / snapshot.getTotalByteCount();
+ progressBar.setVisibility(View.VISIBLE);
+ progressBar.setProgress((int) progress);
})
- .addOnSuccessListener(new OnSuccessListener() {
- @Override
- public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
- progressBar.setVisibility(View.INVISIBLE);
- Toast.makeText(MainActivity.this, "Image Uploaded!", Toast.LENGTH_SHORT).show();
- loadImages();
- createLocationMetadata(ref);
- }
- })
- .addOnFailureListener(new OnFailureListener() {
- @Override
- public void onFailure(@NonNull Exception e) {
- Toast.makeText(MainActivity.this, "Failed " + e.getMessage(), Toast.LENGTH_LONG).show();
- }
+ .addOnSuccessListener(taskSnapshot -> {
+ progressBar.setVisibility(View.INVISIBLE);
+ Toast.makeText(MainActivity.this, "Image Uploaded!", Toast.LENGTH_SHORT).show();
+ loadImages();
+ createLocationMetadata(ref);
})
+ .addOnFailureListener(e -> Toast.makeText(MainActivity.this, "Failed " + e.getMessage(), Toast.LENGTH_LONG).show())
;
}
}
@@ -140,31 +116,18 @@ public void onFailure(@NonNull Exception e) {
private void loadImages() {
gallery.removeAllViews();
listRef.listAll()
- .addOnSuccessListener(new OnSuccessListener() {
- @Override
- public void onSuccess(ListResult listResult) {
- for (StorageReference item : listResult.getItems()) {
- ImageView imageView = new ImageView(getApplicationContext());
- GlideApp.with(getApplicationContext()).load(item).into(imageView);
-
- imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
- imageView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- openImage(item.getPath());
- }
- });
-
- gallery.addView(imageView, ViewGroup.LayoutParams.MATCH_PARENT, 700);
- }
+ .addOnSuccessListener(listResult -> {
+ for (StorageReference item : listResult.getItems()) {
+ ImageView imageView = new ImageView(getApplicationContext());
+ GlideApp.with(getApplicationContext()).load(item).into(imageView);
+
+ imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
+ imageView.setOnClickListener(v -> openImage(item.getPath()));
+
+ gallery.addView(imageView, ViewGroup.LayoutParams.MATCH_PARENT, 700);
}
})
- .addOnFailureListener(new OnFailureListener() {
- @Override
- public void onFailure(@NonNull Exception e) {
- Toast.makeText(MainActivity.this, "Image load error!", Toast.LENGTH_SHORT).show();
- }
- });
+ .addOnFailureListener(e -> Toast.makeText(MainActivity.this, "Image load error!", Toast.LENGTH_SHORT).show());
}
private File createImageFile() throws IOException {
@@ -184,38 +147,20 @@ private void createLocationMetadata(StorageReference ref) {
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
fusedLocationClient.getCurrentLocation(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY, cancellationTokenSource.getToken())
- .addOnSuccessListener(new OnSuccessListener() {
- @Override
- public void onSuccess(Location location) {
- if (location != null) {
- StorageMetadata metadata = new StorageMetadata.Builder()
- .setCustomMetadata("Latitude", String.valueOf(location.getLatitude()))
- .setCustomMetadata("Longitude", String.valueOf(location.getLongitude()))
- .build();
-
- ref.updateMetadata(metadata)
- .addOnSuccessListener(new OnSuccessListener() {
- @Override
- public void onSuccess(StorageMetadata storageMetadata) {
- Toast.makeText(MainActivity.this, "Image Location is saved!", Toast.LENGTH_SHORT).show();
- }
- })
- .addOnFailureListener(new OnFailureListener() {
- @Override
- public void onFailure(@NonNull Exception e) {
- Toast.makeText(MainActivity.this, "Failed to save location for the image!", Toast.LENGTH_LONG).show();
- }
- })
- ;
- }
- }
- })
- .addOnFailureListener(new OnFailureListener() {
- @Override
- public void onFailure(@NonNull Exception e) {
- Toast.makeText(MainActivity.this, "The current location is not available!", Toast.LENGTH_SHORT).show();
+ .addOnSuccessListener(location -> {
+ if (location != null) {
+ StorageMetadata metadata = new StorageMetadata.Builder()
+ .setCustomMetadata("Latitude", String.valueOf(location.getLatitude()))
+ .setCustomMetadata("Longitude", String.valueOf(location.getLongitude()))
+ .build();
+
+ ref.updateMetadata(metadata)
+ .addOnSuccessListener(storageMetadata -> Toast.makeText(MainActivity.this, "Image Location is saved!", Toast.LENGTH_SHORT).show())
+ .addOnFailureListener(e -> Toast.makeText(MainActivity.this, "Failed to save location for the image!", Toast.LENGTH_LONG).show())
+ ;
}
})
+ .addOnFailureListener(e -> Toast.makeText(MainActivity.this, "The current location is not available!", Toast.LENGTH_SHORT).show())
;
}
diff --git a/local.properties b/local.properties
index 22057fc..ac09911 100644
--- a/local.properties
+++ b/local.properties
@@ -1,10 +1,8 @@
-## This file is automatically generated by Android Studio.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file should *NOT* be checked into Version Control Systems,
+## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
-sdk.dir=C\:\\Users\\bogna\\AppData\\Local\\Android\\Sdk
\ No newline at end of file
+#Wed Oct 20 18:11:42 CEST 2021
+sdk.dir=C\:\\Users\\ct4nk3r\\AppData\\Local\\Android\\Sdk