mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-13 09:48:47 +00:00
Ready for presentation
This commit is contained in:
parent
21277e1f76
commit
645cdc90f9
@ -1,4 +1,4 @@
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
@ -40,7 +40,7 @@ public class UserDeleter implements CallHandler {
|
||||
private final String DELETE_LISTS = "DELETE FROM List WHERE (owner = ?);";
|
||||
private final String DELETE_LIST_SHARES = "DELETE FROM ListSharee WHERE (listID = ?);";
|
||||
private final String DELETE_LIST_ACCESS = "DELETE FROM ListSharee WHERE (userID = ?);";
|
||||
private final String DELETE_PROFILE_PICTURE = "DELETE FROM Pictures WHERE (userID = ?);";
|
||||
private final String DELETE_PROFILE_PICTURE = "DELETE FROM Pictures WHERE (cognitoID = ?);";
|
||||
|
||||
public UserDeleter(Connection connection, String cognitoID) {
|
||||
this.connection = connection;
|
||||
|
||||
@ -43,6 +43,10 @@ public class ConfirmShareView extends AppCompatActivity {
|
||||
try {
|
||||
requestor.getObject(shareeEmail, User.class, userReceiver);
|
||||
String shareeID = userReceiver.await().getCognitoID();
|
||||
if (shareeID == null) {
|
||||
setResult(RESULT_CANCELED,null);
|
||||
finish();
|
||||
}
|
||||
requestor.getObject(shareeID, Picture.class, profilePictureReceiver);
|
||||
profilePictureView.setImageURI(Uri.fromFile(saveImage(profilePictureReceiver.await().getBase64EncodedImage(), "shareeProfilePicture")));
|
||||
} catch (Exception e) {
|
||||
|
||||
@ -1,13 +1,9 @@
|
||||
package com.example.listify;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
@ -24,7 +20,6 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.navigation.NavController;
|
||||
@ -84,31 +79,31 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||
if(checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
|
||||
Log.d("CHECKING", "WORKS");
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(
|
||||
this,
|
||||
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
|
||||
0
|
||||
);
|
||||
}
|
||||
Location location;
|
||||
|
||||
while(true) {
|
||||
try {
|
||||
location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
||||
break;
|
||||
} catch(java.lang.SecurityException e) {
|
||||
//User clicked delete
|
||||
}
|
||||
}
|
||||
|
||||
if(location != null) {
|
||||
double longitude = location.getLongitude();
|
||||
double latitude = location.getLatitude();
|
||||
}
|
||||
// LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||
// if(checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
|
||||
// Log.d("CHECKING", "WORKS");
|
||||
// } else {
|
||||
// ActivityCompat.requestPermissions(
|
||||
// this,
|
||||
// new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
|
||||
// 0
|
||||
// );
|
||||
// }
|
||||
// Location location;
|
||||
//
|
||||
// while(true) {
|
||||
// try {
|
||||
// location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
||||
// break;
|
||||
// } catch(java.lang.SecurityException e) {
|
||||
// //User clicked delete
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(location != null) {
|
||||
// double longitude = location.getLongitude();
|
||||
// double latitude = location.getLatitude();
|
||||
// }
|
||||
|
||||
|
||||
//------------------------------Auth Testing---------------------------------------------//
|
||||
|
||||
@ -13,7 +13,7 @@ import com.chauthai.swipereveallayout.SwipeRevealLayout;
|
||||
import com.chauthai.swipereveallayout.ViewBinderHelper;
|
||||
import com.example.listify.*;
|
||||
import com.example.listify.data.List;
|
||||
import com.example.listify.data.ListShare;
|
||||
import com.example.listify.data.User;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -25,6 +25,7 @@ import static com.example.listify.MainActivity.am;
|
||||
public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
||||
private Activity activity;
|
||||
private ArrayList<List> lists;
|
||||
private ArrayList<String> emails;
|
||||
private LayoutInflater inflater;
|
||||
private ViewHolder holder;
|
||||
private Requestor requestor;
|
||||
@ -34,6 +35,23 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
||||
binderHelper = new ViewBinderHelper();
|
||||
this.activity = activity;
|
||||
this.lists = lists;
|
||||
this.emails = new ArrayList<>();
|
||||
Properties configs = new Properties();
|
||||
try {
|
||||
configs = AuthManager.loadProperties(activity, "android.resource://" + activity.getPackageName() + "/raw/auths.json");
|
||||
} catch (IOException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
SynchronousReceiver<User> emailReceiver = new SynchronousReceiver();
|
||||
for (List list : lists) {
|
||||
requestor.getObject(list.getOwner(), User.class, emailReceiver);
|
||||
try {
|
||||
emails.add(emailReceiver.await().getEmail());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -53,13 +71,6 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
Properties configs = new Properties();
|
||||
try {
|
||||
configs = AuthManager.loadProperties(activity, "android.resource://" + activity.getPackageName() + "/raw/auths.json");
|
||||
} catch (IOException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
|
||||
if (inflater == null) {
|
||||
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
@ -88,12 +99,12 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
||||
holder.listName.setText(curList.getName());
|
||||
|
||||
if(curList.isShared()) {
|
||||
holder.listName.setText(curList.getName() + " (shared by User " + curList.getOwner() + ")");
|
||||
holder.listName.setText(curList.getName() + " (shared by " + emails.get(position) + ")");
|
||||
|
||||
String listText = holder.listName.getText().toString();
|
||||
|
||||
if(listText.length() > 25) {
|
||||
holder.listName.setText(listText.substring(0, 25) + "...");
|
||||
if(listText.length() > 27) {
|
||||
holder.listName.setText(listText.substring(0, 27) + "...");
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,6 +128,7 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
||||
|
||||
Toast.makeText(activity, String.format("%s deleted", curList.getName()), Toast.LENGTH_SHORT).show();
|
||||
lists.remove(position);
|
||||
emails.remove(position);
|
||||
|
||||
// Update listView
|
||||
notifyDataSetChanged();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user