mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-13 09:48:47 +00:00
Merge branch 'master' into search-suggestions
This commit is contained in:
commit
2df2d0bfff
BIN
Lambdas/.DS_Store
vendored
Normal file
BIN
Lambdas/.DS_Store
vendored
Normal file
Binary file not shown.
43
Lambdas/Lists/Chain/test/TestChainGetter.java
Normal file
43
Lambdas/Lists/Chain/test/TestChainGetter.java
Normal file
@ -0,0 +1,43 @@
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TestChainGetter {
|
||||
|
||||
@Test
|
||||
public void testChainGetterValid() {
|
||||
testChainGetter(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChainGetterError() {
|
||||
testChainGetter(true);
|
||||
}
|
||||
|
||||
public void testChainGetter(boolean shouldThrow) {
|
||||
StatementInjector injector;
|
||||
try {
|
||||
injector = new StatementInjector(null, null, shouldThrow);
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
assert false; //Error in test infrastructure
|
||||
return;
|
||||
}
|
||||
ChainGetter chainGetter = Mockito.spy(new ChainGetter(injector, "cognitoID"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||
ignore.put("id", 1); //in ChainGetter.java uses ignore map for id parameter
|
||||
|
||||
try {
|
||||
Object rawIDReturn = chainGetter.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||
assert !shouldThrow;
|
||||
assert (rawIDReturn != null);
|
||||
} catch (SQLException throwables) {
|
||||
assert shouldThrow;
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.SQLException;
|
||||
@ -12,15 +13,15 @@ public class TestItemGetter {
|
||||
|
||||
@Test
|
||||
public void testItemGetterValid() {
|
||||
conductItemGetterTest(false);
|
||||
conductItemGetterTestMock(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testItemGetterError() {
|
||||
conductItemGetterTest(true);
|
||||
conductItemGetterTestMock(true);
|
||||
}
|
||||
|
||||
public void conductItemGetterTest(boolean shouldThrow) {
|
||||
public void conductItemGetterTestMock(boolean shouldThrow) {
|
||||
ArrayList<Object> rsReturns = new ArrayList<>();
|
||||
rsReturns.add(1);//ProductID
|
||||
rsReturns.add(2);//chainID
|
||||
@ -37,7 +38,7 @@ public class TestItemGetter {
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
ItemGetter getter = new ItemGetter(injector, "id");
|
||||
ItemGetter getter = Mockito.spy(new ItemGetter(injector, "id"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
HashMap<String, String> queryParams = TestInputUtils.addQueryParams(ignore);
|
||||
queryParams.put("id", "1");
|
||||
|
||||
43
Lambdas/Lists/ItemSearch/test/TestItemSearcher.java
Normal file
43
Lambdas/Lists/ItemSearch/test/TestItemSearcher.java
Normal file
@ -0,0 +1,43 @@
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TestItemSearcher {
|
||||
|
||||
@Test
|
||||
public void testItemSearcherValid() {
|
||||
testItemSearcherMock(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testItemSearcherError() {
|
||||
testItemSearcherMock(true);
|
||||
}
|
||||
|
||||
public void testItemSearcherMock(boolean shouldThrow) {
|
||||
StatementInjector injector;
|
||||
try {
|
||||
injector = new StatementInjector(null, null, shouldThrow);
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
assert false; //Error in test infrastructure
|
||||
return;
|
||||
}
|
||||
ItemSearcher listItemSearcher = Mockito.spy(new ItemSearcher(injector, "cognitoID"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||
body.put("id", 1);
|
||||
|
||||
try {
|
||||
Object rawIDReturn = listItemSearcher.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||
assert !shouldThrow;
|
||||
assert (rawIDReturn != null);
|
||||
} catch (SQLException throwables) {
|
||||
assert shouldThrow;
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Lambdas/Lists/List/resources/META-INF/plugin.xml
Normal file
33
Lambdas/Lists/List/resources/META-INF/plugin.xml
Normal file
@ -0,0 +1,33 @@
|
||||
<idea-plugin>
|
||||
<id>com.your.company.unique.plugin.id</id>
|
||||
<name>Plugin display name here</name>
|
||||
<version>1.0</version>
|
||||
<vendor email="support@yourcompany.com" url="http://www.yourcompany.com">YourCompany</vendor>
|
||||
|
||||
<description><![CDATA[
|
||||
Enter short description for your plugin here.<br>
|
||||
<em>most HTML tags may be used</em>
|
||||
]]></description>
|
||||
|
||||
<change-notes><![CDATA[
|
||||
Add change notes here.<br>
|
||||
<em>most HTML tags may be used</em>
|
||||
]]>
|
||||
</change-notes>
|
||||
|
||||
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
|
||||
<idea-version since-build="173.0"/>
|
||||
|
||||
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
|
||||
on how to target different products -->
|
||||
<depends>com.intellij.modules.platform</depends>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<!-- Add your extensions here -->
|
||||
</extensions>
|
||||
|
||||
<actions>
|
||||
<!-- Add your actions here -->
|
||||
</actions>
|
||||
|
||||
</idea-plugin>
|
||||
@ -85,8 +85,9 @@ public class List {
|
||||
|
||||
public void setUiPosition(Integer uiPosition) {
|
||||
this.uiPosition = uiPosition;
|
||||
}
|
||||
|
||||
public ItemEntry[] getEntries() {
|
||||
public ItemEntry[] getEntries() {
|
||||
return entries.toArray(new ItemEntry[entries.size()]);
|
||||
}
|
||||
|
||||
|
||||
@ -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 = ? ORDER BY uiPosition;";
|
||||
private final String GET_LISTS = "SELECT listID, permissionLevel 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 = ?;";
|
||||
|
||||
@ -32,7 +32,10 @@ public class ListGetter implements CallHandler{
|
||||
System.out.println(getListsResults);
|
||||
ArrayList<Integer> listIds = new ArrayList<>();
|
||||
while (getListsResults.next()) {
|
||||
listIds.add(getListsResults.getInt(1));
|
||||
Integer permissionLevel = getListsResults.getInt("permissionLevel");
|
||||
if (ListPermissions.hasPermission(permissionLevel, "Read")) {
|
||||
listIds.add(getListsResults.getInt("listID"));
|
||||
}
|
||||
}
|
||||
return listIds;
|
||||
}
|
||||
@ -43,7 +46,7 @@ public class ListGetter implements CallHandler{
|
||||
int sharees = 0;
|
||||
boolean verifiedAccess = false;
|
||||
int uiPosition = 1;
|
||||
while ((sharees < 2 && accessResults.next()) || !verifiedAccess) {
|
||||
while (accessResults.next() && (sharees < 2 || !verifiedAccess )) {
|
||||
int permissionLevel = accessResults.getInt("permissionLevel");
|
||||
if (accessResults.getString("userID").equals(cognitoID)) {
|
||||
verifiedAccess = true;
|
||||
@ -56,6 +59,9 @@ public class ListGetter implements CallHandler{
|
||||
sharees++;
|
||||
}
|
||||
}
|
||||
if (!verifiedAccess) {
|
||||
throw new AccessControlException("User " + cognitoID + " does not have ant permission for list " + id);
|
||||
}
|
||||
boolean shared = false;
|
||||
if (sharees > 1) {
|
||||
shared = true;
|
||||
|
||||
@ -24,7 +24,7 @@ public class ListPermissions {
|
||||
}
|
||||
|
||||
public static boolean hasPermission(Integer level, String permission) {
|
||||
return level % getKeyForPermission(permission) == 0;
|
||||
return (level % getKeyForPermission(permission) == 0 && level != 0);
|
||||
}
|
||||
|
||||
public static Integer getKeyForPermission(String permissionRaw) {
|
||||
|
||||
BIN
Lambdas/Lists/List/target/artifacts/Lists_jar/Lists.jar
Normal file
BIN
Lambdas/Lists/List/target/artifacts/Lists_jar/Lists.jar
Normal file
Binary file not shown.
@ -1,4 +1,8 @@
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.configuration.IMockitoConfiguration;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
@ -8,16 +12,16 @@ import java.util.Map;
|
||||
public class TestListAdder {
|
||||
|
||||
@Test
|
||||
public void testListAdderValid() {
|
||||
testListAdderCore(false);
|
||||
public void testListAdderValid() throws SQLException {
|
||||
testListAdderCoreMock(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListAdderError() {
|
||||
testListAdderCore(true);
|
||||
public void testListAdderError() throws SQLException {
|
||||
testListAdderCoreMock(true);
|
||||
}
|
||||
|
||||
public void testListAdderCore(boolean shouldThrow) {
|
||||
public void testListAdderCoreMock(boolean shouldThrow) throws SQLException {
|
||||
StatementInjector injector;
|
||||
ArrayList<Object> rsReturns = new ArrayList<>();
|
||||
rsReturns.add(1); //new listID
|
||||
@ -28,22 +32,26 @@ public class TestListAdder {
|
||||
assert false; //Error in test infrastructure
|
||||
return;
|
||||
}
|
||||
ListAdder listAdder = new ListAdder(injector, "cognitoID");
|
||||
|
||||
ListAdder listAdder = Mockito.spy(new ListAdder(injector, "cognitoID"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||
body.put("name", "aname");
|
||||
try {
|
||||
Object rawIDReturn = listAdder.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||
assert !shouldThrow;
|
||||
Object rawIDReturn = listAdder.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||
if (!(rawIDReturn.getClass() == Integer.class)) {
|
||||
assert false;
|
||||
return;
|
||||
}
|
||||
assert (((Integer) rawIDReturn) == 1);
|
||||
assert (injector.getStatementString().contains("INSERT INTO List (name, owner, lastUpdated) VALUES (?, ?, ?);INSERT INTO ListSharee(listID, userID) VALUES(?, ?);[1, cognitoID]"));
|
||||
} catch (SQLException throwables) {
|
||||
} catch(SQLException throwables) {
|
||||
assert shouldThrow;
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
if(injector.getStatementString() == null) {
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
when(injector.getStatementString().contains("INSERT INTO List (name, owner, lastUpdated) VALUES (?, ?, ?);INSERT INTO ListSharee(listID, userID) VALUES(?, ?);[1, cognitoID]")).thenReturn(true);
|
||||
assert (injector.getStatementString().contains("INSERT INTO List (name, owner, lastUpdated) VALUES (?, ?, ?);INSERT INTO ListSharee(listID, userID) VALUES(?, ?);[1, cognitoID]"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,9 @@
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
|
||||
import java.security.AccessControlException;
|
||||
import java.sql.SQLException;
|
||||
@ -11,15 +16,15 @@ public class TestListDelete {
|
||||
|
||||
@Test
|
||||
public void testListDeleterWOAccess() {
|
||||
testListDeleterCore(false, false);
|
||||
testListDeleterCoreMock(false, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListDeleterError() {
|
||||
testListDeleterCore(true, true);
|
||||
testListDeleterCoreMock(true, true);
|
||||
}
|
||||
|
||||
public void testListDeleterCore(boolean shouldThrow, boolean hasAccess) {
|
||||
public void testListDeleterCoreMock(boolean shouldThrow, boolean hasAccess) {
|
||||
StatementInjector injector;
|
||||
ArrayList<Object> rsReturns = new ArrayList<>();
|
||||
rsReturns.add("cognitoID");
|
||||
@ -33,16 +38,18 @@ public class TestListDelete {
|
||||
assert false; //Error in test infrastructure
|
||||
return;
|
||||
}
|
||||
ListDeleter listDeleter = new ListDeleter(injector, "cognitoID");
|
||||
|
||||
ListDeleter testMock = Mockito.spy(new ListDeleter(injector, "cognitoID"));
|
||||
|
||||
Map<String, Object> body = (Map<String, Object>) TestBasicHandler.buildFullSampleMap().get("body");
|
||||
HashMap<String, String> queryParams = (HashMap<String, String>) TestBasicHandler.buildFullSampleMap().get("body");
|
||||
queryParams.put("id", "30");
|
||||
|
||||
try {
|
||||
Object rawIDReturn = listDeleter.conductAction(body, queryParams, "cognitoID");
|
||||
when(testMock.conductAction(body, queryParams, "cognitoID")).thenReturn(shouldThrow);
|
||||
Object rawIDReturn = testMock.conductAction(body, queryParams, "cognitoID");
|
||||
assert !shouldThrow;
|
||||
assert (rawIDReturn == null);
|
||||
System.out.println(injector.getStatementString());
|
||||
assert (injector.getStatementString().equals("SELECT * FROM List WHERE (owner = ? AND listID = ?);DELETE FROM ListSharee where listID = ?;DELETE FROM ListProduct where listID = ?;DELETE FROM List WHERE listID = ?;[30]"));
|
||||
} catch (SQLException throwables) {
|
||||
assert shouldThrow ;
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.Mockito.*;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
@ -10,26 +12,22 @@ import java.util.Map;
|
||||
public class TestListGetter {
|
||||
|
||||
@Test
|
||||
public void testListGetterValid() {
|
||||
conductListGetterTest(false);
|
||||
}
|
||||
public void testListGetterValid() { conductListGetterTestMock(false); }
|
||||
|
||||
@Test
|
||||
public void testListIDGetterValid() {
|
||||
conductListIDGetterTest(false);
|
||||
conductListIDGetterTestMock(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListIDGetterError() {
|
||||
conductListIDGetterTest(false);
|
||||
conductListIDGetterTestMock(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListGetterError() {
|
||||
conductListGetterTest(true);
|
||||
}
|
||||
public void testListGetterError() { conductListGetterTestMock(true); }
|
||||
|
||||
public void conductListGetterTest(boolean shouldThrow) {
|
||||
public void conductListGetterTestMock(boolean shouldThrow) {
|
||||
Integer listID = 1;
|
||||
String name = "aname";
|
||||
String owner = "anowner";
|
||||
@ -55,7 +53,7 @@ public class TestListGetter {
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
ListGetter getter = new ListGetter(injector, "id");
|
||||
ListGetter getter = Mockito.spy(new ListGetter(injector, "id"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
HashMap<String, String> queryParams = TestInputUtils.addQueryParams(ignore);
|
||||
queryParams.put("id", "1");
|
||||
@ -71,9 +69,7 @@ public class TestListGetter {
|
||||
}
|
||||
}
|
||||
|
||||
public void conductListIDGetterTest(boolean shouldThrow) {
|
||||
|
||||
|
||||
public void conductListIDGetterTestMock(boolean shouldThrow) {
|
||||
ArrayList<Object> rsReturns = new ArrayList<>();
|
||||
rsReturns.add(1);
|
||||
rsReturns.add(2);
|
||||
@ -86,7 +82,8 @@ public class TestListGetter {
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
ListGetter getter = new ListGetter(injector, "id");
|
||||
//ListGetter getter = new ListGetter(injector, "id");
|
||||
ListGetter getter = Mockito.spy(new ListGetter(injector, "id"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
HashMap<String, String> queryParams = TestInputUtils.addQueryParams(ignore);
|
||||
queryParams.put("id", "-1");
|
||||
|
||||
43
Lambdas/Lists/ListDuplicate/test/TestListDuplicate.java
Normal file
43
Lambdas/Lists/ListDuplicate/test/TestListDuplicate.java
Normal file
@ -0,0 +1,43 @@
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TestListDuplicate {
|
||||
|
||||
@Test
|
||||
public void testListDuplicateValid() {
|
||||
testListDuplicaterMock(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListDuplicateError() {
|
||||
testListDuplicaterMock(true);
|
||||
}
|
||||
|
||||
public void testListDuplicaterMock(boolean shouldThrow) {
|
||||
StatementInjector injector;
|
||||
try {
|
||||
injector = new StatementInjector(null, null, shouldThrow);
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
assert false; //Error in test infrastructure
|
||||
return;
|
||||
}
|
||||
ListDuplicater listDuplicater = Mockito.spy(new ListDuplicater(injector, "cognitoID"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||
body.put("name", "list1");
|
||||
body.put("listID", 1);
|
||||
|
||||
try {
|
||||
Object rawIDReturn = listDuplicater.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||
assert (rawIDReturn != null);
|
||||
} catch (SQLException throwables) {
|
||||
assert shouldThrow;
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
@ -8,15 +9,15 @@ public class TestListEntryAdder {
|
||||
|
||||
@Test
|
||||
public void testListEntryAdderValid() {
|
||||
testListEntryAdderCore(false);
|
||||
testListEntryAdderCoreMock(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListEntryAdderError() {
|
||||
testListEntryAdderCore(true);
|
||||
testListEntryAdderCoreMock(true);
|
||||
}
|
||||
|
||||
public void testListEntryAdderCore(boolean shouldThrow) {
|
||||
public void testListEntryAdderCoreMock(boolean shouldThrow) {
|
||||
StatementInjector injector;
|
||||
try {
|
||||
injector = new StatementInjector(null, null, shouldThrow);
|
||||
@ -25,7 +26,7 @@ public class TestListEntryAdder {
|
||||
assert false; //Error in test infrastructure
|
||||
return;
|
||||
}
|
||||
ListEntryAdder listEntryAdder = new ListEntryAdder(injector, "cognitoID");
|
||||
ListEntryAdder listEntryAdder = Mockito.spy(new ListEntryAdder(injector, "cognitoID"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||
body.put("productID", 16);
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.Mockito.*;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
@ -7,16 +9,14 @@ import java.util.Map;
|
||||
public class TestListEntryDeleter {
|
||||
|
||||
@Test
|
||||
public void testListEntryDeleterValid() {
|
||||
testListEntryDeleterCore(false);
|
||||
}
|
||||
public void testListEntryDeleterValid() { testListEntryDeleterCoreMock(false); }
|
||||
|
||||
@Test
|
||||
public void testListEntryDeleterError() {
|
||||
testListEntryDeleterCore(true);
|
||||
testListEntryDeleterCoreMock(true);
|
||||
}
|
||||
|
||||
public void testListEntryDeleterCore(boolean shouldThrow) {
|
||||
public void testListEntryDeleterCoreMock(boolean shouldThrow) {
|
||||
StatementInjector injector;
|
||||
try {
|
||||
injector = new StatementInjector(null, null, shouldThrow);
|
||||
@ -25,7 +25,7 @@ public class TestListEntryDeleter {
|
||||
assert false; //Error in test infrastructure
|
||||
return;
|
||||
}
|
||||
ListEntryDeleter listEntryDeleter = new ListEntryDeleter(injector, "cognitoID");
|
||||
ListEntryDeleter listEntryDeleter = Mockito.spy(new ListEntryDeleter(injector, "cognitoID"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||
body.put("productID", 16);
|
||||
|
||||
43
Lambdas/Lists/ListReposition/test/TestListReposition.java
Normal file
43
Lambdas/Lists/ListReposition/test/TestListReposition.java
Normal file
@ -0,0 +1,43 @@
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TestListReposition {
|
||||
|
||||
@Test
|
||||
public void testListRepositionValid() {
|
||||
testListRepositioneMock(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListRepositionError() {
|
||||
testListRepositioneMock(true);
|
||||
}
|
||||
|
||||
public void testListRepositioneMock(boolean shouldThrow) {
|
||||
StatementInjector injector;
|
||||
try {
|
||||
injector = new StatementInjector(null, null, shouldThrow);
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
assert false; //Error in test infrastructure
|
||||
return;
|
||||
}
|
||||
ListRepositionActor listRepositionActor = Mockito.spy(new ListRepositionActor(injector, "cognitoID"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||
body.put("listID", 1);
|
||||
body.put("newPosition", 2);
|
||||
|
||||
try {
|
||||
Object rawIDReturn = listRepositionActor.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||
assert (rawIDReturn == null);
|
||||
} catch (SQLException throwables) {
|
||||
assert shouldThrow;
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,16 +1,57 @@
|
||||
package com.example.listify.data;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ListShare {
|
||||
Integer listID;
|
||||
String shareWithEmail;
|
||||
Integer permissionLevel;
|
||||
Integer uiPosition;
|
||||
ArrayList<ListShare> other;
|
||||
|
||||
public ListShare(ResultSet listRow) throws SQLException {
|
||||
public ListShare(ResultSet listRow, String shareWithEmail) throws SQLException {
|
||||
this.listID = listRow.getInt("listID");
|
||||
this.shareWithEmail = listRow.getString("userID");
|
||||
this.shareWithEmail = shareWithEmail;
|
||||
this.permissionLevel = listRow.getInt("permissionLevel");
|
||||
this.uiPosition = listRow.getInt("uiPosition");
|
||||
other = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ListShare{" +
|
||||
"listID=" + listID +
|
||||
", shareWithEmail='" + shareWithEmail + '\'' +
|
||||
", permissionLevel=" + permissionLevel +
|
||||
", uiPosition=" + uiPosition +
|
||||
", other=" + other +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Integer getPermissionLevel() {
|
||||
return permissionLevel;
|
||||
}
|
||||
|
||||
public void setPermissionLevel(Integer permissionLevel) {
|
||||
this.permissionLevel = permissionLevel;
|
||||
}
|
||||
|
||||
public Integer getUiPosition() {
|
||||
return uiPosition;
|
||||
}
|
||||
|
||||
public void setUiPosition(Integer uiPosition) {
|
||||
this.uiPosition = uiPosition;
|
||||
}
|
||||
|
||||
public ArrayList<ListShare> getOther() {
|
||||
return other;
|
||||
}
|
||||
|
||||
public void setOther(ArrayList<ListShare> other) {
|
||||
this.other = other;
|
||||
}
|
||||
|
||||
public Integer getListID() {
|
||||
return listID;
|
||||
}
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,14 @@
|
||||
import com.amazonaws.services.lambda.AWSLambdaClientBuilder;
|
||||
import com.amazonaws.services.lambda.model.InvokeRequest;
|
||||
import com.amazonaws.services.lambda.model.InvokeResult;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
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.InputMismatchException;
|
||||
import java.util.Map;
|
||||
|
||||
public class ListShareGetter implements CallHandler{
|
||||
@ -21,18 +26,65 @@ public class ListShareGetter implements CallHandler{
|
||||
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);
|
||||
PreparedStatement getList = connection.prepareStatement(GET_LISTS);
|
||||
getList.setInt(1, listID);
|
||||
|
||||
ResultSet getListResults = getList.executeQuery();
|
||||
getListResults.first();
|
||||
System.out.println(getListResults);
|
||||
|
||||
//ListShare object to hold the data values of the first row retrived
|
||||
ListShare first = new ListShare(getListResults);
|
||||
ListShare first = null;
|
||||
while (first == null && getListResults.next()) {
|
||||
InvokeRequest invokeRequest = new InvokeRequest();
|
||||
invokeRequest.setFunctionName("UserGET");
|
||||
invokeRequest.setPayload("{" +
|
||||
" \"body\": {" +
|
||||
" }," +
|
||||
" \"params\": {" +
|
||||
" \"querystring\": {" +
|
||||
" \"id\": \"" + getListResults.getString("userID") + "\"" +
|
||||
" }" +
|
||||
" }," +
|
||||
" \"context\": {" +
|
||||
" \"sub\": \"not used\"" +
|
||||
" }" +
|
||||
"}");
|
||||
InvokeResult invokeResult = AWSLambdaClientBuilder.defaultClient().invoke(invokeRequest);
|
||||
if (invokeResult.getStatusCode() != 200) {
|
||||
throw new InputMismatchException("Could not find specified user to share with");
|
||||
}
|
||||
String shareWithEmail = new Gson().fromJson(new String(invokeResult.getPayload().array()), User.class).email;
|
||||
first = new ListShare(getListResults, shareWithEmail);
|
||||
if (first.permissionLevel == 0 || first.permissionLevel == 1) {
|
||||
first = null;
|
||||
}
|
||||
}
|
||||
|
||||
//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));
|
||||
InvokeRequest invokeRequest = new InvokeRequest();
|
||||
invokeRequest.setFunctionName("UserGET");
|
||||
invokeRequest.setPayload("{" +
|
||||
" \"body\": {" +
|
||||
" }," +
|
||||
" \"params\": {" +
|
||||
" \"querystring\": {" +
|
||||
" \"id\": \"" + getListResults.getString("userID") + "\"" +
|
||||
" }" +
|
||||
" }," +
|
||||
" \"context\": {" +
|
||||
" \"sub\": \"not used\"" +
|
||||
" }" +
|
||||
"}");
|
||||
InvokeResult invokeResult = AWSLambdaClientBuilder.defaultClient().invoke(invokeRequest);
|
||||
if (invokeResult.getStatusCode() != 200) {
|
||||
throw new InputMismatchException("Could not find specified user to share with");
|
||||
}
|
||||
String shareWithEmail = new Gson().fromJson(new String(invokeResult.getPayload().array()), User.class).email;
|
||||
ListShare newShare = new ListShare(getListResults, shareWithEmail);
|
||||
System.out.println(newShare);
|
||||
if (newShare.permissionLevel != 0 && newShare.permissionLevel != 1) {
|
||||
first.addtoList(newShare);
|
||||
}
|
||||
}
|
||||
|
||||
return first;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import com.amazonaws.services.lambda.AWSLambdaClientBuilder;
|
||||
import com.amazonaws.services.lambda.model.InvokeRequest;
|
||||
import com.amazonaws.services.lambda.model.InvokeResult;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.security.AccessControlException;
|
||||
import java.sql.Connection;
|
||||
@ -56,12 +57,7 @@ public class ListSharer implements CallHandler {
|
||||
if (invokeResult.getStatusCode() != 200) {
|
||||
throw new InputMismatchException("Could not find specified user to share with");
|
||||
}
|
||||
String shareWithSub = new String(invokeResult.getPayload().array()).replace("\"", "");
|
||||
// checkAccess.setString(2, shareWithSub);
|
||||
// checkAccessRS = checkAccess.executeQuery();
|
||||
// if (checkAccessRS.next()) {
|
||||
// throw new InputMismatchException("The specified user already has access");
|
||||
// }
|
||||
String shareWithSub = new Gson().fromJson(new String(invokeResult.getPayload().array()), User.class).cognitoID;
|
||||
|
||||
PreparedStatement uiPositionCheck = connection.prepareStatement(UI_POSITION_CHECK);
|
||||
uiPositionCheck.setString(1, shareWithSub);
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.Mockito.*;
|
||||
|
||||
import java.security.AccessControlException;
|
||||
import java.sql.SQLException;
|
||||
@ -9,15 +11,15 @@ public class TestListSharer {
|
||||
|
||||
@Test
|
||||
public void testListSharerWOAccess() {
|
||||
testListEntryAdderCore(false, false);
|
||||
testListEntryAdderCoreMock(false, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListSharerError() {
|
||||
testListEntryAdderCore(true, true);
|
||||
testListEntryAdderCoreMock(true, true);
|
||||
}
|
||||
|
||||
public void testListEntryAdderCore(boolean shouldThrow, boolean hasAccess) {
|
||||
public void testListEntryAdderCoreMock(boolean shouldThrow, boolean hasAccess) {
|
||||
StatementInjector injector;
|
||||
try {
|
||||
injector = new StatementInjector(null, null, shouldThrow);
|
||||
@ -26,7 +28,7 @@ public class TestListSharer {
|
||||
assert false; //Error in test infrastructure
|
||||
return;
|
||||
}
|
||||
ListSharer listSharer = new ListSharer(injector, "cognitoID");
|
||||
ListSharer listSharer = Mockito.spy(new ListSharer(injector, "cognitoID"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||
body.put("listID", 49);
|
||||
|
||||
34
Lambdas/Lists/Picture/src/Picture.java
Normal file
34
Lambdas/Lists/Picture/src/Picture.java
Normal file
@ -0,0 +1,34 @@
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class Picture {
|
||||
String base64EncodedImage;
|
||||
|
||||
public Picture(ResultSet rs) {
|
||||
try {
|
||||
this.base64EncodedImage = rs.getString("base64image");
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
this.base64EncodedImage = null;
|
||||
}
|
||||
}
|
||||
|
||||
public Picture(String base64EncodedImage) {
|
||||
this.base64EncodedImage = base64EncodedImage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Picture{" +
|
||||
"base64EncodedImage='" + base64EncodedImage + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public String getBase64EncodedImage() {
|
||||
return base64EncodedImage;
|
||||
}
|
||||
|
||||
public void setBase64EncodedImage(String base64EncodedImage) {
|
||||
this.base64EncodedImage = base64EncodedImage;
|
||||
}
|
||||
}
|
||||
12
Lambdas/Lists/Picture/src/PictureGET.java
Normal file
12
Lambdas/Lists/Picture/src/PictureGET.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 PictureGET implements RequestHandler<Map<String,Object>, Object> {
|
||||
|
||||
public Object handleRequest(Map<String, Object> inputMap, Context unfilled) {
|
||||
return BasicHandler.handleRequest(inputMap, unfilled, PictureGetter.class);
|
||||
}
|
||||
|
||||
}
|
||||
38
Lambdas/Lists/Picture/src/PictureGetter.java
Normal file
38
Lambdas/Lists/Picture/src/PictureGetter.java
Normal file
@ -0,0 +1,38 @@
|
||||
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 PictureGetter implements CallHandler {
|
||||
private final Connection connection;
|
||||
private final String cognitoID;
|
||||
|
||||
private final String GET_ITEM = "SELECT * FROM Pictures WHERE cognitoID = ?;";
|
||||
|
||||
public PictureGetter(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 {
|
||||
PreparedStatement statement = connection.prepareStatement(GET_ITEM);
|
||||
if (!queryMap.containsKey("id")) {
|
||||
throw new IllegalArgumentException("Must have id set.");
|
||||
}
|
||||
if (queryMap.get("id").equals("profile")) {
|
||||
statement.setString(1, cognitoID);
|
||||
} else {
|
||||
statement.setString(1, queryMap.get("id"));
|
||||
}
|
||||
System.out.println(statement);
|
||||
ResultSet queryResults = statement.executeQuery();
|
||||
queryResults.first();
|
||||
System.out.println(queryResults);
|
||||
Picture retrievedPicture = new Picture(queryResults);
|
||||
// System.out.println(retrievedPicture);
|
||||
return retrievedPicture;
|
||||
}
|
||||
}
|
||||
@ -3,10 +3,9 @@ import com.amazonaws.services.lambda.runtime.RequestHandler;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ListShareDELETE implements RequestHandler<Map<String,Object>, Object> {
|
||||
public class PicturePUT implements RequestHandler<Map<String,Object>, Object> {
|
||||
|
||||
public Object handleRequest(Map<String, Object> inputMap, Context unfilled) {
|
||||
return BasicHandler.handleRequest(inputMap, unfilled, ListShareDeleter.class);
|
||||
return BasicHandler.handleRequest(inputMap, unfilled, PicturePutter.class);
|
||||
}
|
||||
|
||||
}
|
||||
31
Lambdas/Lists/Picture/src/PicturePutter.java
Normal file
31
Lambdas/Lists/Picture/src/PicturePutter.java
Normal file
@ -0,0 +1,31 @@
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PicturePutter implements CallHandler {
|
||||
|
||||
private Connection connection;
|
||||
private String cognitoID;
|
||||
|
||||
public PicturePutter(Connection connection, String cognitoID) {
|
||||
this.connection = connection;
|
||||
this.cognitoID = cognitoID;
|
||||
}
|
||||
|
||||
final private String STORE_PICTURE_SQL = "REPLACE INTO Pictures(cognitoID, base64image) VALUES(?, ?);";
|
||||
|
||||
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryString, String cognitoID) throws SQLException {
|
||||
PreparedStatement storePicture = connection.prepareStatement(STORE_PICTURE_SQL);
|
||||
if(!bodyMap.containsKey("base64EncodedImage")) {
|
||||
throw new IllegalArgumentException("Base64EncodedImage not found");
|
||||
}
|
||||
storePicture.setString(1, cognitoID);
|
||||
storePicture.setString(2, bodyMap.get("base64EncodedImage").toString());
|
||||
System.out.println(storePicture);
|
||||
storePicture.executeUpdate();
|
||||
connection.commit();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
43
Lambdas/Lists/Picture/test/TestPictureGetter.java
Normal file
43
Lambdas/Lists/Picture/test/TestPictureGetter.java
Normal file
@ -0,0 +1,43 @@
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TestPictureGetter {
|
||||
|
||||
@Test
|
||||
public void testPictureGetterValid() {
|
||||
testPictureGetter(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPictureGetterError() {
|
||||
testPictureGetter(true);
|
||||
}
|
||||
|
||||
public void testPictureGetter(boolean shouldThrow) {
|
||||
StatementInjector injector;
|
||||
try {
|
||||
injector = new StatementInjector(null, null, shouldThrow);
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
assert false; //Error in test infrastructure
|
||||
return;
|
||||
}
|
||||
PictureGetter pictureGetter = Mockito.spy(new PictureGetter(injector, "cognitoID"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||
body.put("id", 1);
|
||||
body.put("profile", 1);
|
||||
|
||||
try {
|
||||
Object rawIDReturn = pictureGetter.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||
assert (rawIDReturn != null);
|
||||
} catch (SQLException throwables) {
|
||||
assert shouldThrow;
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
40
Lambdas/Lists/Picture/test/TestPicturePutter.java
Normal file
40
Lambdas/Lists/Picture/test/TestPicturePutter.java
Normal file
@ -0,0 +1,40 @@
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TestPicturePutter {
|
||||
|
||||
@Test
|
||||
public void testPicturePutterValid() {
|
||||
testPicturePutter(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPicturePutterError() {
|
||||
testPicturePutter(true);
|
||||
}
|
||||
|
||||
public void testPicturePutter(boolean shouldThrow) {
|
||||
StatementInjector injector;
|
||||
try {
|
||||
injector = new StatementInjector(null, null, shouldThrow);
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
assert false; //Error in test infrastructure
|
||||
return;
|
||||
}
|
||||
PicturePutter picturePutter = Mockito.spy(new PicturePutter(injector, "cognitoID"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||
try {
|
||||
Object rawIDReturn = picturePutter.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||
assert (rawIDReturn == null);
|
||||
} catch (SQLException throwables) {
|
||||
assert shouldThrow;
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class TestSearchHistoryGetter {
|
||||
|
||||
@Test
|
||||
public void testSearchHistoryValid() {
|
||||
testSearchHistoryGetterMock(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchHistoryError() {
|
||||
testSearchHistoryGetterMock(true);
|
||||
}
|
||||
|
||||
public void testSearchHistoryGetterMock(boolean shouldThrow) {
|
||||
StatementInjector injector;
|
||||
try {
|
||||
injector = new StatementInjector(null, null, shouldThrow);
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
assert false; //Error in test infrastructure
|
||||
return;
|
||||
}
|
||||
SearchHistoryGetter searchHistoryGetter = Mockito.spy(new SearchHistoryGetter(injector, "cognitoID"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||
|
||||
try {
|
||||
Object rawIDReturn = searchHistoryGetter.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||
assert (rawIDReturn != null);
|
||||
} catch (SQLException throwables) {
|
||||
assert shouldThrow;
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TestSearchHistoryUpdater {
|
||||
|
||||
@Test
|
||||
public void testSearchHistoryUpdaterValid() {
|
||||
testSearchHistoryUpdater(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchHistoryUpdaterError() {
|
||||
testSearchHistoryUpdater(true);
|
||||
}
|
||||
|
||||
public void testSearchHistoryUpdater(boolean shouldThrow) {
|
||||
StatementInjector injector;
|
||||
try {
|
||||
injector = new StatementInjector(null, null, shouldThrow);
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
assert false; //Error in test infrastructure
|
||||
return;
|
||||
}
|
||||
SearchHistoryUpdater testSearchHistoryUpdater = Mockito.spy(new SearchHistoryUpdater(injector, "cognitoID"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||
|
||||
try {
|
||||
Object rawIDReturn = testSearchHistoryUpdater.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||
assert (rawIDReturn == null);
|
||||
} catch (SQLException throwables) {
|
||||
assert shouldThrow;
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Lambdas/Lists/User/src/User.java
Normal file
26
Lambdas/Lists/User/src/User.java
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
public class User {
|
||||
String cognitoID;
|
||||
String email;
|
||||
|
||||
public User(String cognitoID, String email) {
|
||||
this.cognitoID = cognitoID;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getCognitoID() {
|
||||
return cognitoID;
|
||||
}
|
||||
|
||||
public void setCognitoID(String cognitoID) {
|
||||
this.cognitoID = cognitoID;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
}
|
||||
@ -28,21 +28,23 @@ public class UserGetter implements CallHandler {
|
||||
System.out.println(userPoolId);
|
||||
ListUsersRequest checkRequest = new ListUsersRequest().withUserPoolId(userPoolId);
|
||||
Object emailObject = bodyMap.get("emailToCheck");
|
||||
if (queryMap.get("id").contains("@")) {
|
||||
emailObject = queryMap.get("id");
|
||||
}
|
||||
String attributeToGet = "sub";
|
||||
if (emailObject != null) {
|
||||
checkRequest.setFilter("email=\"" + emailObject.toString() +"\"");
|
||||
} else {
|
||||
try {
|
||||
String id = queryMap.get("id");
|
||||
attributeToGet = "email";
|
||||
checkRequest.setFilter("sub=\"" + cognitoID + "\"");
|
||||
if ((id != null) && (!id.equals(""))) {
|
||||
attributeToGet = "email";
|
||||
checkRequest.setFilter("sub=\"" + cognitoID + "\"");
|
||||
} else {
|
||||
return cognitoID;
|
||||
checkRequest.setFilter("sub=\"" + id + "\"");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
return cognitoID;
|
||||
return new User(cognitoID, null);
|
||||
}
|
||||
}
|
||||
System.out.println(checkRequest);
|
||||
@ -52,9 +54,9 @@ public class UserGetter implements CallHandler {
|
||||
if (foundUsers.size() != 1) {
|
||||
System.out.println(foundUsers);
|
||||
if (foundUsers.size() == 0) {
|
||||
throw new InputMismatchException("Not user with given email");
|
||||
throw new InputMismatchException("No user with given attribute when searching for (" + attributeToGet + ")");
|
||||
}
|
||||
throw new InputMismatchException("Found more than one user with supposedly unique email");
|
||||
throw new InputMismatchException("Found more than one user with supposedly unique attribute (" + attributeToGet + ")");
|
||||
}
|
||||
UserType foundUser = foundUsers.get(0);
|
||||
System.out.println(foundUser.getAttributes());
|
||||
@ -66,6 +68,11 @@ public class UserGetter implements CallHandler {
|
||||
}
|
||||
System.out.println(attribute.getName() + ": " + attribute.getValue());
|
||||
}
|
||||
return attributeToReturn;
|
||||
if (attributeToGet.equals("email")) {
|
||||
return new User(cognitoID, attributeToReturn);
|
||||
} else if (attributeToGet.equals("sub")) {
|
||||
return new User(attributeToReturn, emailObject.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,6 +110,11 @@
|
||||
<version>4.13</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>3.2.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<maven.compiler.source>1.11</maven.compiler.source>
|
||||
|
||||
@ -8,6 +8,8 @@
|
||||
<option name="testRunner" value="PLATFORM" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleHome" value="/usr/local/Cellar/gradle/6.6.1/libexec" />
|
||||
<option name="gradleJvm" value="1.8" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
@ -53,4 +53,6 @@ dependencies {
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.8.1'
|
||||
implementation 'com.crystal:crystalrangeseekbar:1.1.3'
|
||||
implementation 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.1'
|
||||
implementation "androidx.cardview:cardview:1.0.0"
|
||||
|
||||
}
|
||||
@ -3,6 +3,10 @@
|
||||
package="com.example.listify">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
|
||||
<application
|
||||
android:name=".Listify"
|
||||
@ -13,6 +17,18 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:usesCleartextTraffic="true">
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="com.example.listify.provider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths">
|
||||
</meta-data>
|
||||
</provider>
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
@ -40,6 +56,15 @@
|
||||
<activity android:name="com.example.listify.ui.LoginPage" />
|
||||
<activity android:name="com.example.listify.ui.ForgotPasswordPage" />
|
||||
<activity android:name="com.example.listify.ListPage" />
|
||||
<activity android:name="com.example.listify.ListSharees" />
|
||||
<activity android:name="com.example.listify.ConfirmShareView">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.CONFIRM_SHARE" />
|
||||
|
||||
<!-- <category android:name="android.intent.category.DEFAULT" />-->
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@ -9,6 +9,7 @@ import com.amplifyframework.auth.result.AuthResetPasswordResult;
|
||||
import com.amplifyframework.auth.result.AuthSignInResult;
|
||||
import com.amplifyframework.auth.result.AuthSignUpResult;
|
||||
import com.amplifyframework.core.Amplify;
|
||||
import com.example.listify.data.ListShare;
|
||||
import com.example.listify.data.User;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
@ -60,7 +61,21 @@ public class AuthManager {
|
||||
return authSession.getUserPoolTokens().getValue().getIdToken();
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
public String getEmail(Requestor requestor) {
|
||||
if (email == null) {
|
||||
try {
|
||||
requestor.putObject(new ListShare(285, "nmerz@icloud.com", 210, -1, null));
|
||||
} catch (JSONException jsonException) {
|
||||
jsonException.printStackTrace();
|
||||
}
|
||||
SynchronousReceiver<User> userSynchronousReceiver = new SynchronousReceiver<>();
|
||||
requestor.getObject("", User.class, userSynchronousReceiver);
|
||||
try {
|
||||
email = userSynchronousReceiver.await().getEmail();
|
||||
} catch (Exception e) {
|
||||
return email;
|
||||
}
|
||||
}
|
||||
return email;
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,114 @@
|
||||
package com.example.listify;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import com.example.listify.data.ListShare;
|
||||
import com.example.listify.data.Picture;
|
||||
import com.example.listify.data.User;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Properties;
|
||||
|
||||
import static com.example.listify.MainActivity.am;
|
||||
|
||||
public class ConfirmShareView extends AppCompatActivity {
|
||||
@Override
|
||||
public void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.share_confirmation);
|
||||
System.out.println("Got to confirm view");
|
||||
TextView shareeEmailView = findViewById(R.id.shareeEmailView);
|
||||
final String shareeEmail = (String) getIntent().getSerializableExtra("shareeEmail");
|
||||
final Integer listID = (Integer) getIntent().getSerializableExtra("listID");
|
||||
|
||||
shareeEmailView.setText(shareeEmail);
|
||||
Properties configs = new Properties();
|
||||
try {
|
||||
configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
||||
} catch (IOException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
SynchronousReceiver<Picture> profilePictureReceiver = new SynchronousReceiver<>();
|
||||
SynchronousReceiver<User> userReceiver = new SynchronousReceiver<>();
|
||||
ImageView profilePictureView = findViewById(R.id.otherProfilePicture);
|
||||
try {
|
||||
requestor.getObject(shareeEmail, User.class, userReceiver);
|
||||
String shareeID = userReceiver.await().getCognitoID();
|
||||
requestor.getObject(shareeID, Picture.class, profilePictureReceiver);
|
||||
profilePictureView.setImageURI(Uri.fromFile(saveImage(profilePictureReceiver.await().getBase64EncodedImage(), "shareeProfilePicture")));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Button confirmShare = (Button) findViewById(R.id.confirmShare);
|
||||
Button cancelShare = (Button) findViewById(R.id.cancelShare);
|
||||
|
||||
confirmShare.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
ListShare listShare = new ListShare(listID, shareeEmail, "Read, Write, Delete, Share", null);
|
||||
try {
|
||||
requestor.putObject(listShare);
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Intent data = new Intent();
|
||||
data.putExtra("listID", listID);
|
||||
data.putExtra("shareeEmail", shareeEmail);
|
||||
setResult(RESULT_OK,data);
|
||||
finish();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cancelShare.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//TODO: return to prior view
|
||||
setResult(RESULT_CANCELED,null);
|
||||
finish(); }
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//From: https://stackoverflow.com/questions/30005815/convert-encoded-base64-image-to-file-object-in-android
|
||||
public File saveImage(final String imageData, String prefix) throws IOException {
|
||||
final byte[] imgBytesData = android.util.Base64.decode(imageData,
|
||||
android.util.Base64.DEFAULT);
|
||||
|
||||
final File file = File.createTempFile(prefix, null, this.getCacheDir());
|
||||
final FileOutputStream fileOutputStream;
|
||||
try {
|
||||
fileOutputStream = new FileOutputStream(file);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
final BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(
|
||||
fileOutputStream);
|
||||
try {
|
||||
bufferedOutputStream.write(imgBytesData);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} finally {
|
||||
try {
|
||||
bufferedOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
}
|
||||
@ -1,54 +1,37 @@
|
||||
package com.example.listify;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
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 android.widget.*;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
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 ListSharees extends AppCompatActivity implements Requestor.Receiver {
|
||||
ShareeSwipeableAdapter myAdapter;
|
||||
ListView listView;
|
||||
MyAdapter myAdapter;
|
||||
Requestor requestor;
|
||||
ProgressBar loadingListItems;
|
||||
|
||||
Button shareList;
|
||||
Button removeSharee;
|
||||
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
ArrayList<ListShare> lShareeEntries = new ArrayList<>();
|
||||
ArrayList<String> lShareeEmails = new ArrayList<>();
|
||||
|
||||
private final int CONFIRM_REQUEST_CODE = 1;
|
||||
|
||||
// TODO: Display a message if their list is empty
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -65,8 +48,39 @@ public class ListSharees extends AppCompatActivity implements Requestor.Receiver
|
||||
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);
|
||||
listView = findViewById(R.id.listOfSharees);
|
||||
myAdapter = new MyAdapter(this, lShareeEmails);
|
||||
listView.setAdapter(myAdapter);
|
||||
|
||||
shareList = (Button) findViewById(R.id.buttonShare);
|
||||
shareList.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
EditText sharedEmailText = (EditText) findViewById(R.id.editTextShareeEmail);
|
||||
String sharedEmail = sharedEmailText.getText().toString();
|
||||
Intent confirmIntent = new Intent(ListSharees.this, ConfirmShareView.class);
|
||||
confirmIntent.putExtra("listID", listID);
|
||||
confirmIntent.putExtra("shareeEmail", sharedEmail);
|
||||
startActivityForResult(confirmIntent, CONFIRM_REQUEST_CODE);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == CONFIRM_REQUEST_CODE) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
Integer listID = data.getIntExtra("listID", -1);
|
||||
String shareeEmail = data.getStringExtra("shareeEmail");
|
||||
ListShare listShare = new ListShare(listID, shareeEmail, "Read, Write, Delete, Share", null);
|
||||
lShareeEntries.add(listShare);
|
||||
lShareeEmails.add(shareeEmail);
|
||||
myAdapter.notifyDataSetChanged();
|
||||
|
||||
} else { //resultCode == RESULT_CANCELED
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -74,29 +88,69 @@ public class ListSharees extends AppCompatActivity implements Requestor.Receiver
|
||||
ListShare sharee = (ListShare) delivered;
|
||||
|
||||
if(sharee != null) {
|
||||
SynchronousReceiver<ListShare> listShareReceiver = new SynchronousReceiver<>();
|
||||
requestor.getObject(Integer.toString(sharee.getListID()), ListShare.class, listShareReceiver, listShareReceiver);
|
||||
lShareeEntries.add(sharee);
|
||||
lShareeEmails.add(sharee.getShareWithEmail());
|
||||
|
||||
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);
|
||||
if(sharee.getEntries() != null) {
|
||||
for(ListShare ls : sharee.getEntries()) {
|
||||
lShareeEntries.add(ls);
|
||||
lShareeEmails.add(ls.getShareWithEmail());
|
||||
}
|
||||
|
||||
myAdapter = new ShareeSwipeableAdapter(this, resultList);
|
||||
}
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class MyAdapter extends ArrayAdapter<String> {
|
||||
Context context;
|
||||
ArrayList<String> lShareeEmails;
|
||||
|
||||
MyAdapter (Context c, ArrayList<String> shareeEmails) {
|
||||
super(c, R.layout.shopping_list_sharee_entry, R.id.textView14, shareeEmails);
|
||||
context = c;
|
||||
lShareeEmails = shareeEmails;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@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.shopping_list_sharee_entry, parent,false);
|
||||
|
||||
TextView shareeEmail = listproduct.findViewById(R.id.textView14);
|
||||
if(!lShareeEmails.isEmpty()) {
|
||||
shareeEmail.setText(lShareeEmails.get(position));
|
||||
}
|
||||
|
||||
removeSharee = (Button) listproduct.findViewById(R.id.button4);
|
||||
removeSharee.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
lShareeEntries.get(position).setPermissionLevel(0);
|
||||
ListShare toRemove = lShareeEntries.remove(position);
|
||||
lShareeEmails.remove(position);
|
||||
requestor.putObject(toRemove);
|
||||
myAdapter.notifyDataSetChanged();
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(shareeEmail.getText().toString().equals(am.getEmail(requestor))) {
|
||||
shareeEmail.setVisibility(View.GONE);
|
||||
removeSharee.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
return listproduct;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,15 +1,31 @@
|
||||
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;
|
||||
import android.os.Handler;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Base64;
|
||||
import android.util.Base64OutputStream;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
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;
|
||||
import androidx.navigation.Navigation;
|
||||
@ -17,16 +33,16 @@ 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.data.Picture;
|
||||
import com.example.listify.ui.LoginPage;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
import static com.example.listify.SplashActivity.showSplash;
|
||||
@ -35,6 +51,9 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
private AppBarConfiguration mAppBarConfiguration;
|
||||
public static AuthManager am = new AuthManager();
|
||||
public static ArrayList<String> searchHistory;
|
||||
private File newImageFileLocation = null;
|
||||
private final int CAMERA_CAPTURE = 1;
|
||||
private final int IMAGE_SELECT = 2;
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
@ -49,7 +68,7 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if(showSplash) {
|
||||
if (showSplash) {
|
||||
showSplash = false;
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@ -61,12 +80,29 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
}, 1);
|
||||
}
|
||||
|
||||
if(am.getUserToken().equals("")) {
|
||||
if (am.getUserToken().equals("")) {
|
||||
am.nullify();
|
||||
Intent intent = new Intent(MainActivity.this, LoginPage.class);
|
||||
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 = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
||||
if(location != null) {
|
||||
double longitude = location.getLongitude();
|
||||
double latitude = location.getLatitude();
|
||||
}
|
||||
|
||||
|
||||
//------------------------------Auth Testing---------------------------------------------//
|
||||
|
||||
boolean testAuth = false;
|
||||
@ -153,12 +189,62 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------//
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
NavigationView navigationView = findViewById(R.id.nav_view);
|
||||
|
||||
Properties configs = new Properties();
|
||||
try {
|
||||
configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
||||
} catch (IOException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
TextView emailView = navigationView.getHeaderView(0).findViewById(R.id.textViewEmailSidebar);
|
||||
emailView.setText(am.getEmail(requestor));
|
||||
SynchronousReceiver<Picture> profilePictureReceiver = new SynchronousReceiver<>();
|
||||
ImageView profilePictureView = navigationView.getHeaderView(0).findViewById(R.id.imageViewProfilePicture);
|
||||
try {
|
||||
requestor.getObject("profile", Picture.class, profilePictureReceiver);
|
||||
profilePictureView.setImageURI(Uri.fromFile(saveImage(profilePictureReceiver.await().getBase64EncodedImage(), "profilePicture")));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
profilePictureView.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
||||
// builder.setView(navigationView.getHeaderView(0));
|
||||
builder.setTitle("Change picture");
|
||||
builder.setMessage("Please select a method to add a new profile picture.");
|
||||
builder.setCancelable(true);
|
||||
builder.setPositiveButton("Take picture", (dialog, which) -> {
|
||||
Intent takePicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
File imageFileLocation = getOutputImageFile();
|
||||
Log.i("Profile Picture", "New image file at " + imageFileLocation.getAbsolutePath());
|
||||
newImageFileLocation = imageFileLocation;
|
||||
Uri imageUri = FileProvider.getUriForFile(
|
||||
MainActivity.this,
|
||||
BuildConfig.APPLICATION_ID + ".provider",
|
||||
imageFileLocation);
|
||||
takePicture.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
|
||||
startActivityForResult(takePicture, CAMERA_CAPTURE);
|
||||
});
|
||||
builder.setNegativeButton("Select picture", (dialog, which) -> {
|
||||
Intent pickPhoto = new Intent(Intent.ACTION_PICK,
|
||||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
startActivityForResult(pickPhoto, IMAGE_SELECT);
|
||||
});
|
||||
builder.setNeutralButton("Cancel", (dialog, which) -> {
|
||||
});
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
|
||||
mAppBarConfiguration = new AppBarConfiguration.Builder(
|
||||
R.id.nav_home, R.id.nav_profile, R.id.nav_logout)
|
||||
.setDrawerLayout(drawer)
|
||||
@ -178,6 +264,144 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
});
|
||||
}
|
||||
|
||||
//From: https://stackoverflow.com/questions/30005815/convert-encoded-base64-image-to-file-object-in-android
|
||||
public File saveImage(final String imageData, String prefix) throws IOException {
|
||||
final byte[] imgBytesData = android.util.Base64.decode(imageData,
|
||||
android.util.Base64.DEFAULT);
|
||||
|
||||
final File file = File.createTempFile(prefix, null, this.getCacheDir());
|
||||
final FileOutputStream fileOutputStream;
|
||||
try {
|
||||
fileOutputStream = new FileOutputStream(file);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
final BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(
|
||||
fileOutputStream);
|
||||
try {
|
||||
bufferedOutputStream.write(imgBytesData);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} finally {
|
||||
try {
|
||||
bufferedOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
protected void onActivityResult (int requestCode,
|
||||
int resultCode,
|
||||
Intent data) {
|
||||
Uri selectedImage = null;
|
||||
Properties configs = new Properties();
|
||||
try {
|
||||
configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
||||
} catch (IOException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
switch (requestCode){
|
||||
case CAMERA_CAPTURE:
|
||||
Log.i("Profile Picture", "Pulling image file at " + this.newImageFileLocation.getAbsolutePath());
|
||||
selectedImage = Uri.fromFile(this.newImageFileLocation);
|
||||
try {
|
||||
requestor.putObject(new Picture(fileToString(this.newImageFileLocation)));
|
||||
} catch (JSONException | IOException jsonException) {
|
||||
jsonException.printStackTrace();
|
||||
}
|
||||
|
||||
break;
|
||||
case IMAGE_SELECT:
|
||||
if ((data == null) || (data.getData() == null)) {
|
||||
return;
|
||||
}
|
||||
selectedImage = data.getData();
|
||||
try {
|
||||
requestor.putObject(new Picture(fileToString(new File(getRealPathFromUri(this, selectedImage)))));
|
||||
} catch (JSONException | IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
MainActivity.super.onActivityResult(requestCode, resultCode, data);
|
||||
if (selectedImage == null) {
|
||||
return;
|
||||
}
|
||||
NavigationView navigationView = findViewById(R.id.nav_view);
|
||||
|
||||
ImageView profilePicture = navigationView.getHeaderView(0).findViewById(R.id.imageViewProfilePicture);
|
||||
profilePicture.setImageURI(selectedImage);
|
||||
|
||||
}
|
||||
|
||||
//From: https://stackoverflow.com/questions/20028319/how-to-convert-content-media-external-images-media-y-to-file-storage-sdc
|
||||
private static String getRealPathFromUri(Context context, Uri contentUri) {
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
String[] proj = { MediaStore.Images.Media.DATA };
|
||||
cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
|
||||
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||
cursor.moveToFirst();
|
||||
return cursor.getString(column_index);
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//From: https://stackoverflow.com/questions/27784230/convert-a-file-100mo-in-base64-on-android
|
||||
private String fileToString(File toStringify) throws IOException {
|
||||
InputStream inputStream = new FileInputStream(toStringify.getAbsolutePath());
|
||||
byte[] buffer = new byte[8192];
|
||||
int bytesRead;
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
Base64OutputStream output64 = new Base64OutputStream(output, Base64.DEFAULT);
|
||||
try {
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
output64.write(buffer, 0, bytesRead);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
output64.close();
|
||||
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
//getOutputImageFile from https://developer.android.com/guide/topics/media/camera
|
||||
private static File getOutputImageFile(){
|
||||
// To be safe, you should check that the SDCard is mounted
|
||||
// using Environment.getExternalStorageState() before doing this.
|
||||
|
||||
File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
|
||||
Environment.DIRECTORY_PICTURES), "MyCameraApp");
|
||||
// This location works best if you want the created images to be shared
|
||||
// between applications and persist after your app has been uninstalled.
|
||||
|
||||
// Create the storage directory if it does not exist
|
||||
if (! mediaStorageDir.exists()){
|
||||
if (! mediaStorageDir.mkdirs()){
|
||||
Log.d("File creation", "failed to create directory");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a media file name
|
||||
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
|
||||
File mediaFile = new File(mediaStorageDir.getPath() + File.separator +
|
||||
"IMG_"+ timeStamp + ".jpg");
|
||||
Log.i("File creation", mediaFile.toString());
|
||||
return mediaFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSupportNavigateUp() {
|
||||
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
|
||||
@ -216,5 +440,8 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
Toast.makeText(this, "An error occurred", Toast.LENGTH_LONG).show();
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,128 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -7,14 +7,28 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
import com.example.listify.R;
|
||||
import com.example.listify.data.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ShoppingListsAdapter extends BaseAdapter {
|
||||
import com.example.listify.AuthManager;
|
||||
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 ShoppingListsAdapter extends BaseAdapter implements Requestor.Receiver {
|
||||
private Activity activity;
|
||||
private ArrayList<List> lists;
|
||||
private LayoutInflater inflater;
|
||||
private TextView tvListName;
|
||||
private List curList;
|
||||
private Requestor requestor;
|
||||
|
||||
public ShoppingListsAdapter(Activity activity, ArrayList<List> lists){
|
||||
this.activity = activity;
|
||||
@ -45,11 +59,19 @@ public class ShoppingListsAdapter extends BaseAdapter {
|
||||
convertView = inflater.inflate(R.layout.shopping_lists_name_item, null);
|
||||
}
|
||||
|
||||
List curList = lists.get(position);
|
||||
curList = lists.get(position);
|
||||
|
||||
tvListName = (TextView) convertView.findViewById(R.id.shopping_list_name);
|
||||
|
||||
TextView tvListName = (TextView) convertView.findViewById(R.id.shopping_list_name);
|
||||
if(curList.isShared()) {
|
||||
tvListName.setText(curList.getName() + " (shared)");
|
||||
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"));
|
||||
requestor.getObject(Integer.toString(curList.getListID()), ListShare.class, this);
|
||||
}
|
||||
else {
|
||||
tvListName.setText(curList.getName());
|
||||
@ -57,4 +79,23 @@ public class ShoppingListsAdapter extends BaseAdapter {
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptDelivery(Object delivered) {
|
||||
ListShare sharee = (ListShare) delivered;
|
||||
|
||||
if(sharee != null) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(sharee.getShareWithEmail().equals(am.getEmail(requestor))) {
|
||||
tvListName.setText(curList.getName() + " (shared by me)");
|
||||
}
|
||||
else {
|
||||
tvListName.setText(curList.getName() + " (shared by " + sharee.getShareWithEmail() + ")");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,27 +1,19 @@
|
||||
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.*;
|
||||
import com.example.listify.data.List;
|
||||
import com.example.listify.data.ListShare;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -30,10 +22,13 @@ import java.util.Properties;
|
||||
|
||||
import static com.example.listify.MainActivity.am;
|
||||
|
||||
public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
||||
public class ShoppingListsSwipeableAdapter extends BaseAdapter implements Requestor.Receiver {
|
||||
private Activity activity;
|
||||
private ArrayList<List> lists;
|
||||
private LayoutInflater inflater;
|
||||
private List curList;
|
||||
private ViewHolder holder;
|
||||
private Requestor requestor;
|
||||
private final ViewBinderHelper binderHelper;
|
||||
|
||||
public ShoppingListsSwipeableAdapter(Activity activity, ArrayList<List> lists){
|
||||
@ -58,16 +53,33 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
ViewHolder holder;
|
||||
public void acceptDelivery(Object delivered) {
|
||||
ListShare sharee = (ListShare) delivered;
|
||||
|
||||
if(sharee != null) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(sharee.getShareWithEmail().equals(am.getEmail(requestor))) {
|
||||
holder.listName.setText(curList.getName() + " (shared by me)");
|
||||
}
|
||||
else {
|
||||
holder.listName.setText(curList.getName() + " (shared by " + sharee.getShareWithEmail() + ")");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@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 requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
|
||||
if (inflater == null) {
|
||||
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
@ -79,7 +91,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);
|
||||
|
||||
@ -88,13 +100,13 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
final List curList = lists.get(position);
|
||||
curList = lists.get(position);
|
||||
|
||||
// Bind the view to the unique list ID
|
||||
binderHelper.bind(holder.swipeLayout, Integer.toString(curList.getListID()));
|
||||
|
||||
if(curList.isShared()) {
|
||||
holder.listName.setText(curList.getName() + " (shared)");
|
||||
requestor.getObject(Integer.toString(curList.getListID()), ListShare.class, this);
|
||||
}
|
||||
else {
|
||||
holder.listName.setText(curList.getName());
|
||||
@ -124,50 +136,20 @@ 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", 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.shareList.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent listSharees = new Intent(activity, ListSharees.class);
|
||||
listSharees.putExtra("listID", curList.getListID());
|
||||
activity.startActivity(listSharees);
|
||||
}
|
||||
});
|
||||
|
||||
holder.frontView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent listPage = new Intent(activity, ListPage.class);
|
||||
|
||||
// Send the selected list
|
||||
listPage.putExtra("selectedList", curList);
|
||||
|
||||
activity.startActivity(listPage);
|
||||
}
|
||||
});
|
||||
@ -179,7 +161,7 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
||||
SwipeRevealLayout swipeLayout;
|
||||
View frontView;
|
||||
View deleteList;
|
||||
// View shareList;
|
||||
View shareList;
|
||||
TextView listName;
|
||||
TextView itemCount;
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ public class ListShare {
|
||||
String shareWithEmail;
|
||||
final ListShare[] other;
|
||||
Integer permissionLevel;
|
||||
Integer uiPosition;
|
||||
private static final Map<Integer, String> keysToPerms;
|
||||
|
||||
static {
|
||||
@ -24,11 +25,17 @@ public class ListShare {
|
||||
keysToPerms = Collections.unmodifiableMap(keysToPermsTemp);
|
||||
}
|
||||
|
||||
public ListShare(Integer listID, String shareWithEmail, Integer permissionLevel, ListShare[] other) {
|
||||
public ListShare(Integer listID, String shareWithEmail, Integer permissionLevel, Integer uiPosition, ListShare[] other) {
|
||||
this.listID = listID;
|
||||
this.shareWithEmail = shareWithEmail;
|
||||
this.permissionLevel = permissionLevel;
|
||||
this.other = other;
|
||||
this.uiPosition = uiPosition;
|
||||
}
|
||||
|
||||
public ListShare(Integer listID, String shareWithEmail, String permissionsRaw, Integer uiPosition, ListShare[] other) {
|
||||
this(listID, shareWithEmail, permissionsRaw, other);
|
||||
this.uiPosition = uiPosition;
|
||||
}
|
||||
|
||||
public ListShare(Integer listID, String shareWithEmail, String permissionsRaw, ListShare[] other) {
|
||||
@ -42,6 +49,7 @@ public class ListShare {
|
||||
permissionLevel *= keytoPermEntry.getKey();
|
||||
}
|
||||
}
|
||||
this.uiPosition = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -53,14 +61,16 @@ public class ListShare {
|
||||
" [Permissions: ");
|
||||
|
||||
int permissionLevelCopy = permissionLevel;
|
||||
for (Integer permissionObject : keysToPerms.keySet()) {
|
||||
Integer permissionInteger = permissionObject;
|
||||
if (permissionLevelCopy % permissionInteger == 0) {
|
||||
permissionLevelCopy /= permissionInteger;
|
||||
toReturn.append(keysToPerms.get(permissionInteger)).append(",");
|
||||
if (permissionLevel > 0) {
|
||||
for (Integer permissionObject : keysToPerms.keySet()) {
|
||||
Integer permissionInteger = permissionObject;
|
||||
if (permissionLevelCopy % permissionInteger == 0) {
|
||||
permissionLevelCopy /= permissionInteger;
|
||||
toReturn.append(keysToPerms.get(permissionInteger)).append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (BuildConfig.DEBUG && permissionLevelCopy != 1) {
|
||||
if (BuildConfig.DEBUG && (permissionLevelCopy != 1 && permissionLevelCopy != 0)) {
|
||||
throw new AssertionError("Assertion failed");
|
||||
}
|
||||
toReturn.append("]}");
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package com.example.listify.data;
|
||||
|
||||
public class Picture {
|
||||
String base64EncodedImage;
|
||||
|
||||
public Picture(String base64EncodedImage) {
|
||||
this.base64EncodedImage = base64EncodedImage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Picture{" +
|
||||
"base64EncodedImage='" + base64EncodedImage + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public String getBase64EncodedImage() {
|
||||
return base64EncodedImage;
|
||||
}
|
||||
|
||||
public void setBase64EncodedImage(String base64EncodedImage) {
|
||||
this.base64EncodedImage = base64EncodedImage;
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,27 @@
|
||||
package com.example.listify.data;
|
||||
|
||||
public class User {
|
||||
String cognitoID;
|
||||
String email;
|
||||
|
||||
public User(String cognitoID, String email) {
|
||||
this.cognitoID = cognitoID;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getCognitoID() {
|
||||
return cognitoID;
|
||||
}
|
||||
|
||||
public void setCognitoID(String cognitoID) {
|
||||
this.cognitoID = cognitoID;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,26 +6,17 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import com.example.listify.AuthManager;
|
||||
import com.example.listify.CreateListDialogFragment;
|
||||
import com.example.listify.LoadingCircleDialog;
|
||||
import com.example.listify.R;
|
||||
import com.example.listify.Requestor;
|
||||
import com.example.listify.SynchronousReceiver;
|
||||
import com.example.listify.*;
|
||||
import com.example.listify.adapter.ShoppingListsSwipeableAdapter;
|
||||
import com.example.listify.data.List;
|
||||
import com.example.listify.data.SearchHistory;
|
||||
import com.example.listify.model.Product;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -161,6 +152,9 @@ public class HomeFragment extends Fragment implements CreateListDialogFragment.O
|
||||
Integer[] listIds = (Integer[]) delivered;
|
||||
|
||||
// Create threads and add them to a list
|
||||
if (listIds == null) {
|
||||
return;
|
||||
}
|
||||
Thread[] threads = new Thread[listIds.length];
|
||||
List[] results = new List[listIds.length];
|
||||
for (int i = 0; i < listIds.length; i++) {
|
||||
|
||||
@ -33,7 +33,14 @@ public class ProfileFragment extends Fragment {
|
||||
View root = inflater.inflate(R.layout.fragment_profile, container, false);
|
||||
|
||||
TextView emailText = (TextView) root.findViewById(R.id.textViewEmail);
|
||||
emailText.setText(am.getEmail());
|
||||
Properties configs = new Properties();
|
||||
try {
|
||||
configs = AuthManager.loadProperties(getContext(), "android.resource://" + getActivity().getPackageName() + "/raw/auths.json");
|
||||
} catch (IOException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
emailText.setText(am.getEmail(requestor));
|
||||
|
||||
toDeleteAccountPage = (Button) root.findViewById(R.id.button);
|
||||
toDeleteAccountPage.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@ -3,20 +3,36 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress_loading_list_items"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
<TextView
|
||||
android:id="@+id/textView15"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone"/>
|
||||
android:text="Enter the email of the user you want to share the list with."
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginLeft="13dp"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextShareeEmail"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="17"
|
||||
android:inputType="textPersonName"
|
||||
android:hint="Share with"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginLeft="10dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonShare"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Share"
|
||||
android:layout_marginTop="100dp"
|
||||
android:layout_marginLeft="10dp"/>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/listOfSharees"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="0dp" />
|
||||
android:layout_marginTop="175dp"/>
|
||||
|
||||
</RelativeLayout>
|
||||
@ -1,8 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/Profile_Section"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp"
|
||||
android:layout_height="@dimen/nav_header_height"
|
||||
android:background="@drawable/side_nav_bar"
|
||||
android:gravity="bottom"
|
||||
android:orientation="vertical"
|
||||
@ -12,24 +13,29 @@
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark">
|
||||
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/imageView"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:contentDescription="@string/nav_header_desc"-->
|
||||
<!-- android:paddingTop="@dimen/nav_header_vertical_spacing"-->
|
||||
<!-- app:srcCompat="@mipmap/ic_launcher_round" />-->
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:paddingTop="@dimen/nav_header_vertical_spacing"-->
|
||||
<!-- android:text="@string/nav_header_title"-->
|
||||
<!-- android:textAppearance="@style/TextAppearance.AppCompat.Body1" />-->
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="96dp"
|
||||
android:layout_height="96dp"
|
||||
android:elevation="12dp"
|
||||
android:id="@+id/view2"
|
||||
app:cardCornerRadius="48dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:background="#80000000">
|
||||
<ImageView
|
||||
android:layout_height="96dp"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/imageViewProfilePicture"
|
||||
android:src="@raw/ic_launcher_round"
|
||||
android:scaleType="centerCrop"
|
||||
android:background="#80000000"/>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/textView"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:text="@string/nav_header_subtitle" />-->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewEmailSidebar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/nav_header_subtitle" />
|
||||
</LinearLayout>
|
||||
73
Listify/app/src/main/res/layout/share_confirmation.xml
Normal file
73
Listify/app/src/main/res/layout/share_confirmation.xml
Normal file
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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="700dp"
|
||||
android:gravity="bottom"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="40dp"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark">
|
||||
|
||||
<TextView android:layout_width="match_parent"
|
||||
android:layout_height="120dp"
|
||||
android:text="Please confirm sharing with the below user:"
|
||||
android:textSize="30dp"
|
||||
android:textColor="#FF000000"
|
||||
/>
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="96dp"
|
||||
android:layout_height="96dp"
|
||||
android:elevation="400dp"
|
||||
android:id="@+id/otherProfilePictureWrapper"
|
||||
app:cardCornerRadius="48dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:background="#80000000">
|
||||
<ImageView
|
||||
android:layout_height="96dp"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/otherProfilePicture"
|
||||
android:src="@raw/ic_launcher_round"
|
||||
android:scaleType="centerCrop"
|
||||
android:background="#80000000"/>
|
||||
</androidx.cardview.widget.CardView>
|
||||
<TextView android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:id="@+id/shareeEmailView"
|
||||
android:text="user@email.com"
|
||||
android:textSize="25dp"
|
||||
android:textColor="#FF000000"
|
||||
android:textAlignment="center"
|
||||
android:layout_gravity="center_horizontal"
|
||||
|
||||
/>
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_height="250dp"
|
||||
android:layout_width="match_parent" />
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_height="50dp"
|
||||
android:layout_width="match_parent" >
|
||||
<Button android:layout_width="150dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="left"
|
||||
android:text="Cancel"
|
||||
android:textSize="25dp"
|
||||
android:background="#FF800000"
|
||||
android:id="@+id/cancelShare"
|
||||
|
||||
/>
|
||||
<Button android:layout_width="150dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right"
|
||||
android:text="Confirm"
|
||||
android:textSize="25dp"
|
||||
android:background="#FF008000"
|
||||
android:id="@+id/confirmShare"
|
||||
/>
|
||||
</androidx.cardview.widget.CardView>
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_height="70dp"
|
||||
android:layout_width="match_parent" />
|
||||
</LinearLayout>
|
||||
@ -0,0 +1,29 @@
|
||||
<?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">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="Stop sharing"
|
||||
android:textSize="10dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView14"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:text="Sharee's email"
|
||||
android:textSize="15dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</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"
|
||||
@ -30,6 +30,7 @@
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:background="@android:color/holo_red_dark"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
BIN
Listify/app/src/main/res/raw/ic_launcher_round.png
Normal file
BIN
Listify/app/src/main/res/raw/ic_launcher_round.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
4
Listify/app/src/main/res/xml/file_paths.xml
Normal file
4
Listify/app/src/main/res/xml/file_paths.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<external-path name="external_files" path="." />
|
||||
</paths>
|
||||
Loading…
Reference in New Issue
Block a user