mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-15 18:28:47 +00:00
Merge branch 'master' into improvements
This commit is contained in:
commit
24253ec391
@ -9,18 +9,16 @@ public class List {
|
||||
long lastUpdated;
|
||||
ArrayList<ItemEntry> entries;
|
||||
boolean shared;
|
||||
Integer uiPosition;
|
||||
|
||||
public List(ResultSet listRow, boolean shared) throws SQLException {
|
||||
public List(ResultSet listRow, boolean shared, Integer uiPosition) throws SQLException {
|
||||
listID = listRow.getInt("listID");
|
||||
name = listRow.getString("name");
|
||||
owner = listRow.getString("owner");
|
||||
lastUpdated = listRow.getTimestamp("lastUpdated").toInstant().toEpochMilli();
|
||||
entries = new ArrayList<>();
|
||||
this.shared = shared;
|
||||
}
|
||||
|
||||
public void addItemEntry(ItemEntry entry) {
|
||||
entries.add(entry);
|
||||
this.uiPosition = uiPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -31,9 +29,12 @@ public class List {
|
||||
", owner='" + owner + '\'' +
|
||||
", lastUpdated=" + lastUpdated +
|
||||
", entries=" + entries +
|
||||
", shared=" + shared +
|
||||
", uiPosition=" + uiPosition +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
public ItemEntry[] getEntries() {
|
||||
return entries.toArray(new ItemEntry[entries.size()]);
|
||||
}
|
||||
@ -77,4 +78,19 @@ public class List {
|
||||
public void setShared(boolean shared) {
|
||||
this.shared = shared;
|
||||
}
|
||||
|
||||
public Integer getUiPosition() {
|
||||
return uiPosition;
|
||||
}
|
||||
|
||||
public void setUiPosition(Integer uiPosition) {
|
||||
this.uiPosition = uiPosition;
|
||||
|
||||
public ItemEntry[] getEntries() {
|
||||
return entries.toArray(new ItemEntry[entries.size()]);
|
||||
}
|
||||
|
||||
public void addItemEntry(ItemEntry entry) {
|
||||
entries.add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,8 @@ public class ListAdder implements CallHandler {
|
||||
private String cognitoID;
|
||||
|
||||
private final String LIST_CREATE = "INSERT INTO List (name, owner, lastUpdated) VALUES (?, ?, ?);";
|
||||
private final String LIST_ACCESS_GRANT = "INSERT INTO ListSharee(listID, userID, permissionLevel) VALUES(?, ?, ?);";
|
||||
private final String LIST_ACCESS_GRANT = "INSERT INTO ListSharee(listID, userID, permissionLevel, uiPosition) VALUES(?, ?, ?, ?);";
|
||||
private final String UI_POSITION_CHECK = "SELECT Max(uiPosition) as maxUIPosition FROM ListSharee WHERE userID = ?;";
|
||||
|
||||
public ListAdder(Connection connection, String cognitoID) {
|
||||
this.connection = connection;
|
||||
@ -17,9 +18,17 @@ public class ListAdder implements CallHandler {
|
||||
}
|
||||
|
||||
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryString, String cognitoID) throws SQLException {
|
||||
PreparedStatement statement = connection.prepareStatement(LIST_CREATE, Statement.RETURN_GENERATED_KEYS);
|
||||
|
||||
String listName = bodyMap.get("name").toString();//Needs safe checking
|
||||
|
||||
PreparedStatement uiPositionCheck = connection.prepareStatement(UI_POSITION_CHECK);
|
||||
uiPositionCheck.setString(1, cognitoID);
|
||||
ResultSet uiPositionCheckRS = uiPositionCheck.executeQuery();
|
||||
int nextPosition = 1;
|
||||
if (uiPositionCheckRS.next()) {
|
||||
nextPosition = uiPositionCheckRS.getInt("maxUIPosition") + 1;
|
||||
}
|
||||
|
||||
PreparedStatement statement = connection.prepareStatement(LIST_CREATE, Statement.RETURN_GENERATED_KEYS);
|
||||
statement.setString(1, listName);
|
||||
statement.setString(2, cognitoID);
|
||||
statement.setTimestamp(3, Timestamp.from(Instant.now()));
|
||||
@ -32,6 +41,7 @@ public class ListAdder implements CallHandler {
|
||||
accessGrant.setInt(1, newID);
|
||||
accessGrant.setString(2, cognitoID);
|
||||
accessGrant.setInt(3, ListPermissions.getAll());
|
||||
accessGrant.setInt(4, nextPosition);
|
||||
System.out.println(accessGrant);
|
||||
accessGrant.executeUpdate();
|
||||
connection.commit();
|
||||
|
||||
@ -12,7 +12,7 @@ public class ListGetter implements CallHandler{
|
||||
private final String cognitoID;
|
||||
|
||||
private final String GET_LIST = "SELECT * FROM List WHERE listID = ?;";
|
||||
private final String GET_LISTS = "SELECT listID FROM ListSharee WHERE userID = ?;";
|
||||
private final String GET_LISTS = "SELECT listID FROM ListSharee WHERE userID = ? ORDER BY uiPosition;";
|
||||
private final String SHARE_CHECK = "SELECT * FROM ListSharee WHERE listID = ?;";
|
||||
private final String GET_ENTRIES = "SELECT * FROM ListProduct WHERE listID = ?;";
|
||||
|
||||
@ -42,6 +42,7 @@ public class ListGetter implements CallHandler{
|
||||
ResultSet accessResults = checkAccess.executeQuery();
|
||||
int sharees = 0;
|
||||
boolean verifiedAccess = false;
|
||||
int uiPosition = 1;
|
||||
while ((sharees < 2 && accessResults.next()) || !verifiedAccess) {
|
||||
int permissionLevel = accessResults.getInt("permissionLevel");
|
||||
if (accessResults.getString("userID").equals(cognitoID)) {
|
||||
@ -49,6 +50,7 @@ public class ListGetter implements CallHandler{
|
||||
if (!ListPermissions.hasPermission(permissionLevel, "Read")) {
|
||||
throw new AccessControlException("User " + cognitoID + " does not have permission to read list " + id);
|
||||
}
|
||||
uiPosition = accessResults.getInt("uiPosition");
|
||||
}
|
||||
if (permissionLevel > 0) {
|
||||
sharees++;
|
||||
@ -64,7 +66,7 @@ public class ListGetter implements CallHandler{
|
||||
ResultSet getListResults = getList.executeQuery();
|
||||
getListResults.first();
|
||||
System.out.println(getListResults);
|
||||
List retrievedList = new List(getListResults, shared);
|
||||
List retrievedList = new List(getListResults, shared, uiPosition);
|
||||
System.out.println(retrievedList);
|
||||
PreparedStatement getListEntries = connection.prepareStatement(GET_ENTRIES);
|
||||
getListEntries.setInt(1, id);
|
||||
|
||||
11
Lambdas/Lists/ListDuplicate/src/ListDuplicatePOST.java
Normal file
11
Lambdas/Lists/ListDuplicate/src/ListDuplicatePOST.java
Normal file
@ -0,0 +1,11 @@
|
||||
import com.amazonaws.services.lambda.runtime.Context;
|
||||
import com.amazonaws.services.lambda.runtime.RequestHandler;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ListDuplicatePOST implements RequestHandler<Map<String,Object>, Object>{
|
||||
|
||||
public Object handleRequest(Map<String, Object> inputMap, Context unfilled) {
|
||||
return BasicHandler.handleRequest(inputMap, unfilled, ListDuplicater.class);
|
||||
}
|
||||
}
|
||||
73
Lambdas/Lists/ListDuplicate/src/ListDuplicater.java
Normal file
73
Lambdas/Lists/ListDuplicate/src/ListDuplicater.java
Normal file
@ -0,0 +1,73 @@
|
||||
import com.amazonaws.services.lambda.AWSLambdaClientBuilder;
|
||||
import com.amazonaws.services.lambda.model.InvokeRequest;
|
||||
import com.amazonaws.services.lambda.model.InvokeResult;
|
||||
|
||||
import java.security.AccessControlException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.InputMismatchException;
|
||||
import java.util.Map;
|
||||
|
||||
public class ListDuplicater implements CallHandler {
|
||||
|
||||
private Connection connection;
|
||||
private String cognitoID;
|
||||
|
||||
private final String LIST_POPULATE = "INSERT INTO ListProduct(listID, productID, quantity, addedDate, purchased) SELECT ?, productID, quantity, addedDate, purchased FROM ListProduct WHERE listID = ?;";
|
||||
private final String ACCESS_CHECK = "SELECT * from ListSharee WHERE userID = ? and listID = ?;";
|
||||
|
||||
public ListDuplicater(Connection connection, String cognitoID) {
|
||||
this.connection = connection;
|
||||
this.cognitoID = cognitoID;
|
||||
}
|
||||
|
||||
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryString, String cognitoID) throws SQLException {
|
||||
String listName = bodyMap.get("name").toString();//Needs safe checking
|
||||
Integer copyListID = (Integer) bodyMap.get("listID");
|
||||
|
||||
PreparedStatement accessCheck = connection.prepareStatement(ACCESS_CHECK);
|
||||
accessCheck.setString(1, cognitoID);
|
||||
accessCheck.setInt(2, copyListID);
|
||||
ResultSet access = accessCheck.executeQuery();
|
||||
if (access.next()) {
|
||||
if (!ListPermissions.hasPermission(access.getInt("permissionLevel"), "Read")) {
|
||||
throw new AccessControlException("User " + cognitoID + " does not have write permissions for list " + copyListID);
|
||||
}
|
||||
} else {
|
||||
throw new AccessControlException("User " + cognitoID + " does not have any permissions to access list " + copyListID);
|
||||
}
|
||||
|
||||
|
||||
InvokeRequest invokeRequest = new InvokeRequest();
|
||||
invokeRequest.setFunctionName("ListPOST");
|
||||
invokeRequest.setPayload("{" +
|
||||
" \"body\": {" +
|
||||
" \"name\": \"" + listName + "\"" +
|
||||
" }," +
|
||||
" \"params\": {" +
|
||||
" \"querystring\": {" +
|
||||
" }" +
|
||||
" }," +
|
||||
" \"context\": {" +
|
||||
" \"sub\": \"" + cognitoID + "\"" +
|
||||
" }" +
|
||||
"}");
|
||||
System.out.println(invokeRequest);
|
||||
InvokeResult listCreateResult = AWSLambdaClientBuilder.defaultClient().invoke(invokeRequest);
|
||||
if (listCreateResult.getStatusCode() != 200) {
|
||||
throw new InputMismatchException("Could not find specified user to share with");
|
||||
}
|
||||
Integer newListID = Integer.parseInt(new String(listCreateResult.getPayload().array()).replace("\"", ""));
|
||||
|
||||
PreparedStatement populateList = connection.prepareStatement(LIST_POPULATE);
|
||||
populateList.setInt(1, newListID);
|
||||
populateList.setInt(2, copyListID);
|
||||
System.out.println(populateList);
|
||||
populateList.executeUpdate();
|
||||
connection.commit();
|
||||
return newListID;
|
||||
}
|
||||
}
|
||||
70
Lambdas/Lists/ListReposition/src/ListRepositionActor.java
Normal file
70
Lambdas/Lists/ListReposition/src/ListRepositionActor.java
Normal file
@ -0,0 +1,70 @@
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ListRepositionActor implements CallHandler {
|
||||
|
||||
private Connection connection;
|
||||
private String cognitoID;
|
||||
|
||||
public ListRepositionActor(Connection connection, String cognitoID) {
|
||||
this.connection = connection;
|
||||
this.cognitoID = cognitoID;
|
||||
}
|
||||
|
||||
final private String GET_PRIOR_POSITION = "SELECT uiPosition FROM ListSharee WHERE userID = ? AND listID = ?;";
|
||||
final private String SET_NEW_POSITION = "UPDATE ListSharee SET uiPosition = ? WHERE userID = ? AND listID = ?;";
|
||||
final private String DECREMENT_HIGHER_POSITIONS = "UPDATE ListSharee SET uiPosition = uiPosition - 1 WHERE uiPosition > ? AND userID = ?;";
|
||||
final private String INCREMENT_GEQ_POSITIONS = "UPDATE ListSharee SET uiPosition = uiPosition + 1 WHERE uiPosition >= ? AND userID = ?;";
|
||||
|
||||
|
||||
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryString, String cognitoID) throws SQLException {
|
||||
Integer listID = (Integer) bodyMap.get("listID");
|
||||
Integer newPosition = (Integer) bodyMap.get("newPosition");
|
||||
|
||||
PreparedStatement getPriorPosition = connection.prepareStatement(GET_PRIOR_POSITION);
|
||||
getPriorPosition.setString(1, cognitoID);
|
||||
getPriorPosition.setInt(2, listID);
|
||||
ResultSet priorPositionRS = getPriorPosition.executeQuery();
|
||||
if (!priorPositionRS.next()) {
|
||||
throw new IllegalArgumentException("Bad listID for user");
|
||||
}
|
||||
Integer priorPosition = priorPositionRS.getInt("uiPosition");
|
||||
|
||||
PreparedStatement openNewPosition = connection.prepareStatement(INCREMENT_GEQ_POSITIONS);
|
||||
|
||||
if (newPosition.equals(priorPosition)) {
|
||||
return null;
|
||||
}
|
||||
if (newPosition < priorPosition) {
|
||||
openNewPosition.setInt(1, newPosition);
|
||||
} else {
|
||||
openNewPosition.setInt(1, newPosition + 1);
|
||||
}
|
||||
openNewPosition.setString(2, cognitoID);
|
||||
System.out.println(openNewPosition);
|
||||
openNewPosition.executeUpdate();
|
||||
|
||||
PreparedStatement fillPriorPosition = connection.prepareStatement(DECREMENT_HIGHER_POSITIONS);
|
||||
fillPriorPosition.setInt(1, priorPosition);
|
||||
fillPriorPosition.setString(2, cognitoID);
|
||||
System.out.println(fillPriorPosition);
|
||||
fillPriorPosition.executeUpdate();
|
||||
|
||||
|
||||
|
||||
PreparedStatement setNewPosition = connection.prepareStatement(SET_NEW_POSITION);
|
||||
setNewPosition.setInt(1, newPosition);
|
||||
setNewPosition.setString(2, cognitoID);
|
||||
setNewPosition.setInt(3, listID);
|
||||
System.out.println(setNewPosition);
|
||||
setNewPosition.executeUpdate();
|
||||
|
||||
connection.commit();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
11
Lambdas/Lists/ListReposition/src/ListRepositionPUT.java
Normal file
11
Lambdas/Lists/ListReposition/src/ListRepositionPUT.java
Normal file
@ -0,0 +1,11 @@
|
||||
import com.amazonaws.services.lambda.runtime.Context;
|
||||
import com.amazonaws.services.lambda.runtime.RequestHandler;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ListRepositionPUT implements RequestHandler<Map<String,Object>, Object> {
|
||||
|
||||
public Object handleRequest(Map<String, Object> inputMap, Context unfilled) {
|
||||
return BasicHandler.handleRequest(inputMap, unfilled, ListRepositionActor.class);
|
||||
}
|
||||
}
|
||||
37
Lambdas/Lists/ListShare/src/ListShare.java
Normal file
37
Lambdas/Lists/ListShare/src/ListShare.java
Normal file
@ -0,0 +1,37 @@
|
||||
package com.example.listify.data;
|
||||
|
||||
public class ListShare {
|
||||
Integer listID;
|
||||
String shareWithEmail;
|
||||
ArrayList<ListShare> other;
|
||||
|
||||
public ListShare(ResultSet listRow) throws SQLException {
|
||||
this.listID = listRow.getInt("listID");
|
||||
this.shareWithEmail = listRow.getString("userID");
|
||||
other = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Integer getListID() {
|
||||
return listID;
|
||||
}
|
||||
|
||||
public void setListID(Integer listID) {
|
||||
this.listID = listID;
|
||||
}
|
||||
|
||||
public String getShareWithEmail() {
|
||||
return shareWithEmail;
|
||||
}
|
||||
|
||||
public void setShareWithEmail(String shareWithEmail) {
|
||||
this.shareWithEmail = shareWithEmail;
|
||||
}
|
||||
|
||||
public ListShare[] getEntries() {
|
||||
return other.toArray(new ListShare[other.size()]);
|
||||
}
|
||||
|
||||
public void addtoList(ListShare entry) {
|
||||
other.add(entry);
|
||||
}
|
||||
}
|
||||
12
Lambdas/Lists/ListShare/src/ListShareDELETE.java
Normal file
12
Lambdas/Lists/ListShare/src/ListShareDELETE.java
Normal file
@ -0,0 +1,12 @@
|
||||
import com.amazonaws.services.lambda.runtime.Context;
|
||||
import com.amazonaws.services.lambda.runtime.RequestHandler;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ListShareDELETE implements RequestHandler<Map<String,Object>, Object> {
|
||||
|
||||
public Object handleRequest(Map<String, Object> inputMap, Context unfilled) {
|
||||
return BasicHandler.handleRequest(inputMap, unfilled, ListShareDeleter.class);
|
||||
}
|
||||
|
||||
}
|
||||
65
Lambdas/Lists/ListShare/src/ListShareDeleter.java
Normal file
65
Lambdas/Lists/ListShare/src/ListShareDeleter.java
Normal file
@ -0,0 +1,65 @@
|
||||
import java.security.AccessControlException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ListShareDeleter implements CallHandler {
|
||||
private final Connection connection;
|
||||
private final String cognitoID;
|
||||
|
||||
private final String GET_LIST_ACCESS = "SELECT * FROM List WHERE (owner = ? AND listID = ?);";
|
||||
private final String REMOVE_SHAREE = "DELETE FROM ListSharee WHERE listID = ? AND user = ?;";
|
||||
|
||||
public ListShareDeleter(Connection connection, String cognitoID) {
|
||||
this.connection = connection;
|
||||
this.cognitoID = cognitoID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryMap, String cognitoID) throws SQLException {
|
||||
Integer listID = Integer.parseInt(queryMap.get("id"));
|
||||
|
||||
InvokeRequest invokeRequest = new InvokeRequest();
|
||||
invokeRequest.setFunctionName("UserGET");
|
||||
invokeRequest.setPayload("{" +
|
||||
" \"body\": {" +
|
||||
" \"emailToCheck\": \"" + bodyMap.get("shareWithEmail").toString() + "\"" +
|
||||
" }," +
|
||||
" \"params\": {" +
|
||||
" \"querystring\": {" +
|
||||
" }" +
|
||||
" }," +
|
||||
" \"context\": {" +
|
||||
" \"sub\": \"not used\"" +
|
||||
" }" +
|
||||
"}");
|
||||
InvokeResult invokeResult = AWSLambdaClientBuilder.defaultClient().invoke(invokeRequest);
|
||||
|
||||
String shareeID = new String(invokeResult.getPayload().array()).replace("\"", "");
|
||||
|
||||
//Ensure that the user who is unsharing a list is the owner of that list
|
||||
PreparedStatement accessCheck = connection.prepareStatement(GET_LIST_ACCESS);
|
||||
accessCheck.setString(1, cognitoID);
|
||||
accessCheck.setInt(2, listID);
|
||||
|
||||
ResultSet userLists = accessCheck.executeQuery();
|
||||
|
||||
//User does not own the list; unshare attempt fails
|
||||
if (!userLists.next()) {
|
||||
throw new AccessControlException("User does not have access to list");
|
||||
}
|
||||
|
||||
//Unshare the list with the specified sharee
|
||||
PreparedStatement unshareList = connection.prepareStatement(REMOVE_SHAREE);
|
||||
unshareList.setInt(1, listID);
|
||||
unshareList.setInt(2, shareeID);
|
||||
|
||||
cleanAccess.executeUpdate();
|
||||
connection.commit();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
11
Lambdas/Lists/ListShare/src/ListShareGET.java
Normal file
11
Lambdas/Lists/ListShare/src/ListShareGET.java
Normal file
@ -0,0 +1,11 @@
|
||||
import com.amazonaws.services.lambda.runtime.Context;
|
||||
import com.amazonaws.services.lambda.runtime.RequestHandler;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ListShareGET implements RequestHandler<Map<String,Object>, Object> {
|
||||
|
||||
public Object handleRequest(Map<String, Object> inputMap, Context unfilled) {
|
||||
return BasicHandler.handleRequest(inputMap, unfilled, ListShareGetter.class);
|
||||
}
|
||||
}
|
||||
40
Lambdas/Lists/ListShare/src/ListShareGetter.java
Normal file
40
Lambdas/Lists/ListShare/src/ListShareGetter.java
Normal file
@ -0,0 +1,40 @@
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ListShareGetter implements CallHandler{
|
||||
private final Connection connection;
|
||||
private final String cognitoID;
|
||||
|
||||
private final String GET_LISTS = "SELECT * FROM ListSharee WHERE listID = ?;";
|
||||
|
||||
public ListShareGetter(Connection connection, String cognitoID) {
|
||||
this.connection = connection;
|
||||
this.cognitoID = cognitoID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryMap, String cognitoID) throws SQLException {
|
||||
Integer listID = Integer.parseInt(queryMap.get("id"));
|
||||
|
||||
PreparedStatement getList = connection.prepareStatement(GET_LIST);
|
||||
getList.setInt(1, listID);
|
||||
|
||||
ResultSet getListResults = getList.executeQuery();
|
||||
getListResults.first();
|
||||
|
||||
//ListShare object to hold the data values of the first row retrived
|
||||
ListShare first = new ListShare(getListResults);
|
||||
|
||||
//Insert the ListShare objects to hold the data of the remaining rows into first's ListShare list
|
||||
while (getListResults.next()) {
|
||||
first.addtoList(new ListShare(getListResults));
|
||||
}
|
||||
|
||||
return first;
|
||||
}
|
||||
}
|
||||
@ -22,9 +22,9 @@ public class ListSharer implements CallHandler {
|
||||
}
|
||||
|
||||
final private String CHECK_ACCESS = "SELECT * from ListSharee WHERE listID = ? AND userID = ?;";
|
||||
private final String UI_POSITION_CHECK = "SELECT Max(uiPosition) as maxUIPosition FROM ListSharee WHERE userID = ?;";
|
||||
final private String SHARE_LIST = "INSERT INTO ListSharee(listID, userID, permissionLevel, uiPosition) VALUES(?, ?, ?, ?) ON DUPLICATE KEY UPDATE permissionLevel = ?;";
|
||||
|
||||
|
||||
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryString, String cognitoID) throws SQLException {
|
||||
PreparedStatement checkAccess = connection.prepareStatement(CHECK_ACCESS);
|
||||
Integer listID = Integer.parseInt(bodyMap.get("listID").toString());
|
||||
@ -63,12 +63,23 @@ public class ListSharer implements CallHandler {
|
||||
// throw new InputMismatchException("The specified user already has access");
|
||||
// }
|
||||
|
||||
PreparedStatement uiPositionCheck = connection.prepareStatement(UI_POSITION_CHECK);
|
||||
uiPositionCheck.setString(1, shareWithSub);
|
||||
System.out.println(uiPositionCheck);
|
||||
ResultSet uiPositionCheckRS = uiPositionCheck.executeQuery();
|
||||
int nextPosition = 1;
|
||||
if (uiPositionCheckRS.next()) {
|
||||
nextPosition = uiPositionCheckRS.getInt("maxUIPosition") + 1;
|
||||
}
|
||||
|
||||
PreparedStatement shareList = connection.prepareStatement(SHARE_LIST);
|
||||
shareList.setInt(1, listID);
|
||||
shareList.setString(2, shareWithSub);
|
||||
Integer permissionLevel = Integer.parseInt(bodyMap.get("permissionLevel").toString());
|
||||
shareList.setInt(3, permissionLevel);
|
||||
shareList.setInt(4, permissionLevel);
|
||||
shareList.setInt(4, nextPosition);
|
||||
shareList.setInt(5, permissionLevel);
|
||||
System.out.println(shareList);
|
||||
shareList.executeUpdate();
|
||||
connection.commit();
|
||||
return null;
|
||||
|
||||
@ -2,20 +2,15 @@ package com.example.listify;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.*;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.example.listify.data.List;
|
||||
import com.example.listify.data.ListEntry;
|
||||
import com.example.listify.model.Product;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -233,7 +228,7 @@ public class ItemDetails extends AppCompatActivity implements ListPickerDialogFr
|
||||
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
SynchronousReceiver<Integer> idReceiver = new SynchronousReceiver<>();
|
||||
|
||||
com.example.listify.data.List newList = new List(-1, name, "user filled by lambda", Instant.now().toEpochMilli());
|
||||
com.example.listify.data.List newList = new List(-1, name, "user filled by lambda", Instant.now().toEpochMilli(), -1);
|
||||
|
||||
Thread t = new Thread(new Runnable() {
|
||||
@Override
|
||||
|
||||
@ -1,16 +1,19 @@
|
||||
package com.example.listify;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.util.Log;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import com.example.listify.ui.home.HomeFragment;
|
||||
import com.bumptech.glide.Glide;
|
||||
@ -26,7 +29,7 @@ import java.util.Properties;
|
||||
|
||||
import static com.example.listify.MainActivity.am;
|
||||
|
||||
public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
public class ListPage extends AppCompatActivity implements Requestor.Receiver, RenameListDialogFragment.OnRenameListListener {
|
||||
ListView listView;
|
||||
MyAdapter myAdapter;
|
||||
Requestor requestor;
|
||||
@ -39,6 +42,8 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
Button shareList;
|
||||
|
||||
TextView tvTotalPrice;
|
||||
TextView emptyMessage;
|
||||
|
||||
ProgressBar loadingListItems;
|
||||
|
||||
ArrayList<String> pNames = new ArrayList<>();
|
||||
@ -56,16 +61,15 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
Map<String, Integer> storeHeaderIndex = new HashMap<>();
|
||||
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
List selectedList;
|
||||
|
||||
// TODO: Display a message if their list is empty
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_list);
|
||||
|
||||
final int LIST_ID = (int) getIntent().getSerializableExtra("listID");
|
||||
final String LIST_NAME = (String) getIntent().getSerializableExtra("listName");
|
||||
setTitle(LIST_NAME);
|
||||
selectedList = (List) getIntent().getSerializableExtra("selectedList");
|
||||
setTitle(selectedList.getName());
|
||||
|
||||
Properties configs = new Properties();
|
||||
try {
|
||||
@ -74,7 +78,7 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
e.printStackTrace();
|
||||
}
|
||||
requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
requestor.getObject(Integer.toString(LIST_ID), List.class, this);
|
||||
requestor.getObject(Integer.toString(selectedList.getListID()), List.class, this);
|
||||
|
||||
listView = findViewById(R.id.listView);
|
||||
myAdapter = new MyAdapter(this, pNames, pStores, pPrices, pQuantity, pImages);
|
||||
@ -84,8 +88,9 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
loadingListItems.setVisibility(View.VISIBLE);
|
||||
|
||||
tvTotalPrice = (TextView) findViewById(R.id.total_price);
|
||||
emptyMessage = (TextView) findViewById(R.id.textViewEmpty2);
|
||||
|
||||
clearAll = (Button) findViewById(R.id.buttonClear);
|
||||
/*clearAll = (Button) findViewById(R.id.buttonClear);
|
||||
clearAll.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -95,6 +100,8 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
pQuantity.clear();
|
||||
pImages.clear();
|
||||
|
||||
emptyMessage.setVisibility(View.VISIBLE);
|
||||
|
||||
while(!pListItemPair.isEmpty()) {
|
||||
try {
|
||||
requestor.deleteObject(pListItemPair.remove(0));
|
||||
@ -123,7 +130,7 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
EditText sharedEmailText = (EditText) codeView.findViewById(R.id.editTextTextSharedEmail);
|
||||
String sharedEmail = sharedEmailText.getText().toString();
|
||||
|
||||
ListShare listShare = new ListShare(LIST_ID, sharedEmail, "Read, Write, Delete, Share");
|
||||
ListShare listShare = new ListShare(LIST_ID, sharedEmail, "Read, Write, Delete, Share", null);
|
||||
try {
|
||||
requestor.putObject(listShare);
|
||||
}
|
||||
@ -139,7 +146,7 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
});*/
|
||||
|
||||
refreshList = (SwipeRefreshLayout) findViewById(R.id.refresh_list);
|
||||
refreshList.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@ -153,7 +160,7 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
}
|
||||
|
||||
requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
requestor.getObject(Integer.toString(LIST_ID), List.class, ListPage.this);
|
||||
requestor.getObject(Integer.toString(selectedList.getListID()), List.class, ListPage.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -162,13 +169,15 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
//Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.list, menu);
|
||||
// return super.onCreateOptionsMenu(menu);
|
||||
|
||||
|
||||
|
||||
MenuItem renameItem = menu.findItem(R.id.action_rename_list);
|
||||
renameItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
Toast.makeText(ListPage.this, "Rename List", Toast.LENGTH_SHORT).show();
|
||||
RenameListDialogFragment renameListDialog = new RenameListDialogFragment();
|
||||
renameListDialog.show(getSupportFragmentManager(), "Rename List");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@ -186,7 +195,24 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
duplicateItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
Toast.makeText(ListPage.this, "Duplicate List", Toast.LENGTH_SHORT).show();
|
||||
|
||||
ListDuplicate duplicate = new ListDuplicate(selectedList.getListID(), String.format("%s copy", selectedList.getName()));
|
||||
|
||||
Properties configs = new Properties();
|
||||
try {
|
||||
configs = AuthManager.loadProperties(ListPage.this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
||||
} catch (IOException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
try {
|
||||
requestor.postObject(duplicate);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Toast.makeText(ListPage.this, "List duplicated", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@ -232,6 +258,12 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
|
||||
if(list != null) {
|
||||
for (ListEntry entry : list.getEntries()) {
|
||||
this.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
emptyMessage.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
int product = entry.getProductID();
|
||||
SynchronousReceiver<Item> pr = new SynchronousReceiver<>();
|
||||
requestor.getObject(Integer.toString(product), Item.class, pr, pr);
|
||||
@ -328,6 +360,34 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
refreshList.setRefreshing(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRenameListName(String name) {
|
||||
selectedList.setName(name);
|
||||
|
||||
Properties configs = new Properties();
|
||||
try {
|
||||
configs = AuthManager.loadProperties(ListPage.this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
||||
} catch (IOException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
try {
|
||||
requestor.putObject(selectedList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setTitle(name);
|
||||
Toast.makeText(ListPage.this, "List Renamed", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
class MyAdapter extends ArrayAdapter<String> {
|
||||
Context context;
|
||||
ArrayList<String> pNames;
|
||||
@ -338,7 +398,7 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
|
||||
|
||||
MyAdapter (Context c, ArrayList<String> names, ArrayList<String> stores, ArrayList<String> prices, ArrayList<String> quantity, ArrayList<String> images) {
|
||||
super(c, R.layout.activity_listproductentry, R.id.productView, names);
|
||||
super(c, R.layout.shopping_list_product_entry, R.id.productView, names);
|
||||
context = c;
|
||||
pNames = names;
|
||||
pStores = stores;
|
||||
@ -351,7 +411,7 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
@Override
|
||||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||
LayoutInflater layoutInflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View listproduct = layoutInflater.inflate(R.layout.activity_listproductentry, parent,false);
|
||||
View listproduct = layoutInflater.inflate(R.layout.shopping_list_product_entry, parent,false);
|
||||
|
||||
decrQuan = (Button) listproduct.findViewById(R.id.buttonDecr);
|
||||
incrQuan = (Button) listproduct.findViewById(R.id.buttonIncr);
|
||||
@ -435,7 +495,6 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
totalPriceByStore.put(storeName, totalPriceByStore.get(storeName) - (Double.parseDouble(pPrices.get(position)) * Integer.parseInt(pQuantity.get(position))));
|
||||
pPrices.set(storeHeaderIndex.get(storeName), df.format(totalPriceByStore.get(storeName)));
|
||||
|
||||
|
||||
totalPrice -= (Double.parseDouble(pPrices.get(position)) * Double.parseDouble(pQuantity.get(position)));
|
||||
tvTotalPrice.setText(String.format("$%.2f", totalPrice));
|
||||
|
||||
@ -444,8 +503,35 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
pPrices.remove(position);
|
||||
pQuantity.remove(position);
|
||||
pImages.remove(position);
|
||||
|
||||
requestor.deleteObject(pListItemPair.remove(position));
|
||||
|
||||
for(String str : storeHeaderIndex.keySet()) {
|
||||
if(storeHeaderIndex.get(str) > position) {
|
||||
storeHeaderIndex.put(str, storeHeaderIndex.get(str) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
if(String.format("$%.2f", totalPriceByStore.get(storeName)).equals("$0.00") || String.format("$%.2f", totalPriceByStore.get(storeName)).equals("$-0.00")) {
|
||||
int index = storeHeaderIndex.remove(storeName);
|
||||
|
||||
pNames.remove(index);
|
||||
pStores.remove(index);
|
||||
pPrices.remove(index);
|
||||
pQuantity.remove(index);
|
||||
pImages.remove(index);
|
||||
pListItemPair.remove(index);
|
||||
|
||||
for(String str : storeHeaderIndex.keySet()) {
|
||||
if(storeHeaderIndex.get(str) > index) {
|
||||
storeHeaderIndex.put(str, storeHeaderIndex.get(str) - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(pNames.isEmpty()) {
|
||||
emptyMessage.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
myAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
@ -470,6 +556,14 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
decrQuan.setVisibility(View.GONE);
|
||||
incrQuan.setVisibility(View.GONE);
|
||||
removeItem.setVisibility(View.GONE);
|
||||
|
||||
listproduct.setBackgroundColor(Color.parseColor("#BBBBBB"));
|
||||
|
||||
ConstraintLayout constraintLayout = listproduct.findViewById(R.id.constraintLayout);
|
||||
constraintLayout.setMaxHeight(250);
|
||||
|
||||
name.setPadding(0, 175, 0, 0);
|
||||
price.setPadding(0, 175, 0, 0);
|
||||
}
|
||||
else {
|
||||
quantity.setText(pQuantity.get(position));
|
||||
|
||||
102
Listify/app/src/main/java/com/example/listify/ListSharees.java
Normal file
102
Listify/app/src/main/java/com/example/listify/ListSharees.java
Normal file
@ -0,0 +1,102 @@
|
||||
package com.example.listify;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.example.listify.adapter.ShareeSwipeableAdapter;
|
||||
import com.example.listify.adapter.ShoppingListsSwipeableAdapter;
|
||||
import com.example.listify.data.Chain;
|
||||
import com.example.listify.data.Item;
|
||||
import com.example.listify.data.List;
|
||||
import com.example.listify.data.ListEntry;
|
||||
import com.example.listify.data.ListShare;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import static com.example.listify.MainActivity.am;
|
||||
|
||||
public class ListSharees extends AppCompatActivity implements Requestor.Receiver {
|
||||
ShareeSwipeableAdapter myAdapter;
|
||||
Requestor requestor;
|
||||
ProgressBar loadingListItems;
|
||||
|
||||
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
|
||||
// TODO: Display a message if their list is empty
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_listofsharees);
|
||||
|
||||
final int listID = (int) getIntent().getSerializableExtra("listID");
|
||||
|
||||
Properties configs = new Properties();
|
||||
try {
|
||||
configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
||||
} catch (IOException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
requestor.getObject(Integer.toString(listID), ListShare.class, this);
|
||||
|
||||
loadingListItems = findViewById(R.id.progress_loading_list_items);
|
||||
loadingListItems.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptDelivery(Object delivered) {
|
||||
ListShare sharee = (ListShare) delivered;
|
||||
|
||||
if(sharee != null) {
|
||||
SynchronousReceiver<ListShare> listShareReceiver = new SynchronousReceiver<>();
|
||||
requestor.getObject(Integer.toString(sharee.getListID()), ListShare.class, listShareReceiver, listShareReceiver);
|
||||
|
||||
ArrayList<ListShare> resultList = new ArrayList<>();
|
||||
ListShare result;
|
||||
|
||||
try {
|
||||
result = listShareReceiver.await();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result = null;
|
||||
}
|
||||
|
||||
if(result != null) {
|
||||
resultList.add(result);
|
||||
|
||||
for(ListShare r : result.getEntries()) {
|
||||
resultList.add(r);
|
||||
}
|
||||
|
||||
myAdapter = new ShareeSwipeableAdapter(this, resultList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,6 +17,8 @@ import androidx.navigation.ui.AppBarConfiguration;
|
||||
import androidx.navigation.ui.NavigationUI;
|
||||
import com.amplifyframework.auth.AuthException;
|
||||
import com.example.listify.data.List;
|
||||
import com.example.listify.data.ListDuplicate;
|
||||
import com.example.listify.data.ListReposition;
|
||||
import com.example.listify.data.SearchHistory;
|
||||
import com.example.listify.ui.LoginPage;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
@ -103,16 +105,18 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Requestor requestor = new Requestor(authManager, configs.getProperty("apiKey"));
|
||||
/*Requestor requestor = new Requestor(authManager, configs.getProperty("apiKey"));
|
||||
SynchronousReceiver<SearchHistory> historyReceiver = new SynchronousReceiver<>();
|
||||
requestor.getObject("N/A", SearchHistory.class, historyReceiver, historyReceiver);
|
||||
try {
|
||||
requestor.putObject(new List(293, "Java.py", "me!", 1));
|
||||
System.out.println(historyReceiver.await());
|
||||
requestor.putObject(new ListReposition(291, 1));
|
||||
requestor.postObject(new ListDuplicate(290, "yet another list"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
/*
|
||||
|
||||
List testList = new List(-1, "New List", "user filled by lambda", Instant.now().toEpochMilli());
|
||||
ListEntry entry = new ListEntry(1, 4, Math.abs(new Random().nextInt()), Instant.now().toEpochMilli(),false);
|
||||
|
||||
@ -200,7 +204,7 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
SynchronousReceiver<Integer> idReceiver = new SynchronousReceiver<>();
|
||||
|
||||
List newList = new List(-1, name, "user filled by lambda", Instant.now().toEpochMilli());
|
||||
List newList = new List(-1, name, "user filled by lambda", Instant.now().toEpochMilli(), -1);
|
||||
|
||||
try {
|
||||
requestor.postObject(newList, idReceiver, idReceiver);
|
||||
|
||||
@ -0,0 +1,71 @@
|
||||
package com.example.listify;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
|
||||
public class RenameListDialogFragment extends DialogFragment {
|
||||
|
||||
public interface OnRenameListListener {
|
||||
void sendRenameListName(String name);
|
||||
}
|
||||
|
||||
public OnRenameListListener onRenameListListener;
|
||||
|
||||
EditText etRenameListName;
|
||||
|
||||
public RenameListDialogFragment() {}
|
||||
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(final Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
|
||||
// Get the layout inflater
|
||||
LayoutInflater inflater = requireActivity().getLayoutInflater();
|
||||
|
||||
// Inflate and set the layout for the dialog
|
||||
// Pass null as the parent view because its going in the dialog layout
|
||||
View root = inflater.inflate(R.layout.dialog_rename_list, null);
|
||||
builder.setView(root)
|
||||
// Add action buttons
|
||||
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
onRenameListListener.sendRenameListName(etRenameListName.getText().toString());
|
||||
}
|
||||
})
|
||||
.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
RenameListDialogFragment.this.getDialog().cancel();
|
||||
}
|
||||
});
|
||||
|
||||
etRenameListName = (EditText) root.findViewById(R.id.et_renamed_list_name);
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
// Required to extend DialogFragment
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
try {
|
||||
onRenameListListener = (OnRenameListListener) getTargetFragment();
|
||||
if (onRenameListListener == null) {
|
||||
onRenameListListener = (OnRenameListListener) getActivity();
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
Log.e("CreateListDialogFragment", "onAttach: ClassCastException: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,128 @@
|
||||
package com.example.listify.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.chauthai.swipereveallayout.SwipeRevealLayout;
|
||||
import com.chauthai.swipereveallayout.ViewBinderHelper;
|
||||
import com.example.listify.AuthManager;
|
||||
import com.example.listify.ListPage;
|
||||
import com.example.listify.R;
|
||||
import com.example.listify.Requestor;
|
||||
import com.example.listify.data.List;
|
||||
import com.example.listify.data.ListShare;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
|
||||
import static com.example.listify.MainActivity.am;
|
||||
|
||||
public class ShareeSwipeableAdapter extends BaseAdapter {
|
||||
private Activity activity;
|
||||
private ArrayList<ListShare> sharees;
|
||||
private LayoutInflater inflater;
|
||||
private final ViewBinderHelper binderHelper;
|
||||
|
||||
public ShareeSwipeableAdapter(Activity activity, ArrayList<ListShare> sharees){
|
||||
binderHelper = new ViewBinderHelper();
|
||||
this.activity = activity;
|
||||
this.sharees = sharees;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return sharees.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return sharees.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
ViewHolder holder;
|
||||
|
||||
Properties configs = new Properties();
|
||||
try {
|
||||
configs = AuthManager.loadProperties(activity, "android.resource://" + activity.getPackageName() + "/raw/auths.json");
|
||||
} catch (IOException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
|
||||
if (inflater == null) {
|
||||
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
}
|
||||
if (convertView == null) {
|
||||
convertView = inflater.inflate(R.layout.shopping_lists_swipeable_name_item, null);
|
||||
|
||||
holder = new ViewHolder();
|
||||
holder.swipeLayout = (SwipeRevealLayout)convertView.findViewById(R.id.swipe_layout);
|
||||
holder.frontView = convertView.findViewById(R.id.front_layout);
|
||||
holder.deleteList = convertView.findViewById(R.id.delete_list);
|
||||
// holder.shareList = convertView.findViewById(R.id.share_list);
|
||||
holder.textView = (TextView) convertView.findViewById(R.id.shopping_list_name);
|
||||
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
final ListShare currSharee = sharees.get(position);
|
||||
|
||||
// Bind the view to the unique list ID
|
||||
binderHelper.bind(holder.swipeLayout, currSharee.getShareWithEmail());
|
||||
|
||||
holder.textView.setText(currSharee.getShareWithEmail());
|
||||
|
||||
holder.deleteList.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// holder.shareList.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
|
||||
holder.frontView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
private class ViewHolder {
|
||||
SwipeRevealLayout swipeLayout;
|
||||
View frontView;
|
||||
View deleteList;
|
||||
View shareList;
|
||||
TextView textView;
|
||||
}
|
||||
}
|
||||
@ -79,7 +79,7 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
||||
holder.swipeLayout = (SwipeRevealLayout)convertView.findViewById(R.id.swipe_layout);
|
||||
holder.frontView = convertView.findViewById(R.id.front_layout);
|
||||
holder.deleteList = convertView.findViewById(R.id.delete_list);
|
||||
holder.shareList = convertView.findViewById(R.id.share_list);
|
||||
// holder.shareList = convertView.findViewById(R.id.share_list);
|
||||
holder.listName = (TextView) convertView.findViewById(R.id.shopping_list_name);
|
||||
holder.itemCount = (TextView) convertView.findViewById(R.id.shopping_list_item_count);
|
||||
|
||||
@ -100,7 +100,11 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
||||
holder.listName.setText(curList.getName());
|
||||
}
|
||||
|
||||
holder.itemCount.setText(String.format("%d items", curList.getEntries().length));
|
||||
if (curList.getEntries() != null) {
|
||||
holder.itemCount.setText(String.format("%d items", curList.getEntries().length));
|
||||
} else {
|
||||
holder.itemCount.setText("0 items");
|
||||
}
|
||||
|
||||
holder.deleteList.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -120,50 +124,49 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
||||
}
|
||||
});
|
||||
|
||||
holder.shareList.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
View codeView = inflater.inflate(R.layout.activity_sharedemail, null);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setView(codeView);
|
||||
builder.setTitle("Share list");
|
||||
builder.setMessage("Please enter the email of the user who you want to share the list with.");
|
||||
builder.setPositiveButton("Submit", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
EditText sharedEmailText = (EditText) codeView.findViewById(R.id.editTextTextSharedEmail);
|
||||
String sharedEmail = sharedEmailText.getText().toString();
|
||||
ListShare listShare = new ListShare(curList.getListID(), sharedEmail, "Read, Write, Delete, Share");
|
||||
try {
|
||||
requestor.putObject(listShare);
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {}
|
||||
});
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
|
||||
Toast.makeText(activity, String.format("Share %s", curList.getName()), Toast.LENGTH_SHORT).show();
|
||||
|
||||
// Close the layout
|
||||
binderHelper.closeLayout(Integer.toString(curList.getListID()));
|
||||
}
|
||||
});
|
||||
// holder.shareList.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// View codeView = inflater.inflate(R.layout.activity_sharedemail, null);
|
||||
// AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
// builder.setView(codeView);
|
||||
// builder.setTitle("Share list");
|
||||
// builder.setMessage("Please enter the email of the user who you want to share the list with.");
|
||||
// builder.setPositiveButton("Submit", new DialogInterface.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(DialogInterface dialog, int which) {
|
||||
// EditText sharedEmailText = (EditText) codeView.findViewById(R.id.editTextTextSharedEmail);
|
||||
// String sharedEmail = sharedEmailText.getText().toString();
|
||||
// ListShare listShare = new ListShare(curList.getListID(), sharedEmail, "Read, Write, Delete, Share", null);
|
||||
// try {
|
||||
// requestor.putObject(listShare);
|
||||
// }
|
||||
// catch(Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(DialogInterface dialog, int which) {}
|
||||
// });
|
||||
// AlertDialog dialog = builder.create();
|
||||
// dialog.show();
|
||||
//
|
||||
// Toast.makeText(activity, String.format("Share %s", curList.getName()), Toast.LENGTH_SHORT).show();
|
||||
//
|
||||
// // Close the layout
|
||||
// binderHelper.closeLayout(Integer.toString(curList.getListID()));
|
||||
// }
|
||||
// });
|
||||
|
||||
holder.frontView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent listPage = new Intent(activity, ListPage.class);
|
||||
|
||||
// Send the list ID and list name
|
||||
listPage.putExtra("listID", curList.getListID());
|
||||
listPage.putExtra("listName", curList.getName());
|
||||
// Send the selected list
|
||||
listPage.putExtra("selectedList", curList);
|
||||
|
||||
activity.startActivity(listPage);
|
||||
}
|
||||
@ -176,7 +179,7 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
||||
SwipeRevealLayout swipeLayout;
|
||||
View frontView;
|
||||
View deleteList;
|
||||
View shareList;
|
||||
// View shareList;
|
||||
TextView listName;
|
||||
TextView itemCount;
|
||||
}
|
||||
|
||||
@ -1,26 +1,29 @@
|
||||
package com.example.listify.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class List {
|
||||
public class List implements Serializable {
|
||||
Integer listID;
|
||||
String name;
|
||||
String owner;
|
||||
long lastUpdated;
|
||||
final ListEntry[] entries;
|
||||
boolean shared;
|
||||
Integer uiPosition;
|
||||
|
||||
public List(Integer listID, String name, String owner, long lastUpdated, ListEntry[] entries, boolean shared) {
|
||||
public List(Integer listID, String name, String owner, long lastUpdated, ListEntry[] entries, boolean shared, Integer uiPosition) {
|
||||
this.listID = listID;
|
||||
this.name = name;
|
||||
this.owner = owner;
|
||||
this.lastUpdated = lastUpdated;
|
||||
this.entries = entries;
|
||||
this.shared = false;
|
||||
this.uiPosition = uiPosition;
|
||||
}
|
||||
|
||||
public List(Integer listID, String name, String owner, long lastUpdated) {
|
||||
this(listID, name, owner, lastUpdated, null, false);
|
||||
public List(Integer listID, String name, String owner, long lastUpdated, Integer uiPosition) {
|
||||
this(listID, name, owner, lastUpdated, null, false, uiPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -32,6 +35,7 @@ public class List {
|
||||
", lastUpdated=" + lastUpdated +
|
||||
", entries=" + Arrays.toString(entries) +
|
||||
", shared=" + shared +
|
||||
", uiPosition=" + uiPosition +
|
||||
'}';
|
||||
}
|
||||
|
||||
@ -67,10 +71,6 @@ public class List {
|
||||
this.lastUpdated = lastUpdated;
|
||||
}
|
||||
|
||||
public ListEntry[] getEntries() {
|
||||
return entries;
|
||||
}
|
||||
|
||||
public boolean isShared() {
|
||||
return shared;
|
||||
}
|
||||
@ -78,4 +78,16 @@ public class List {
|
||||
public void setShared(boolean shared) {
|
||||
this.shared = shared;
|
||||
}
|
||||
|
||||
public Integer getUiPosition() {
|
||||
return uiPosition;
|
||||
}
|
||||
|
||||
public void setUiPosition(Integer uiPosition) {
|
||||
this.uiPosition = uiPosition;
|
||||
}
|
||||
|
||||
public ListEntry[] getEntries() {
|
||||
return entries;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
package com.example.listify.data;
|
||||
|
||||
// Info on List to copy
|
||||
public class ListDuplicate {
|
||||
Integer listID;
|
||||
String name;
|
||||
|
||||
public ListDuplicate(Integer listID, String name) {
|
||||
this.listID = listID;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ListDuplicate{" +
|
||||
"listID=" + listID +
|
||||
", name='" + name + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Integer getListID() {
|
||||
return listID;
|
||||
}
|
||||
|
||||
public void setListID(Integer listID) {
|
||||
this.listID = listID;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
package com.example.listify.data;
|
||||
|
||||
public class ListEntry {
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ListEntry implements Serializable {
|
||||
Integer listID;
|
||||
Integer productID;
|
||||
Integer quantity;
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
package com.example.listify.data;
|
||||
|
||||
public class ListReposition {
|
||||
Integer listID;
|
||||
Integer newPosition;
|
||||
|
||||
public ListReposition(Integer listID, Integer newPosition) {
|
||||
this.listID = listID;
|
||||
this.newPosition = newPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ListReposition{" +
|
||||
"listID=" + listID +
|
||||
", newPosition=" + newPosition +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Integer getListID() {
|
||||
return listID;
|
||||
}
|
||||
|
||||
public void setListID(Integer listID) {
|
||||
this.listID = listID;
|
||||
}
|
||||
|
||||
public Integer getNewPosition() {
|
||||
return newPosition;
|
||||
}
|
||||
|
||||
public void setNewPosition(Integer newPosition) {
|
||||
this.newPosition = newPosition;
|
||||
}
|
||||
}
|
||||
@ -9,9 +9,10 @@ import java.util.Map;
|
||||
public class ListShare {
|
||||
Integer listID;
|
||||
String shareWithEmail;
|
||||
final ListShare[] other;
|
||||
Integer permissionLevel;
|
||||
|
||||
private static final Map<Integer, String> keysToPerms;
|
||||
|
||||
static {
|
||||
//All keys should be a prime number > 1
|
||||
//All keys need to be maintained here and in List module->ListPermissions class on the Lambda side
|
||||
@ -22,18 +23,20 @@ public class ListShare {
|
||||
keysToPermsTemp.put(7, "share");
|
||||
keysToPerms = Collections.unmodifiableMap(keysToPermsTemp);
|
||||
}
|
||||
|
||||
public ListShare(Integer listID, String shareWithEmail, Integer permissionLevel) {
|
||||
|
||||
public ListShare(Integer listID, String shareWithEmail, Integer permissionLevel, ListShare[] other) {
|
||||
this.listID = listID;
|
||||
this.shareWithEmail = shareWithEmail;
|
||||
this.permissionLevel = permissionLevel;
|
||||
this.other = other;
|
||||
}
|
||||
|
||||
public ListShare(Integer listID, String shareWithEmail, String permissionsRaw) {
|
||||
public ListShare(Integer listID, String shareWithEmail, String permissionsRaw, ListShare[] other) {
|
||||
String permissions = permissionsRaw.toLowerCase();
|
||||
this.listID = listID;
|
||||
this.shareWithEmail = shareWithEmail;
|
||||
permissionLevel = 1;
|
||||
this.other = other;
|
||||
for (Map.Entry<Integer, String> keytoPermEntry: keysToPerms.entrySet()) {
|
||||
if (permissions.contains(keytoPermEntry.getValue())) {
|
||||
permissionLevel *= keytoPermEntry.getKey();
|
||||
@ -62,6 +65,7 @@ public class ListShare {
|
||||
}
|
||||
toReturn.append("]}");
|
||||
return toReturn.toString();
|
||||
|
||||
}
|
||||
|
||||
public Integer getListID() {
|
||||
@ -79,7 +83,11 @@ public class ListShare {
|
||||
public void setShareWithEmail(String shareWithEmail) {
|
||||
this.shareWithEmail = shareWithEmail;
|
||||
}
|
||||
|
||||
|
||||
public ListShare[] getEntries() {
|
||||
return other;
|
||||
}
|
||||
|
||||
public Integer getPermissionLevel() {
|
||||
return permissionLevel;
|
||||
}
|
||||
@ -87,5 +95,4 @@ public class ListShare {
|
||||
public void setPermissionLevel(Integer permissionLevel) {
|
||||
this.permissionLevel = permissionLevel;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ public class HomeFragment extends Fragment implements CreateListDialogFragment.O
|
||||
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
SynchronousReceiver<Integer> idReceiver = new SynchronousReceiver<>();
|
||||
|
||||
List newList = new List(-1, name, "user filled by lambda", Instant.now().toEpochMilli());
|
||||
List newList = new List(-1, name, "user filled by lambda", Instant.now().toEpochMilli() , -1);
|
||||
|
||||
try {
|
||||
requestor.postObject(newList, idReceiver, idReceiver);
|
||||
|
||||
@ -67,6 +67,17 @@ public class ProfileFragment extends Fragment {
|
||||
Log.i("Authentication", e.toString());
|
||||
}
|
||||
}
|
||||
else {
|
||||
View errorView = getLayoutInflater().inflate(R.layout.activity_erroralert, null);
|
||||
AlertDialog.Builder builder2 = new AlertDialog.Builder(getActivity());
|
||||
builder2.setView(errorView);
|
||||
builder2.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {}
|
||||
});
|
||||
AlertDialog dialog2 = builder2.create();
|
||||
dialog2.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
package com.example.listify.ui.store;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.widget.TextView;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.example.listify.R;
|
||||
|
||||
public class StoreFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View root = inflater.inflate(R.layout.fragment_stores, container, false);
|
||||
|
||||
TextView krogerText = (TextView) root.findViewById(R.id.textView11);
|
||||
krogerText.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
gotoUrl("https://www.kroger.com/");
|
||||
}
|
||||
});
|
||||
|
||||
TextView kohlsText = (TextView) root.findViewById(R.id.textView12);
|
||||
krogerText.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
gotoUrl("https://www.kohls.com/");
|
||||
}
|
||||
});
|
||||
|
||||
TextView ebayText = (TextView) root.findViewById(R.id.textView13);
|
||||
krogerText.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
gotoUrl("https://www.ebay.com/");
|
||||
}
|
||||
});
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
private void gotoUrl(String url) {
|
||||
Uri u = Uri.parse(url);
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, u));
|
||||
}
|
||||
}
|
||||
10
Listify/app/src/main/res/drawable/ic_baseline_store_24.xml
Normal file
10
Listify/app/src/main/res/drawable/ic_baseline_store_24.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M20,4L4,4v2h16L20,4zM21,14v-2l-1,-5L4,7l-1,5v2h1v6h10v-6h4v6h2v-6h1zM12,18L6,18v-4h6v4z"/>
|
||||
</vector>
|
||||
18
Listify/app/src/main/res/layout/activity_erroralert.xml
Normal file
18
Listify/app/src/main/res/layout/activity_erroralert.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView9"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="Incorrect password. Try again."
|
||||
android:textSize="15sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -11,8 +11,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="51dp"
|
||||
android:text="Submit"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textView6"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView6"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textView7"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView7"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword2" />
|
||||
|
||||
<EditText
|
||||
@ -46,8 +46,8 @@
|
||||
android:ems="10"
|
||||
android:hint="Confirm New Password"
|
||||
android:inputType="textPassword"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textView6"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView6"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textView7"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView7"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword" />
|
||||
|
||||
<TextView
|
||||
@ -56,7 +56,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:text=""
|
||||
app:layout_constraintBottom_toTopOf="@+id/button1"
|
||||
app:layout_constraintBottom_toTopOf="@+id/textView7"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
@ -69,4 +69,13 @@
|
||||
android:text="Please enter your email address."
|
||||
app:layout_constraintBottom_toTopOf="@+id/editTextTextEmailAddress"
|
||||
app:layout_constraintEnd_toEndOf="@+id/editTextTextEmailAddress" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView7"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
app:layout_constraintBottom_toTopOf="@+id/button1"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -13,7 +13,7 @@
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<LinearLayout
|
||||
<!--<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
android:text="Share"
|
||||
android:textSize="10sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>-->
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/refresh_list"
|
||||
@ -48,9 +48,18 @@
|
||||
android:layout_height="600dp"
|
||||
android:layout_marginTop="50dp"
|
||||
android:paddingBottom="20dp"/>
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewEmpty2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:textSize="20sp"
|
||||
android:text="This list is empty."/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
22
Listify/app/src/main/res/layout/activity_listofsharees.xml
Normal file
22
Listify/app/src/main/res/layout/activity_listofsharees.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress_loading_list_items"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/listOfSharees"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="0dp" />
|
||||
|
||||
</RelativeLayout>
|
||||
@ -12,8 +12,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="53dp"
|
||||
android:text="Log in"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textView5"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView5"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textView8"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView8"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button2" />
|
||||
|
||||
<Button
|
||||
@ -32,8 +32,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="72dp"
|
||||
android:text="Forgot password? Click here."
|
||||
app:layout_constraintEnd_toStartOf="@+id/textView5"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView5"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textView8"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView8"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName" />
|
||||
|
||||
<EditText
|
||||
@ -73,6 +73,15 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
app:layout_constraintBottom_toTopOf="@+id/textView8"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView8"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
app:layout_constraintBottom_toTopOf="@+id/button3"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
@ -12,8 +12,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="65dp"
|
||||
android:text="Sign up"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textView3"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView3"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textView4"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView4"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword2" />
|
||||
|
||||
<Button
|
||||
@ -77,6 +77,15 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:text=""
|
||||
app:layout_constraintBottom_toTopOf="@+id/textView4"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
app:layout_constraintBottom_toTopOf="@+id/button2"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
22
Listify/app/src/main/res/layout/dialog_rename_list.xml
Normal file
22
Listify/app/src/main/res/layout/dialog_rename_list.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Rename List"
|
||||
android:layout_gravity="center"
|
||||
android:textSize="20sp"
|
||||
android:layout_marginTop="5dp"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_renamed_list_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:singleLine="true"
|
||||
android:hint="@string/new_list_name"/>
|
||||
|
||||
</LinearLayout>
|
||||
51
Listify/app/src/main/res/layout/fragment_stores.xml
Normal file
51
Listify/app/src/main/res/layout/fragment_stores.xml
Normal file
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView10"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="22dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:text="Stores available:"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView11"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="Kroger"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView10"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView10" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView12"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="Kohl's"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView11"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView11" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView13"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="eBay"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView12"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView12" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -17,12 +17,12 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/share_list"
|
||||
android:src="@drawable/ic_baseline_share_24"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:background="@color/colorAccent"/>
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/share_list"-->
|
||||
<!-- android:src="@drawable/ic_baseline_share_24"-->
|
||||
<!-- android:layout_width="50dp"-->
|
||||
<!-- android:layout_height="50dp"-->
|
||||
<!-- android:background="@color/colorAccent"/>-->
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/delete_list"
|
||||
|
||||
@ -14,6 +14,11 @@
|
||||
android:icon="@drawable/ic_baseline_person_24"
|
||||
android:title="@string/menu_profile" />
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_stores"
|
||||
android:icon="@drawable/ic_baseline_store_24"
|
||||
android:title="@string/menu_stores" />
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_logout"
|
||||
android:title="Sign out"
|
||||
|
||||
@ -17,6 +17,12 @@
|
||||
android:label="@string/menu_profile"
|
||||
tools:layout="@layout/fragment_profile" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_stores"
|
||||
android:name="com.example.listify.ui.store.StoreFragment"
|
||||
android:label="@string/menu_stores"
|
||||
tools:layout="@layout/fragment_stores" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_gallery"
|
||||
android:name="com.example.listify.ui.gallery.GalleryFragment"
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
|
||||
<string name="menu_home">My Lists</string>
|
||||
<string name="menu_profile">Profile</string>
|
||||
<string name="menu_stores">Stores</string>
|
||||
<string name="menu_gallery">Gallery</string>
|
||||
<string name="menu_slideshow">Slideshow</string>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user