diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index b40952a..eeb5161 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -1,17 +1,17 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 112d5d7..853d7e3 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,43 +1,51 @@ - - - - - - - - - - + + + + + + + + + + \ No newline at end of file diff --git a/amplify/.config/project-config.json b/amplify/.config/project-config.json index 866fd39..900607a 100644 --- a/amplify/.config/project-config.json +++ b/amplify/.config/project-config.json @@ -2,7 +2,7 @@ "providers": [ "awscloudformation" ], - "projectName": "Thrifty", + "projectName": "thrifty2", "version": "3.1", "frontend": "android", "android": { diff --git a/amplify/backend/analytics/ThriftyOWUjV/parameters.json b/amplify/backend/analytics/ThriftyOWUjV/parameters.json deleted file mode 100755 index 6ee94f9..0000000 --- a/amplify/backend/analytics/ThriftyOWUjV/parameters.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "appName": "ThriftyOWUjV", - "roleName": "pinpointLambdaRolee733af87", - "cloudformationPolicyName": "cloudformationPolicye733af87", - "cloudWatchPolicyName": "cloudWatchPolicye733af87", - "pinpointPolicyName": "pinpointPolicye733af87", - "authPolicyName": "pinpoint_amplify_e733af87", - "unauthPolicyName": "pinpoint_amplify_e733af87", - "authRoleName": { - "Ref": "AuthRoleName" - }, - "unauthRoleName": { - "Ref": "UnauthRoleName" - }, - "authRoleArn": { - "Fn::GetAtt": [ - "AuthRole", - "Arn" - ] - }, - "appId": "f06bd624184f4c90bc7556672ddd9619" -} \ No newline at end of file diff --git a/amplify/backend/analytics/ThriftyOWUjV/pinpoint-cloudformation-template.json b/amplify/backend/analytics/ThriftyOWUjV/pinpoint-cloudformation-template.json deleted file mode 100755 index 27ff3d0..0000000 --- a/amplify/backend/analytics/ThriftyOWUjV/pinpoint-cloudformation-template.json +++ /dev/null @@ -1,590 +0,0 @@ -{ - "AWSTemplateFormatVersion": "2010-09-09", - "Description": "Pinpoint resource stack creation using Amplify CLI", - "Parameters": { - "appName": { - "Type": "String" - }, - "appId": { - "Type": "String", - "Default": "NONE" - }, - "roleName": { - "Type": "String" - }, - "cloudformationPolicyName": { - "Type": "String" - }, - "cloudWatchPolicyName": { - "Type": "String" - }, - "pinpointPolicyName": { - "Type": "String" - }, - "authPolicyName": { - "Type": "String" - }, - "unauthPolicyName": { - "Type": "String" - }, - "authRoleName": { - "Type": "String" - }, - "unauthRoleName": { - "Type": "String" - }, - "authRoleArn": { - "Type": "String" - }, - "env": { - "Type": "String" - } - }, - "Metadata": { - "AWS::CloudFormation::Interface": { - "ParameterGroups": [ - { - "Label": { - "default": "Creating pinpoint app" - }, - "Parameters": [ - "appName" - ] - } - ] - } - }, - "Conditions": { - "ShouldCreatePinpointApp": { - "Fn::Equals": [ - { - "Ref": "appId" - }, - "NONE" - ] - }, - "ShouldNotCreateEnvResources": { - "Fn::Equals": [ - { - "Ref": "env" - }, - "NONE" - ] - } - }, - "Resources": { - "LambdaExecutionRole": { - "Condition": "ShouldCreatePinpointApp", - "Type": "AWS::IAM::Role", - "Properties": { - "RoleName": { - "Fn::If": [ - "ShouldNotCreateEnvResources", - { - "Ref": "roleName" - }, - { - "Fn::Join": [ - "", - [ - { - "Ref": "roleName" - }, - "-", - { - "Ref": "env" - } - ] - ] - } - ] - }, - "AssumeRolePolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Principal": { - "Service": [ - "lambda.amazonaws.com" - ] - }, - "Action": [ - "sts:AssumeRole" - ] - } - ] - }, - "Policies": [ - { - "PolicyName": { - "Ref": "cloudWatchPolicyName" - }, - "PolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Action": [ - "logs:CreateLogGroup", - "logs:CreateLogStream", - "logs:PutLogEvents" - ], - "Resource": "arn:aws:logs:*:*:*" - } - ] - } - }, - { - "PolicyName": { - "Ref": "pinpointPolicyName" - }, - "PolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Action": [ - "mobileanalytics:*", - "mobiletargeting:*" - ], - "Resource": "*" - } - ] - } - }, - { - "PolicyName": { - "Ref": "cloudformationPolicyName" - }, - "PolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Action": [ - "cloudformation:*" - ], - "Resource": "*" - } - ] - } - } - ] - } - }, - "PinpointFunction": { - "Type": "AWS::Lambda::Function", - "Condition": "ShouldCreatePinpointApp", - "Properties": { - "Code": { - "ZipFile": { - "Fn::Join": [ - "\n", - [ - "const response = require('cfn-response');", - "const aws = require('aws-sdk');", - "exports.handler = function(event, context) {", - " if (event.RequestType == 'Delete') {", - " const stackID = event.StackId;", - " const cloudFormationClient = new aws.CloudFormation({ apiVersion: '2016-12-01', region: event.ResourceProperties.region });", - " cloudFormationClient.describeStacks({ StackName: stackID }).promise()", - " .then(describeStacksOutput => {", - " let appId;", - " if (describeStacksOutput.Stacks && describeStacksOutput.Stacks.length > 0) {", - " const { Outputs } = describeStacksOutput.Stacks[0];", - " const appIdOutput = Outputs.find((output)=>{ return output.OutputKey === 'Id'});", - " appId = appIdOutput ? appIdOutput.OutputValue : undefined; ", - " }", - " return appId;", - " })", - " .then(appId => {", - " if (appId) {", - " const pinpointClient = new aws.Pinpoint({ apiVersion: '2016-12-01', region: event.ResourceProperties.pingPointRegion });", - " const params = {", - " ApplicationId: appId,", - " };", - " pinpointClient.deleteApp(params).promise();", - " }", - " })", - " .then(()=>{", - " response.send(event, context, response.SUCCESS, {'message': `Successfully deleted pinpoint project`});", - " })", - " .catch(e=>{", - " response.send(event, context, response.FAILED, {'message': `Failed to deleted Pinpoint project`, 'exception': e});", - " }); ", - " }", - " if (event.RequestType == 'Update') {", - " response.send(event, context, response.SUCCESS);", - " return;", - " }", - " if (event.RequestType == 'Create') {", - " const appName = event.ResourceProperties.appName;", - " let responseData = {};", - " const params = {", - " CreateApplicationRequest: {", - " Name: appName", - " }", - " };", - " const pinpoint = new aws.Pinpoint({ apiVersion: '2016-12-01', region: event.ResourceProperties.pingPointRegion });", - " pinpoint.createApp(params).promise()", - " .then((res) => {", - " responseData = res.ApplicationResponse;", - " response.send(event, context, response.SUCCESS, responseData);", - " }).catch((err) => {", - " console.log(err.stack);", - " responseData = {Error: err};", - " response.send(event, context, response.FAILED, responseData);", - " throw err;", - " });", - " }", - "};" - ] - ] - } - }, - "Handler": "index.handler", - "Runtime": "nodejs12.x", - "Timeout": 300, - "Role": { - "Fn::GetAtt": [ - "LambdaExecutionRole", - "Arn" - ] - } - } - }, - "PinpointFunctionOutputs": { - "Type": "Custom::LambdaCallout", - "Condition": "ShouldCreatePinpointApp", - "Properties": { - "ServiceToken": { - "Fn::GetAtt": [ - "PinpointFunction", - "Arn" - ] - }, - "region": { - "Ref": "AWS::Region" - }, - "pingPointRegion": { - "Fn::FindInMap": [ - "RegionMapping", - { - "Ref": "AWS::Region" - }, - "pinpointRegion" - ] - }, - "appName": { - "Fn::If": [ - "ShouldNotCreateEnvResources", - { - "Ref": "appName" - }, - { - "Fn::Join": [ - "", - [ - { - "Ref": "appName" - }, - "-", - { - "Ref": "env" - } - ] - ] - } - ] - } - }, - "DependsOn": "PinpointFunction" - }, - "CognitoUnauthPolicy": { - "Type": "AWS::IAM::Policy", - "Condition": "ShouldCreatePinpointApp", - "Properties": { - "PolicyName": { - "Ref": "unauthPolicyName" - }, - "Roles": [ - { - "Ref": "unauthRoleName" - } - ], - "PolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Action": [ - "mobiletargeting:PutEvents", - "mobiletargeting:UpdateEndpoint" - ], - "Resource": [ - { - "Fn::If": [ - "ShouldCreatePinpointApp", - { - "Fn::Join": [ - "", - [ - "arn:aws:mobiletargeting:*:", - { - "Fn::Select": [ - "4", - { - "Fn::Split": [ - ":", - { - "Ref": "authRoleArn" - } - ] - } - ] - }, - ":apps/", - { - "Fn::GetAtt": [ - "PinpointFunctionOutputs", - "Id" - ] - }, - "*" - ] - ] - }, - { - "Fn::Join": [ - "", - [ - "arn:aws:mobiletargeting:*:", - { - "Fn::Select": [ - "4", - { - "Fn::Split": [ - ":", - { - "Ref": "authRoleArn" - } - ] - } - ] - }, - ":apps/", - { - "Ref": "appId" - }, - "*" - ] - ] - } - ] - } - ] - } - ] - } - } - }, - "CognitoAuthPolicy": { - "Type": "AWS::IAM::Policy", - "Condition": "ShouldCreatePinpointApp", - "Properties": { - "PolicyName": { - "Ref": "authPolicyName" - }, - "Roles": [ - { - "Ref": "authRoleName" - } - ], - "PolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Action": [ - "mobiletargeting:PutEvents", - "mobiletargeting:UpdateEndpoint" - ], - "Resource": [ - { - "Fn::If": [ - "ShouldCreatePinpointApp", - { - "Fn::Join": [ - "", - [ - "arn:aws:mobiletargeting:*:", - { - "Fn::Select": [ - "4", - { - "Fn::Split": [ - ":", - { - "Ref": "authRoleArn" - } - ] - } - ] - }, - ":apps/", - { - "Fn::GetAtt": [ - "PinpointFunctionOutputs", - "Id" - ] - }, - "*" - ] - ] - }, - { - "Fn::Join": [ - "", - [ - "arn:aws:mobiletargeting:*:", - { - "Fn::Select": [ - "4", - { - "Fn::Split": [ - ":", - { - "Ref": "authRoleArn" - } - ] - } - ] - }, - ":apps/", - { - "Ref": "appId" - }, - "*" - ] - ] - } - ] - } - ] - } - ] - } - } - } - }, - "Outputs": { - "Region": { - "Value": { - "Fn::FindInMap": [ - "RegionMapping", - { - "Ref": "AWS::Region" - }, - "pinpointRegion" - ] - } - }, - "Id": { - "Value": { - "Fn::If": [ - "ShouldCreatePinpointApp", - { - "Fn::GetAtt": [ - "PinpointFunctionOutputs", - "Id" - ] - }, - { - "Ref": "appId" - } - ] - } - }, - "appName": { - "Value": { - "Fn::If": [ - "ShouldCreatePinpointApp", - { - "Fn::GetAtt": [ - "PinpointFunctionOutputs", - "Name" - ] - }, - { - "Ref": "appName" - } - ] - } - } - }, - "Mappings": { - "RegionMapping": { - "us-east-1": { - "pinpointRegion": "us-east-1" - }, - "us-east-2": { - "pinpointRegion": "us-east-1" - }, - "sa-east-1": { - "pinpointRegion": "us-east-1" - }, - "ca-central-1": { - "pinpointRegion": "ca-central-1" - }, - "us-west-1": { - "pinpointRegion": "us-west-2" - }, - "us-west-2": { - "pinpointRegion": "us-west-2" - }, - "cn-north-1": { - "pinpointRegion": "us-west-2" - }, - "cn-northwest-1": { - "pinpointRegion": "us-west-2" - }, - "ap-south-1": { - "pinpointRegion": "ap-south-1" - }, - "ap-northeast-3": { - "pinpointRegion": "us-west-2" - }, - "ap-northeast-2": { - "pinpointRegion": "ap-northeast-2" - }, - "ap-southeast-1": { - "pinpointRegion": "ap-southeast-1" - }, - "ap-southeast-2": { - "pinpointRegion": "ap-southeast-2" - }, - "ap-northeast-1": { - "pinpointRegion": "ap-northeast-1" - }, - "eu-central-1": { - "pinpointRegion": "eu-central-1" - }, - "eu-north-1": { - "pinpointRegion": "eu-central-1" - }, - "eu-west-1": { - "pinpointRegion": "eu-west-1" - }, - "eu-west-2": { - "pinpointRegion": "eu-west-2" - }, - "eu-west-3": { - "pinpointRegion": "eu-west-1" - }, - "me-south-1": { - "pinpointRegion": "ap-south-1" - } - } - } -} \ No newline at end of file diff --git a/amplify/backend/api/thrifty/cli-inputs.json b/amplify/backend/api/thrifty2/cli-inputs.json old mode 100755 new mode 100644 similarity index 70% rename from amplify/backend/api/thrifty/cli-inputs.json rename to amplify/backend/api/thrifty2/cli-inputs.json index 8619fe6..6c408e9 --- a/amplify/backend/api/thrifty/cli-inputs.json +++ b/amplify/backend/api/thrifty2/cli-inputs.json @@ -4,15 +4,15 @@ "serviceName": "AppSync", "defaultAuthType": { "mode": "AMAZON_COGNITO_USER_POOLS", - "cognitoUserPoolId": "auththrifty21f6c364" + "cognitoUserPoolId": "auththrifty23c488d7e" }, "conflictResolution": { "defaultResolutionStrategy": { "type": "AUTOMERGE" } }, - "apiName": "thrifty", - "gqlSchemaPath": "/tmp/amplify-b38aed8f-cc0e-48c1-ab26-b93ee968bf10/amplify/backend/api/thrifty/schema.graphql", + "apiName": "thrifty2", + "gqlSchemaPath": "/tmp/amplify-5f5ada2c-a6db-4c8f-a135-c722a7a816d9/amplify/backend/api/thrifty2/schema.graphql", "additionalAuthTypes": [ { "mode": "API_KEY", diff --git a/amplify/backend/api/thrifty/parameters.json b/amplify/backend/api/thrifty2/parameters.json old mode 100755 new mode 100644 similarity index 61% rename from amplify/backend/api/thrifty/parameters.json rename to amplify/backend/api/thrifty2/parameters.json index 90e1080..254946c --- a/amplify/backend/api/thrifty/parameters.json +++ b/amplify/backend/api/thrifty2/parameters.json @@ -1,12 +1,12 @@ { - "AppSyncApiName": "thrifty", + "AppSyncApiName": "thrifty2", "DynamoDBBillingMode": "PAY_PER_REQUEST", "DynamoDBEnableServerSideEncryption": false, "AuthCognitoUserPoolId": { "Fn::GetAtt": [ - "auththrifty21f6c364", + "auththrifty23c488d7e", "Outputs.UserPoolId" ] }, - "AuthModeLastUpdated": "2021-11-28T17:20:48.071Z" + "AuthModeLastUpdated": "2021-12-01T23:40:42.562Z" } \ No newline at end of file diff --git a/amplify/backend/api/thrifty/resolvers/README.md b/amplify/backend/api/thrifty2/resolvers/README.md old mode 100755 new mode 100644 similarity index 100% rename from amplify/backend/api/thrifty/resolvers/README.md rename to amplify/backend/api/thrifty2/resolvers/README.md diff --git a/amplify/backend/api/thrifty/schema.graphql b/amplify/backend/api/thrifty2/schema.graphql old mode 100755 new mode 100644 similarity index 100% rename from amplify/backend/api/thrifty/schema.graphql rename to amplify/backend/api/thrifty2/schema.graphql diff --git a/amplify/backend/api/thrifty/stacks/CustomResources.json b/amplify/backend/api/thrifty2/stacks/CustomResources.json old mode 100755 new mode 100644 similarity index 100% rename from amplify/backend/api/thrifty/stacks/CustomResources.json rename to amplify/backend/api/thrifty2/stacks/CustomResources.json diff --git a/amplify/backend/api/thrifty/transform.conf.json b/amplify/backend/api/thrifty2/transform.conf.json old mode 100755 new mode 100644 similarity index 100% rename from amplify/backend/api/thrifty/transform.conf.json rename to amplify/backend/api/thrifty2/transform.conf.json diff --git a/amplify/backend/auth/thrifty21f6c364/parameters.json b/amplify/backend/auth/thrifty23c488d7e/parameters.json old mode 100755 new mode 100644 similarity index 79% rename from amplify/backend/auth/thrifty21f6c364/parameters.json rename to amplify/backend/auth/thrifty23c488d7e/parameters.json index 93c33f4..a91ddc4 --- a/amplify/backend/auth/thrifty21f6c364/parameters.json +++ b/amplify/backend/auth/thrifty23c488d7e/parameters.json @@ -1,8 +1,8 @@ { - "identityPoolName": "thrifty21f6c364_identitypool_21f6c364", - "allowUnauthenticatedIdentities": true, - "resourceNameTruncated": "thrift21f6c364", - "userPoolName": "thrifty21f6c364_userpool_21f6c364", + "identityPoolName": "thrifty23c488d7e_identitypool_3c488d7e", + "allowUnauthenticatedIdentities": false, + "resourceNameTruncated": "thrift3c488d7e", + "userPoolName": "thrifty23c488d7e_userpool_3c488d7e", "autoVerifiedAttributes": [ "email" ], @@ -29,10 +29,10 @@ "userpoolClientReadAttributes": [ "email" ], - "userpoolClientLambdaRole": "thrift21f6c364_userpoolclient_lambda_role", + "userpoolClientLambdaRole": "thrift3c488d7e_userpoolclient_lambda_role", "userpoolClientSetAttributes": false, - "sharedId": "21f6c364", - "resourceName": "thrifty21f6c364", + "sharedId": "3c488d7e", + "resourceName": "thrifty23c488d7e", "authSelections": "identityPoolAndUserPool", "authRoleArn": { "Fn::GetAtt": [ diff --git a/amplify/backend/auth/thrifty21f6c364/thrifty21f6c364-cloudformation-template.yml b/amplify/backend/auth/thrifty23c488d7e/thrifty23c488d7e-cloudformation-template.yml old mode 100755 new mode 100644 similarity index 93% rename from amplify/backend/auth/thrifty21f6c364/thrifty21f6c364-cloudformation-template.yml rename to amplify/backend/auth/thrifty23c488d7e/thrifty23c488d7e-cloudformation-template.yml index 950de39..cc8fd58 --- a/amplify/backend/auth/thrifty21f6c364/thrifty21f6c364-cloudformation-template.yml +++ b/amplify/backend/auth/thrifty23c488d7e/thrifty23c488d7e-cloudformation-template.yml @@ -126,6 +126,7 @@ Parameters: userPoolGroupList: Type: CommaDelimitedList + serviceName: Type: String @@ -152,7 +153,7 @@ Resources: # Created to allow the UserPool SMS Config to publish via the Simple Notification Service during MFA Process Type: AWS::IAM::Role Properties: - RoleName: !If [ShouldNotCreateEnvResources, 'thrift21f6c364_sns-role', !Join ['',[ 'sns', '21f6c364', !Select [3, !Split ['-', !Ref 'AWS::StackName']], '-', !Ref env]]] + RoleName: !If [ShouldNotCreateEnvResources, 'thrift3c488d7e_sns-role', !Join ['',[ 'sns', '3c488d7e', !Select [3, !Split ['-', !Ref 'AWS::StackName']], '-', !Ref env]]] AssumeRolePolicyDocument: Version: "2012-10-17" Statement: @@ -164,10 +165,10 @@ Resources: - "sts:AssumeRole" Condition: StringEquals: - sts:ExternalId: thrift21f6c364_role_external_id + sts:ExternalId: thrift3c488d7e_role_external_id Policies: - - PolicyName: thrift21f6c364-sns-policy + PolicyName: thrift3c488d7e-sns-policy PolicyDocument: Version: "2012-10-17" Statement: @@ -224,7 +225,7 @@ Resources: SmsAuthenticationMessage: !Ref smsAuthenticationMessage SmsConfiguration: SnsCallerArn: !GetAtt SNSRole.Arn - ExternalId: thrift21f6c364_role_external_id + ExternalId: thrift3c488d7e_role_external_id UserPoolClientWeb: @@ -232,7 +233,7 @@ Resources: # Depends on UserPool for ID reference Type: "AWS::Cognito::UserPoolClient" Properties: - ClientName: thrift21f6c364_app_clientWeb + ClientName: thrift3c488d7e_app_clientWeb RefreshTokenValidity: !Ref userpoolClientRefreshTokenValidity UserPoolId: !Ref UserPool @@ -242,7 +243,7 @@ Resources: # Depends on UserPool for ID reference Type: "AWS::Cognito::UserPoolClient" Properties: - ClientName: thrift21f6c364_app_client + ClientName: thrift3c488d7e_app_client GenerateSecret: !Ref userpoolClientGenerateSecret RefreshTokenValidity: !Ref userpoolClientRefreshTokenValidity @@ -253,7 +254,7 @@ Resources: # Created to execute Lambda which gets userpool app client config values Type: 'AWS::IAM::Role' Properties: - RoleName: !If [ShouldNotCreateEnvResources, !Ref userpoolClientLambdaRole, !Join ['',['upClientLambdaRole', '21f6c364', !Select [3, !Split ['-', !Ref 'AWS::StackName']], '-', !Ref env]]] + RoleName: !If [ShouldNotCreateEnvResources, !Ref userpoolClientLambdaRole, !Join ['',['upClientLambdaRole', '3c488d7e', !Select [3, !Split ['-', !Ref 'AWS::StackName']], '-', !Ref env]]] AssumeRolePolicyDocument: Version: '2012-10-17' Statement: @@ -307,7 +308,7 @@ Resources: # Marked as depending on UserPoolClientRole for easier to understand CFN sequencing Type: 'AWS::IAM::Policy' Properties: - PolicyName: thrift21f6c364_userpoolclient_lambda_iam_policy + PolicyName: thrift3c488d7e_userpoolclient_lambda_iam_policy Roles: - !Ref UserPoolClientRole PolicyDocument: @@ -324,7 +325,7 @@ Resources: # Marked as depending on UserPoolClientLambdaPolicy for easier to understand CFN sequencing Type: 'AWS::IAM::Policy' Properties: - PolicyName: thrift21f6c364_userpoolclient_lambda_log_policy + PolicyName: thrift3c488d7e_userpoolclient_lambda_log_policy Roles: - !Ref UserPoolClientRole PolicyDocument: @@ -364,7 +365,7 @@ Resources: # Always created Type: AWS::Cognito::IdentityPool Properties: - IdentityPoolName: !If [ShouldNotCreateEnvResources, 'thrifty21f6c364_identitypool_21f6c364', !Join ['',['thrifty21f6c364_identitypool_21f6c364', '__', !Ref env]]] + IdentityPoolName: !If [ShouldNotCreateEnvResources, 'thrifty23c488d7e_identitypool_3c488d7e', !Join ['',['thrifty23c488d7e_identitypool_3c488d7e', '__', !Ref env]]] CognitoIdentityProviders: - ClientId: !Ref UserPoolClient diff --git a/amplify/backend/backend-config.json b/amplify/backend/backend-config.json old mode 100755 new mode 100644 index 27082ea..1c24ae3 --- a/amplify/backend/backend-config.json +++ b/amplify/backend/backend-config.json @@ -1,77 +1,63 @@ { - "api": { - "thrifty": { - "service": "AppSync", - "providerPlugin": "awscloudformation", - "output": { - "authConfig": { - "defaultAuthentication": { - "authenticationType": "AMAZON_COGNITO_USER_POOLS", - "userPoolConfig": { - "userPoolId": "auththrifty21f6c364" - } - }, - "additionalAuthenticationProviders": [ - { - "authenticationType": "API_KEY", - "apiKeyConfig": { - "apiKeyExpirationDays": 30, - "description": "api key description" - } - }, - { - "authenticationType": "AWS_IAM" - } - ] - } + "api": { + "thrifty2": { + "service": "AppSync", + "providerPlugin": "awscloudformation", + "output": { + "authConfig": { + "defaultAuthentication": { + "authenticationType": "AMAZON_COGNITO_USER_POOLS", + "userPoolConfig": { + "userPoolId": "auththrifty23c488d7e" } - } - }, - "auth": { - "thrifty21f6c364": { - "service": "Cognito", - "providerPlugin": "awscloudformation", - "dependsOn": [], - "customAuth": false, - "frontendAuthConfig": { - "loginMechanisms": [ - "EMAIL" - ], - "signupAttributes": [ - "EMAIL" - ], - "passwordProtectionSettings": { - "passwordPolicyMinLength": 8, - "passwordPolicyCharacters": [] - }, - "mfaConfiguration": "OFF", - "mfaTypes": [ - "SMS" - ], - "verificationMechanisms": [ - "EMAIL" - ] + }, + "additionalAuthenticationProviders": [ + { + "authenticationType": "API_KEY", + "apiKeyConfig": { + "apiKeyExpirationDays": 30, + "description": "api key description" + } + }, + { + "authenticationType": "AWS_IAM" } + ] } - }, - "storage": { - "SSDStorage": { - "service": "S3", - "providerPlugin": "awscloudformation" - } - }, - "notifications": { - "ThriftyOWUjV": { - "service": "Pinpoint", - "channels": [ - "FCM" - ] - } - }, - "analytics": { - "ThriftyOWUjV": { - "service": "Pinpoint", - "providerPlugin": "awscloudformation" - } + } + } + }, + "auth": { + "thrifty23c488d7e": { + "service": "Cognito", + "providerPlugin": "awscloudformation", + "dependsOn": [], + "customAuth": false, + "frontendAuthConfig": { + "loginMechanisms": [ + "EMAIL" + ], + "signupAttributes": [ + "EMAIL" + ], + "passwordProtectionSettings": { + "passwordPolicyMinLength": 8, + "passwordPolicyCharacters": [] + }, + "mfaConfiguration": "OFF", + "mfaTypes": [ + "SMS" + ], + "verificationMechanisms": [ + "EMAIL" + ] + } + } + }, + "storage": { + "s370dc9769": { + "service": "S3", + "providerPlugin": "awscloudformation" } + } } \ No newline at end of file diff --git a/amplify/backend/storage/SSDStorage/parameters.json b/amplify/backend/storage/s370dc9769/parameters.json old mode 100755 new mode 100644 similarity index 67% rename from amplify/backend/storage/SSDStorage/parameters.json rename to amplify/backend/storage/s370dc9769/parameters.json index 3ab7dad..3c516e2 --- a/amplify/backend/storage/SSDStorage/parameters.json +++ b/amplify/backend/storage/s370dc9769/parameters.json @@ -1,7 +1,7 @@ { - "bucketName": "thrifty9ac428d5d3084fb499b8aaa6395680b8", - "authPolicyName": "s3_amplify_2b6f0a5b", - "unauthPolicyName": "s3_amplify_2b6f0a5b", + "bucketName": "thrifty247548cdc463d4e43b8b9b7d31a4af078", + "authPolicyName": "s3_amplify_70dc9769", + "unauthPolicyName": "s3_amplify_70dc9769", "authRoleName": { "Ref": "AuthRoleName" }, @@ -19,15 +19,15 @@ "s3:DeleteObject" ], "s3PermissionsAuthenticatedPublic": "s3:PutObject,s3:GetObject,s3:DeleteObject", - "s3PublicPolicy": "Public_policy_0e1bbdf5", + "s3PublicPolicy": "Public_policy_1ea55534", "s3PermissionsAuthenticatedUploads": "s3:PutObject", - "s3UploadsPolicy": "Uploads_policy_0e1bbdf5", + "s3UploadsPolicy": "Uploads_policy_1ea55534", "s3PermissionsAuthenticatedProtected": "s3:PutObject,s3:GetObject,s3:DeleteObject", - "s3ProtectedPolicy": "Protected_policy_0e1bbdf5", + "s3ProtectedPolicy": "Protected_policy_1ea55534", "s3PermissionsAuthenticatedPrivate": "s3:PutObject,s3:GetObject,s3:DeleteObject", - "s3PrivatePolicy": "Private_policy_0e1bbdf5", + "s3PrivatePolicy": "Private_policy_1ea55534", "AuthenticatedAllowList": "ALLOW", - "s3ReadPolicy": "read_policy_0e1bbdf5", + "s3ReadPolicy": "read_policy_1ea55534", "s3PermissionsGuestPublic": "DISALLOW", "s3PermissionsGuestUploads": "DISALLOW", "GuestAllowList": "DISALLOW", diff --git a/amplify/backend/storage/SSDStorage/s3-cloudformation-template.json b/amplify/backend/storage/s370dc9769/s3-cloudformation-template.json old mode 100755 new mode 100644 similarity index 100% rename from amplify/backend/storage/SSDStorage/s3-cloudformation-template.json rename to amplify/backend/storage/s370dc9769/s3-cloudformation-template.json diff --git a/amplify/backend/storage/SSDStorage/storage-params.json b/amplify/backend/storage/s370dc9769/storage-params.json old mode 100755 new mode 100644 similarity index 100% rename from amplify/backend/storage/SSDStorage/storage-params.json rename to amplify/backend/storage/s370dc9769/storage-params.json diff --git a/amplify/backend/tags.json b/amplify/backend/tags.json old mode 100755 new mode 100644 diff --git a/amplify/backend/types/amplify-dependent-resources-ref.d.ts b/amplify/backend/types/amplify-dependent-resources-ref.d.ts index d1ed9b8..ed6ad2d 100644 --- a/amplify/backend/types/amplify-dependent-resources-ref.d.ts +++ b/amplify/backend/types/amplify-dependent-resources-ref.d.ts @@ -1,12 +1,12 @@ export type AmplifyDependentResourcesAttributes = { "api": { - "thrifty": { + "thrifty2": { "GraphQLAPIIdOutput": "string", "GraphQLAPIEndpointOutput": "string" } }, "auth": { - "thrifty21f6c364": { + "thrifty23c488d7e": { "IdentityPoolId": "string", "IdentityPoolName": "string", "UserPoolId": "string", @@ -17,16 +17,9 @@ export type AmplifyDependentResourcesAttributes = { } }, "storage": { - "SSDStorage": { + "s370dc9769": { "BucketName": "string", "Region": "string" } - }, - "analytics": { - "ThriftyOWUjV": { - "Region": "string", - "Id": "string", - "appName": "string" - } } } \ No newline at end of file diff --git a/amplify/cli.json b/amplify/cli.json old mode 100755 new mode 100644 diff --git a/amplify/team-provider-info.json b/amplify/team-provider-info.json index 9d31790..63268b5 100644 --- a/amplify/team-provider-info.json +++ b/amplify/team-provider-info.json @@ -1,26 +1,19 @@ { - "dev": { + "app": { "awscloudformation": { - "AuthRoleName": "amplify-thrifty-dev-144858-authRole", - "UnauthRoleArn": "arn:aws:iam::459760485083:role/amplify-thrifty-dev-144858-unauthRole", - "AuthRoleArn": "arn:aws:iam::459760485083:role/amplify-thrifty-dev-144858-authRole", + "AuthRoleName": "amplify-thrifty2-app-11615-authRole", + "UnauthRoleArn": "arn:aws:iam::459760485083:role/amplify-thrifty2-app-11615-unauthRole", + "AuthRoleArn": "arn:aws:iam::459760485083:role/amplify-thrifty2-app-11615-authRole", "Region": "eu-central-1", - "DeploymentBucketName": "amplify-thrifty-dev-144858-deployment", - "UnauthRoleName": "amplify-thrifty-dev-144858-unauthRole", - "StackName": "amplify-thrifty-dev-144858", - "StackId": "arn:aws:cloudformation:eu-central-1:459760485083:stack/amplify-thrifty-dev-144858/659b7da0-4f80-11ec-a95f-022ef605612a", - "AmplifyAppId": "d2xhz0mn88sj6z" + "DeploymentBucketName": "amplify-thrifty2-app-11615-deployment", + "UnauthRoleName": "amplify-thrifty2-app-11615-unauthRole", + "StackName": "amplify-thrifty2-app-11615", + "StackId": "arn:aws:cloudformation:eu-central-1:459760485083:stack/amplify-thrifty2-app-11615/b0f400e0-52fc-11ec-b5ff-0a4e79c28f7a", + "AmplifyAppId": "d5gnyjf8rb4i4" }, "categories": { - "notifications": { - "Pinpoint": { - "Name": "ThriftyOWUjV-dev", - "Id": "f06bd624184f4c90bc7556672ddd9619", - "Region": "eu-central-1" - } - }, "auth": { - "thrifty21f6c364": {} + "thrifty23c488d7e": {} } } } diff --git a/app/.idea/workspace.xml b/app/.idea/workspace.xml index c307c33..985deed 100644 --- a/app/.idea/workspace.xml +++ b/app/.idea/workspace.xml @@ -1,56 +1,56 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1638010250774 - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1638010250774 + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 036fd14..8f3b34d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,59 +1,59 @@ -plugins { - id 'com.android.application' - id 'com.google.gms.google-services' -} - -android { - compileSdk 31 - - defaultConfig { - applicationId "com.example.thrifty" - minSdk 21 - targetSdk 31 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } -} - -dependencies { - implementation platform('com.google.firebase:firebase-bom:29.0.0') - implementation 'com.google.firebase:firebase-messaging' - implementation 'com.google.firebase:firebase-analytics' - implementation 'com.google.android.gms:play-services-auth:19.2.0' - - implementation 'com.amazonaws:aws-android-sdk-pinpoint:2.36.0' - implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.36.0' - - implementation 'com.amplifyframework:aws-analytics-pinpoint:1.30.0' - implementation 'com.amplifyframework:aws-storage-s3:1.30.0' - implementation 'com.amplifyframework:aws-auth-cognito:1.30.0' - implementation 'com.amplifyframework:core:1.30.0' - implementation 'com.amplifyframework:aws-datastore:1.30.0' - implementation 'com.amplifyframework:aws-api:1.30.0' - implementation "com.google.android.material:material:1.4.0" - implementation 'androidx.appcompat:appcompat:1.3.1' - implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.3' - implementation "androidx.cardview:cardview:1.0.0" - implementation 'com.google.android.material:material:1.4.0' - implementation "androidx.cardview:cardview:1.0.0" - implementation 'androidx.constraintlayout:constraintlayout:2.1.2' - implementation 'androidx.legacy:legacy-support-v4:1.0.0' - testImplementation 'junit:junit:4.+' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - -} -apply plugin: 'com.google.gms.google-services' +plugins { + id 'com.android.application' + id 'com.google.gms.google-services' +} + +android { + compileSdk 31 + + defaultConfig { + applicationId "com.example.thrifty" + minSdk 21 + targetSdk 31 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation platform('com.google.firebase:firebase-bom:29.0.0') + implementation 'com.google.firebase:firebase-messaging' + implementation 'com.google.firebase:firebase-analytics' + implementation 'com.google.android.gms:play-services-auth:19.2.0' + + implementation 'com.amazonaws:aws-android-sdk-pinpoint:2.36.0' + implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.36.0' + + implementation 'com.amplifyframework:aws-analytics-pinpoint:1.30.0' + implementation 'com.amplifyframework:aws-storage-s3:1.30.0' + implementation 'com.amplifyframework:aws-auth-cognito:1.30.0' + implementation 'com.amplifyframework:core:1.30.0' + implementation 'com.amplifyframework:aws-datastore:1.30.0' + implementation 'com.amplifyframework:aws-api:1.30.0' + implementation "com.google.android.material:material:1.4.0" + implementation 'androidx.appcompat:appcompat:1.3.1' + implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.3' + implementation "androidx.cardview:cardview:1.0.0" + implementation 'com.google.android.material:material:1.4.0' + implementation "androidx.cardview:cardview:1.0.0" + implementation 'androidx.constraintlayout:constraintlayout:2.1.2' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + testImplementation 'junit:junit:4.+' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + +} +apply plugin: 'com.google.gms.google-services' diff --git a/app/google-services.json b/app/google-services.json index 0bb730c..3818c7c 100644 --- a/app/google-services.json +++ b/app/google-services.json @@ -1,39 +1,39 @@ -{ - "project_info": { - "project_number": "608816577570", - "project_id": "thrifty-7d9f7", - "storage_bucket": "thrifty-7d9f7.appspot.com" - }, - "client": [ - { - "client_info": { - "mobilesdk_app_id": "1:608816577570:android:812e4f298ed2836c925e7b", - "android_client_info": { - "package_name": "com.example.thrifty" - } - }, - "oauth_client": [ - { - "client_id": "608816577570-4k85dlc0p227aj9ofddejrfjdbmcj5s1.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCI4K3t7Dae5qYAEs02EyaAaCJqYOx76Ag" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "608816577570-4k85dlc0p227aj9ofddejrfjdbmcj5s1.apps.googleusercontent.com", - "client_type": 3 - } - ] - } - } - } - ], - "configuration_version": "1" +{ + "project_info": { + "project_number": "608816577570", + "project_id": "thrifty-7d9f7", + "storage_bucket": "thrifty-7d9f7.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:608816577570:android:812e4f298ed2836c925e7b", + "android_client_info": { + "package_name": "com.example.thrifty" + } + }, + "oauth_client": [ + { + "client_id": "608816577570-4k85dlc0p227aj9ofddejrfjdbmcj5s1.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCI4K3t7Dae5qYAEs02EyaAaCJqYOx76Ag" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "608816577570-4k85dlc0p227aj9ofddejrfjdbmcj5s1.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + } + ], + "configuration_version": "1" } \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 481bb43..64b4a05 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,21 +1,21 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. #-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/androidTest/java/com/example/thrifty/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/example/thrifty/ExampleInstrumentedTest.java index b6e1035..642c65e 100644 --- a/app/src/androidTest/java/com/example/thrifty/ExampleInstrumentedTest.java +++ b/app/src/androidTest/java/com/example/thrifty/ExampleInstrumentedTest.java @@ -1,26 +1,26 @@ -package com.example.thrifty; - -import android.content.Context; - -import androidx.test.platform.app.InstrumentationRegistry; -import androidx.test.ext.junit.runners.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.*; - -/** - * Instrumented test, which will execute on an Android device. - * - * @see Testing documentation - */ -@RunWith(AndroidJUnit4.class) -public class ExampleInstrumentedTest { - @Test - public void useAppContext() { - // Context of the app under test. - Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - assertEquals("com.example.thrifty", appContext.getPackageName()); - } +package com.example.thrifty; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.example.thrifty", appContext.getPackageName()); + } } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0ae36f0..5f8177c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,71 +1,83 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/amplifyframework/datastore/generated/model/AmplifyModelProvider.java b/app/src/main/java/com/amplifyframework/datastore/generated/model/AmplifyModelProvider.java index c7a5842..c5569f5 100644 --- a/app/src/main/java/com/amplifyframework/datastore/generated/model/AmplifyModelProvider.java +++ b/app/src/main/java/com/amplifyframework/datastore/generated/model/AmplifyModelProvider.java @@ -13,7 +13,7 @@ */ public final class AmplifyModelProvider implements ModelProvider { - private static final String AMPLIFY_MODEL_VERSION = "1c29971a13d9fcd249685dddf076b501"; + private static final String AMPLIFY_MODEL_VERSION = "52523adac5d643063a009102021f267d"; private static AmplifyModelProvider amplifyGeneratedModelInstance; private AmplifyModelProvider() { diff --git a/app/src/main/java/com/amplifyframework/datastore/generated/model/Category.java b/app/src/main/java/com/amplifyframework/datastore/generated/model/Category.java index fa1633b..534b2a4 100644 --- a/app/src/main/java/com/amplifyframework/datastore/generated/model/Category.java +++ b/app/src/main/java/com/amplifyframework/datastore/generated/model/Category.java @@ -1,6 +1,5 @@ package com.amplifyframework.datastore.generated.model; -import com.amplifyframework.core.model.annotations.HasMany; import com.amplifyframework.core.model.temporal.Temporal; import java.util.List; @@ -30,7 +29,6 @@ public final class Category implements Model { public static final QueryField NAME = field("Category", "name"); private final @ModelField(targetType="ID", isRequired = true) String id; private final @ModelField(targetType="String", isRequired = true) String name; - private final @ModelField(targetType="Product") @HasMany(associatedWith = "categoryID", type = Product.class) List Products = null; private @ModelField(targetType="AWSDateTime", isReadOnly = true) Temporal.DateTime createdAt; private @ModelField(targetType="AWSDateTime", isReadOnly = true) Temporal.DateTime updatedAt; public String getId() { @@ -41,10 +39,6 @@ public String getName() { return name; } - public List getProducts() { - return Products; - } - public Temporal.DateTime getCreatedAt() { return createdAt; } diff --git a/app/src/main/java/com/amplifyframework/datastore/generated/model/ProductFavorite.java b/app/src/main/java/com/amplifyframework/datastore/generated/model/ProductFavorite.java new file mode 100644 index 0000000..b2804e1 --- /dev/null +++ b/app/src/main/java/com/amplifyframework/datastore/generated/model/ProductFavorite.java @@ -0,0 +1,209 @@ +package com.amplifyframework.datastore.generated.model; + +import com.amplifyframework.core.model.annotations.BelongsTo; + +import java.util.List; +import java.util.UUID; +import java.util.Objects; + +import androidx.core.util.ObjectsCompat; + +import com.amplifyframework.core.model.AuthStrategy; +import com.amplifyframework.core.model.Model; +import com.amplifyframework.core.model.ModelOperation; +import com.amplifyframework.core.model.annotations.AuthRule; +import com.amplifyframework.core.model.annotations.Index; +import com.amplifyframework.core.model.annotations.ModelConfig; +import com.amplifyframework.core.model.annotations.ModelField; +import com.amplifyframework.core.model.query.predicate.QueryField; + +import static com.amplifyframework.core.model.query.predicate.QueryField.field; + +/** This is an auto generated class representing the ProductFavorite type in your schema. */ +@SuppressWarnings("all") +@ModelConfig(pluralName = "ProductFavorites", authRules = { + @AuthRule(allow = AuthStrategy.PRIVATE, operations = { ModelOperation.CREATE, ModelOperation.UPDATE, ModelOperation.DELETE, ModelOperation.READ }), + @AuthRule(allow = AuthStrategy.PRIVATE, operations = { ModelOperation.CREATE, ModelOperation.UPDATE, ModelOperation.DELETE, ModelOperation.READ }) +}) +@Index(name = "byProduct", fields = {"productID","favoriteID"}) +@Index(name = "byFavorite", fields = {"favoriteID","productID"}) +public final class ProductFavorite implements Model { + public static final QueryField ID = field("id"); + public static final QueryField PRODUCT = field("productID"); + public static final QueryField FAVORITE = field("favoriteID"); + private final @ModelField(targetType="ID", isRequired = true) String id; + private final @ModelField(targetType="Product", isRequired = true) @BelongsTo(targetName = "productID", type = Product.class) Product product; + private final @ModelField(targetType="Favorite", isRequired = true) @BelongsTo(targetName = "favoriteID", type = Favorite.class) Favorite favorite; + public String getId() { + return id; + } + + public Product getProduct() { + return product; + } + + public Favorite getFavorite() { + return favorite; + } + + private ProductFavorite(String id, Product product, Favorite favorite) { + this.id = id; + this.product = product; + this.favorite = favorite; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } else if(obj == null || getClass() != obj.getClass()) { + return false; + } else { + ProductFavorite productFavorite = (ProductFavorite) obj; + return ObjectsCompat.equals(getId(), productFavorite.getId()) && + ObjectsCompat.equals(getProduct(), productFavorite.getProduct()) && + ObjectsCompat.equals(getFavorite(), productFavorite.getFavorite()); + } + } + + @Override + public int hashCode() { + return new StringBuilder() + .append(getId()) + .append(getProduct()) + .append(getFavorite()) + .toString() + .hashCode(); + } + + @Override + public String toString() { + return new StringBuilder() + .append("ProductFavorite {") + .append("id=" + String.valueOf(getId()) + ", ") + .append("product=" + String.valueOf(getProduct()) + ", ") + .append("favorite=" + String.valueOf(getFavorite())) + .append("}") + .toString(); + } + + public static ProductStep builder() { + return new Builder(); + } + + /** + * WARNING: This method should not be used to build an instance of this object for a CREATE mutation. + * This is a convenience method to return an instance of the object with only its ID populated + * to be used in the context of a parameter in a delete mutation or referencing a foreign key + * in a relationship. + * @param id the id of the existing item this instance will represent + * @return an instance of this model with only ID populated + * @throws IllegalArgumentException Checks that ID is in the proper format + */ + public static ProductFavorite justId(String id) { + try { + UUID.fromString(id); // Check that ID is in the UUID format - if not an exception is thrown + } catch (Exception exception) { + throw new IllegalArgumentException( + "Model IDs must be unique in the format of UUID. This method is for creating instances " + + "of an existing object with only its ID field for sending as a mutation parameter. When " + + "creating a new object, use the standard builder method and leave the ID field blank." + ); + } + return new ProductFavorite( + id, + null, + null + ); + } + + public CopyOfBuilder copyOfBuilder() { + return new CopyOfBuilder(id, + product, + favorite); + } + public interface ProductStep { + FavoriteStep product(Product product); + } + + + public interface FavoriteStep { + BuildStep favorite(Favorite favorite); + } + + + public interface BuildStep { + ProductFavorite build(); + BuildStep id(String id) throws IllegalArgumentException; + } + + + public static class Builder implements ProductStep, FavoriteStep, BuildStep { + private String id; + private Product product; + private Favorite favorite; + @Override + public ProductFavorite build() { + String id = this.id != null ? this.id : UUID.randomUUID().toString(); + + return new ProductFavorite( + id, + product, + favorite); + } + + @Override + public FavoriteStep product(Product product) { + Objects.requireNonNull(product); + this.product = product; + return this; + } + + @Override + public BuildStep favorite(Favorite favorite) { + Objects.requireNonNull(favorite); + this.favorite = favorite; + return this; + } + + /** + * WARNING: Do not set ID when creating a new object. Leave this blank and one will be auto generated for you. + * This should only be set when referring to an already existing object. + * @param id id + * @return Current Builder instance, for fluent method chaining + * @throws IllegalArgumentException Checks that ID is in the proper format + */ + public BuildStep id(String id) throws IllegalArgumentException { + this.id = id; + + try { + UUID.fromString(id); // Check that ID is in the UUID format - if not an exception is thrown + } catch (Exception exception) { + throw new IllegalArgumentException("Model IDs must be unique in the format of UUID.", + exception); + } + + return this; + } + } + + + public final class CopyOfBuilder extends Builder { + private CopyOfBuilder(String id, Product product, Favorite favorite) { + super.id(id); + super.product(product) + .favorite(favorite); + } + + @Override + public CopyOfBuilder product(Product product) { + return (CopyOfBuilder) super.product(product); + } + + @Override + public CopyOfBuilder favorite(Favorite favorite) { + return (CopyOfBuilder) super.favorite(favorite); + } + } + +} diff --git a/app/src/main/java/com/amplifyframework/datastore/generated/model/User.java b/app/src/main/java/com/amplifyframework/datastore/generated/model/User.java index 5e33a2e..1b7bb0b 100644 --- a/app/src/main/java/com/amplifyframework/datastore/generated/model/User.java +++ b/app/src/main/java/com/amplifyframework/datastore/generated/model/User.java @@ -1,6 +1,5 @@ package com.amplifyframework.datastore.generated.model; -import com.amplifyframework.core.model.annotations.HasMany; import com.amplifyframework.core.model.temporal.Temporal; import java.util.List; @@ -30,7 +29,6 @@ public final class User implements Model { public static final QueryField EMAIL = field("User", "email"); private final @ModelField(targetType="ID", isRequired = true) String id; private final @ModelField(targetType="String", isRequired = true) String email; - private final @ModelField(targetType="Favorite") @HasMany(associatedWith = "userID", type = Favorite.class) List Favorite = null; private @ModelField(targetType="AWSDateTime", isReadOnly = true) Temporal.DateTime createdAt; private @ModelField(targetType="AWSDateTime", isReadOnly = true) Temporal.DateTime updatedAt; public String getId() { @@ -41,10 +39,6 @@ public String getEmail() { return email; } - public List getFavorite() { - return Favorite; - } - public Temporal.DateTime getCreatedAt() { return createdAt; } diff --git a/app/src/main/java/com/example/thrifty/Accessories.java b/app/src/main/java/com/example/thrifty/Accessories.java index 46d6e5a..bfae7b9 100644 --- a/app/src/main/java/com/example/thrifty/Accessories.java +++ b/app/src/main/java/com/example/thrifty/Accessories.java @@ -1,67 +1,67 @@ -package com.example.thrifty; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; -import android.os.Message; -import android.util.Log; - -import com.amplifyframework.AmplifyException; -import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; -import com.amplifyframework.api.aws.AWSApiPlugin; -import com.amplifyframework.api.graphql.model.ModelQuery; -import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; -import com.amplifyframework.core.Amplify; -import com.amplifyframework.datastore.AWSDataStorePlugin; -import com.amplifyframework.datastore.generated.model.Product; -import com.amplifyframework.storage.s3.AWSS3StoragePlugin; -import com.example.thrifty.adapters.AccessoriesAdapter; -import com.example.thrifty.adapters.BeltsAdapter; -import com.example.thrifty.adapters.KidsClothesAdapter; -import com.example.thrifty.adapters.WatchesAdapter; - -import java.util.ArrayList; -import java.util.List; - -public class Accessories extends AppCompatActivity { - - private List categorizedProducts = new ArrayList<>(); - RecyclerView categorizedRecView; - AccessoriesAdapter accessoriesAdapter; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_accessories); - - - categorizedRecView = findViewById(R.id.categorizedRecView); - categorizedRecView.setAdapter(accessoriesAdapter); - categorizedRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(),RecyclerView.HORIZONTAL,false)); - - categorizedRecView.setAdapter(new AccessoriesAdapter(categorizedProducts,this)); - Handler categorizedHandler = new Handler(Looper.myLooper(), new Handler.Callback() { - @Override - public boolean handleMessage(@NonNull Message msg) { - categorizedRecView.getAdapter().notifyDataSetChanged(); - return false; - } - }); - Amplify.API.query( - ModelQuery.list(Product.class,Product.CATEGORY_ID.eq("accessories")), - response -> { - for (Product product : response.getData()) { - categorizedProducts.add(product); - } - categorizedHandler.sendEmptyMessage(1); - }, error -> Log.e("MyAmplifyApp", "Query failure", error) - ); - - } - +package com.example.thrifty; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.util.Log; + +import com.amplifyframework.AmplifyException; +import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; +import com.amplifyframework.api.aws.AWSApiPlugin; +import com.amplifyframework.api.graphql.model.ModelQuery; +import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; +import com.amplifyframework.core.Amplify; +import com.amplifyframework.datastore.AWSDataStorePlugin; +import com.amplifyframework.datastore.generated.model.Product; +import com.amplifyframework.storage.s3.AWSS3StoragePlugin; +import com.example.thrifty.adapters.AccessoriesAdapter; +import com.example.thrifty.adapters.BeltsAdapter; +import com.example.thrifty.adapters.KidsClothesAdapter; +import com.example.thrifty.adapters.WatchesAdapter; + +import java.util.ArrayList; +import java.util.List; + +public class Accessories extends AppCompatActivity { + + private List categorizedProducts = new ArrayList<>(); + RecyclerView categorizedRecView; + AccessoriesAdapter accessoriesAdapter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_accessories); + + + categorizedRecView = findViewById(R.id.categorizedRecView); + categorizedRecView.setAdapter(accessoriesAdapter); + categorizedRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(),RecyclerView.HORIZONTAL,false)); + + categorizedRecView.setAdapter(new AccessoriesAdapter(categorizedProducts,this)); + Handler categorizedHandler = new Handler(Looper.myLooper(), new Handler.Callback() { + @Override + public boolean handleMessage(@NonNull Message msg) { + categorizedRecView.getAdapter().notifyDataSetChanged(); + return false; + } + }); + Amplify.API.query( + ModelQuery.list(Product.class,Product.CATEGORY_ID.eq("accessories")), + response -> { + for (Product product : response.getData()) { + categorizedProducts.add(product); + } + categorizedHandler.sendEmptyMessage(1); + }, error -> Log.e("MyAmplifyApp", "Query failure", error) + ); + + } + } \ No newline at end of file diff --git a/app/src/main/java/com/example/thrifty/Admin.java b/app/src/main/java/com/example/thrifty/Admin.java index 0e41ca6..268c72f 100644 --- a/app/src/main/java/com/example/thrifty/Admin.java +++ b/app/src/main/java/com/example/thrifty/Admin.java @@ -1,106 +1,106 @@ -package com.example.thrifty; - -import androidx.appcompat.app.AppCompatActivity; - -import android.content.Intent; -import android.os.Bundle; -import android.util.Log; -import android.view.View; -import android.widget.ArrayAdapter; -import android.widget.Button; -import android.widget.EditText; -import android.widget.Spinner; -import android.widget.Toolbar; - -import com.amplifyframework.AmplifyException; -//import com.amplifyframework.api.graphql.model.ModelMutation; -import com.amplifyframework.api.aws.AWSApiPlugin; -import com.amplifyframework.api.graphql.model.ModelMutation; -import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; -import com.amplifyframework.core.Amplify; -import com.amplifyframework.datastore.AWSDataStorePlugin; -import com.amplifyframework.datastore.generated.model.Category; -import com.amplifyframework.datastore.generated.model.Product; -import com.amplifyframework.storage.s3.AWSS3StoragePlugin; - -public class Admin extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_admin); - - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - toolbar.setNavigationIcon(R.drawable.ic_baseline_arrow_back_ios_new_24); - toolbar.setNavigationOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - - Intent intent = new Intent(Admin.this, MainActivity.class); - startActivity(intent); - } - }); - - try { -// Amplify.addPlugin(new AWSPinpointAnalyticsPlugin(getApplication())); - Amplify.addPlugin(new AWSS3StoragePlugin()); - Amplify.addPlugin(new AWSCognitoAuthPlugin()); - Amplify.addPlugin(new AWSDataStorePlugin()); - Amplify.addPlugin(new AWSApiPlugin()); - Amplify.configure(getApplicationContext()); - Log.i("MyAmplifyApp", "Initialized Amplify"); - } catch (AmplifyException error) { - Log.e("MyAmplifyApp", "Could not initialize Amplify", error); - } - - - Spinner spinnerLanguages=findViewById(R.id.spinner); - ArrayAdapter adapter=ArrayAdapter.createFromResource(this, R.array.shop, android.R.layout.simple_spinner_item); - adapter.setDropDownViewResource(android.R.layout.simple_spinner_item); - spinnerLanguages.setAdapter(adapter); - - Spinner spinnersize=findViewById(R.id.sizespinner); - ArrayAdapter adapter1=ArrayAdapter.createFromResource(this, R.array.size, android.R.layout.simple_spinner_item); - adapter1.setDropDownViewResource(android.R.layout.simple_spinner_item); - spinnersize.setAdapter(adapter1); - - Button add = findViewById(R.id.addproduct); - add.setOnClickListener(view -> { - EditText name = findViewById(R.id.nametext); - EditText description = findViewById(R.id.descriptiontext); - EditText price = findViewById(R.id.pricetext); - Spinner category = findViewById(R.id.spinner); - Spinner size = findViewById(R.id.sizespinner); - EditText color = findViewById(R.id.colortext); - - String setname = name.getText().toString(); - String setdescription = description.getText().toString(); - String setprice = price.getText().toString(); - String setcategory = category.getSelectedItem().toString(); - String setsize = size.getSelectedItem().toString(); - String setcolor = color.getText().toString(); - Log.i("category", setcategory ); - - Intent intent = new Intent(Admin.this,MainActivity.class); - startActivity(intent); - - - - Product product = new Product.Builder() - .title(setname) - .description(setdescription) - .price(setprice) - .size(setsize) - .color(setcolor) - .image("") - .categoryId(setcategory) - .build(); - - Amplify.API.mutate( - ModelMutation.create(product), - response -> Log.i("MyAmplifyApp", "Added Todo with id: " + response.getData().getId()), - error -> Log.e("MyAmplifyApp", "Create failed", error) - ); - }); - } +package com.example.thrifty; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Spinner; +import android.widget.Toolbar; + +import com.amplifyframework.AmplifyException; +//import com.amplifyframework.api.graphql.model.ModelMutation; +import com.amplifyframework.api.aws.AWSApiPlugin; +import com.amplifyframework.api.graphql.model.ModelMutation; +import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; +import com.amplifyframework.core.Amplify; +import com.amplifyframework.datastore.AWSDataStorePlugin; +import com.amplifyframework.datastore.generated.model.Category; +import com.amplifyframework.datastore.generated.model.Product; +import com.amplifyframework.storage.s3.AWSS3StoragePlugin; + +public class Admin extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_admin); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + toolbar.setNavigationIcon(R.drawable.ic_baseline_arrow_back_ios_new_24); + toolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + Intent intent = new Intent(Admin.this, MainActivity.class); + startActivity(intent); + } + }); + + try { +// Amplify.addPlugin(new AWSPinpointAnalyticsPlugin(getApplication())); + Amplify.addPlugin(new AWSS3StoragePlugin()); + Amplify.addPlugin(new AWSCognitoAuthPlugin()); + Amplify.addPlugin(new AWSDataStorePlugin()); + Amplify.addPlugin(new AWSApiPlugin()); + Amplify.configure(getApplicationContext()); + Log.i("MyAmplifyApp", "Initialized Amplify"); + } catch (AmplifyException error) { + Log.e("MyAmplifyApp", "Could not initialize Amplify", error); + } + + + Spinner spinnerLanguages=findViewById(R.id.spinner); + ArrayAdapter adapter=ArrayAdapter.createFromResource(this, R.array.shop, android.R.layout.simple_spinner_item); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_item); + spinnerLanguages.setAdapter(adapter); + + Spinner spinnersize=findViewById(R.id.sizespinner); + ArrayAdapter adapter1=ArrayAdapter.createFromResource(this, R.array.size, android.R.layout.simple_spinner_item); + adapter1.setDropDownViewResource(android.R.layout.simple_spinner_item); + spinnersize.setAdapter(adapter1); + + Button add = findViewById(R.id.addproduct); + add.setOnClickListener(view -> { + EditText name = findViewById(R.id.nametext); + EditText description = findViewById(R.id.descriptiontext); + EditText price = findViewById(R.id.pricetext); + Spinner category = findViewById(R.id.spinner); + Spinner size = findViewById(R.id.sizespinner); + EditText color = findViewById(R.id.colortext); + + String setname = name.getText().toString(); + String setdescription = description.getText().toString(); + String setprice = price.getText().toString(); + String setcategory = category.getSelectedItem().toString(); + String setsize = size.getSelectedItem().toString(); + String setcolor = color.getText().toString(); + Log.i("category", setcategory ); + + Intent intent = new Intent(Admin.this,MainActivity.class); + startActivity(intent); + + + + Product product = new Product.Builder() + .title(setname) + .description(setdescription) + .price(setprice) + .size(setsize) + .color(setcolor) + .image("") + .categoryId(setcategory) + .build(); + + Amplify.API.mutate( + ModelMutation.create(product), + response -> Log.i("MyAmplifyApp", "Added Todo with id: " + response.getData().getId()), + error -> Log.e("MyAmplifyApp", "Create failed", error) + ); + }); + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/thrifty/Belts.java b/app/src/main/java/com/example/thrifty/Belts.java index 89b9c36..a0f8910 100644 --- a/app/src/main/java/com/example/thrifty/Belts.java +++ b/app/src/main/java/com/example/thrifty/Belts.java @@ -1,65 +1,65 @@ -package com.example.thrifty; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; -import android.os.Message; -import android.util.Log; - -import com.amplifyframework.AmplifyException; -import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; -import com.amplifyframework.api.aws.AWSApiPlugin; -import com.amplifyframework.api.graphql.model.ModelQuery; -import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; -import com.amplifyframework.core.Amplify; -import com.amplifyframework.datastore.AWSDataStorePlugin; -import com.amplifyframework.datastore.generated.model.Product; -import com.amplifyframework.storage.s3.AWSS3StoragePlugin; -import com.example.thrifty.adapters.BeltsAdapter; -import com.example.thrifty.adapters.KidsClothesAdapter; -import com.example.thrifty.adapters.WatchesAdapter; - -import java.util.ArrayList; -import java.util.List; - -public class Belts extends AppCompatActivity { - - private List categorizedProducts = new ArrayList<>(); - RecyclerView categorizedRecView; - BeltsAdapter beltsAdapter; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_belts); - - categorizedRecView = findViewById(R.id.categorizedRecView); - categorizedRecView.setAdapter(beltsAdapter); - categorizedRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(),RecyclerView.HORIZONTAL,false)); - - categorizedRecView.setAdapter(new BeltsAdapter(categorizedProducts,this)); - Handler categorizedHandler = new Handler(Looper.myLooper(), new Handler.Callback() { - @Override - public boolean handleMessage(@NonNull Message msg) { - categorizedRecView.getAdapter().notifyDataSetChanged(); - return false; - } - }); - Amplify.API.query( - ModelQuery.list(Product.class,Product.CATEGORY_ID.eq("belts")), - response -> { - for (Product product : response.getData()) { - categorizedProducts.add(product); - } - categorizedHandler.sendEmptyMessage(1); - }, error -> Log.e("MyAmplifyApp", "Query failure", error) - ); - - } - +package com.example.thrifty; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.util.Log; + +import com.amplifyframework.AmplifyException; +import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; +import com.amplifyframework.api.aws.AWSApiPlugin; +import com.amplifyframework.api.graphql.model.ModelQuery; +import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; +import com.amplifyframework.core.Amplify; +import com.amplifyframework.datastore.AWSDataStorePlugin; +import com.amplifyframework.datastore.generated.model.Product; +import com.amplifyframework.storage.s3.AWSS3StoragePlugin; +import com.example.thrifty.adapters.BeltsAdapter; +import com.example.thrifty.adapters.KidsClothesAdapter; +import com.example.thrifty.adapters.WatchesAdapter; + +import java.util.ArrayList; +import java.util.List; + +public class Belts extends AppCompatActivity { + + private List categorizedProducts = new ArrayList<>(); + RecyclerView categorizedRecView; + BeltsAdapter beltsAdapter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_belts); + + categorizedRecView = findViewById(R.id.categorizedRecView); + categorizedRecView.setAdapter(beltsAdapter); + categorizedRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(),RecyclerView.HORIZONTAL,false)); + + categorizedRecView.setAdapter(new BeltsAdapter(categorizedProducts,this)); + Handler categorizedHandler = new Handler(Looper.myLooper(), new Handler.Callback() { + @Override + public boolean handleMessage(@NonNull Message msg) { + categorizedRecView.getAdapter().notifyDataSetChanged(); + return false; + } + }); + Amplify.API.query( + ModelQuery.list(Product.class,Product.CATEGORY_ID.eq("belts")), + response -> { + for (Product product : response.getData()) { + categorizedProducts.add(product); + } + categorizedHandler.sendEmptyMessage(1); + }, error -> Log.e("MyAmplifyApp", "Query failure", error) + ); + + } + } \ No newline at end of file diff --git a/app/src/main/java/com/example/thrifty/Categories.java b/app/src/main/java/com/example/thrifty/Categories.java index f77fbb4..bd719e1 100644 --- a/app/src/main/java/com/example/thrifty/Categories.java +++ b/app/src/main/java/com/example/thrifty/Categories.java @@ -1,104 +1,104 @@ -package com.example.thrifty; - -import androidx.appcompat.app.AppCompatActivity; -import androidx.recyclerview.widget.RecyclerView; - -import android.content.Intent; -import android.os.Bundle; -import android.widget.Button; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.Toolbar; - -import com.google.android.material.bottomnavigation.BottomNavigationItemView; -import com.google.android.material.bottomnavigation.BottomNavigationView; - -public class Categories extends AppCompatActivity { - - Button btnWomen, btnMen, btnKids, btnWatches, btnBelts, btnAccessories; - - private Toolbar toolbar; - private EditText searchBar; - private ImageView btnSearch; - private BottomNavigationView bottomNavigationView; - private RecyclerView recyclerView; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_categories); - - initViews(); - bottomNav(); - - btnWomen = findViewById(R.id.btnWomen); - btnMen = findViewById(R.id.btnMen); - btnKids = findViewById(R.id.btnKids); - btnWatches = findViewById(R.id.btnWatches); - btnBelts = findViewById(R.id.btnBelts); - btnAccessories = findViewById(R.id.btnAccessories); - - btnWomen.setOnClickListener(view ->{ - Intent intent = new Intent(this, WomenClothes.class); - startActivity(intent); - }); - btnMen.setOnClickListener(view ->{ - Intent intent = new Intent(this, MenClothes.class); - startActivity(intent); - }); - btnKids.setOnClickListener(view ->{ - Intent intent = new Intent(this, KidsClothes.class); - startActivity(intent); - }); - btnWatches.setOnClickListener(view ->{ - Intent intent = new Intent(this, Watches.class); - startActivity(intent); - }); - btnBelts.setOnClickListener(view ->{ - Intent intent = new Intent(this, Belts.class); - startActivity(intent); - }); - btnAccessories.setOnClickListener(view ->{ - Intent intent = new Intent(this, Accessories.class); - startActivity(intent); - }); - - } - public void bottomNav(){ - BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavigationView); - bottomNavigationView.setSelectedItemId(R.id.search); - BottomNavigationItemView homeNav = findViewById(R.id.homeNav); - BottomNavigationItemView search = findViewById(R.id.search); - BottomNavigationItemView profile = findViewById(R.id.profile); -// BottomNavigationItemView cart = findViewById(R.id.cart); -// BottomNavigationItemView wishlist = findViewById(R.id.wishlist); - - search.setOnClickListener(view -> { - Intent intent = new Intent(getApplicationContext(), Categories.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - }); - - homeNav.setOnClickListener(view -> { - Intent intent = new Intent(getApplicationContext(), MainActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - }); - - profile.setOnClickListener(view -> { - Intent intent = new Intent(getApplicationContext(), Profile.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - }); - - } - - private void initViews() { - toolbar = findViewById(R.id.toolbar); - searchBar = findViewById(R.id.searchBox); - btnSearch = findViewById(R.id.btnSearch); - bottomNavigationView = findViewById(R.id.bottomNavigationView); - recyclerView = findViewById(R.id.recViewSearchResults); - } - +package com.example.thrifty; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.RecyclerView; + +import android.content.Intent; +import android.os.Bundle; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.Toolbar; + +import com.google.android.material.bottomnavigation.BottomNavigationItemView; +import com.google.android.material.bottomnavigation.BottomNavigationView; + +public class Categories extends AppCompatActivity { + + Button btnWomen, btnMen, btnKids, btnWatches, btnBelts, btnAccessories; + + private Toolbar toolbar; + private EditText searchBar; + private ImageView btnSearch; + private BottomNavigationView bottomNavigationView; + private RecyclerView recyclerView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_categories); + + initViews(); + bottomNav(); + + btnWomen = findViewById(R.id.btnWomen); + btnMen = findViewById(R.id.btnMen); + btnKids = findViewById(R.id.btnKids); + btnWatches = findViewById(R.id.btnWatches); + btnBelts = findViewById(R.id.btnBelts); + btnAccessories = findViewById(R.id.btnAccessories); + + btnWomen.setOnClickListener(view ->{ + Intent intent = new Intent(this, WomenClothes.class); + startActivity(intent); + }); + btnMen.setOnClickListener(view ->{ + Intent intent = new Intent(this, MenClothes.class); + startActivity(intent); + }); + btnKids.setOnClickListener(view ->{ + Intent intent = new Intent(this, KidsClothes.class); + startActivity(intent); + }); + btnWatches.setOnClickListener(view ->{ + Intent intent = new Intent(this, Watches.class); + startActivity(intent); + }); + btnBelts.setOnClickListener(view ->{ + Intent intent = new Intent(this, Belts.class); + startActivity(intent); + }); + btnAccessories.setOnClickListener(view ->{ + Intent intent = new Intent(this, Accessories.class); + startActivity(intent); + }); + + } + public void bottomNav(){ + BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavigationView); + bottomNavigationView.setSelectedItemId(R.id.search); + BottomNavigationItemView homeNav = findViewById(R.id.homeNav); + BottomNavigationItemView search = findViewById(R.id.search); + BottomNavigationItemView profile = findViewById(R.id.profile); +// BottomNavigationItemView cart = findViewById(R.id.cart); +// BottomNavigationItemView wishlist = findViewById(R.id.wishlist); + + search.setOnClickListener(view -> { + Intent intent = new Intent(getApplicationContext(), Categories.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + }); + + homeNav.setOnClickListener(view -> { + Intent intent = new Intent(getApplicationContext(), MainActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + }); + + profile.setOnClickListener(view -> { + Intent intent = new Intent(getApplicationContext(), Profile.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + }); + + } + + private void initViews() { + toolbar = findViewById(R.id.toolbar); + searchBar = findViewById(R.id.searchBox); + btnSearch = findViewById(R.id.btnSearch); + bottomNavigationView = findViewById(R.id.bottomNavigationView); + recyclerView = findViewById(R.id.recViewSearchResults); + } + } \ No newline at end of file diff --git a/app/src/main/java/com/example/thrifty/ConfirmationPage.java b/app/src/main/java/com/example/thrifty/ConfirmationPage.java index 79de0d6..628cd91 100644 --- a/app/src/main/java/com/example/thrifty/ConfirmationPage.java +++ b/app/src/main/java/com/example/thrifty/ConfirmationPage.java @@ -1,75 +1,75 @@ -package com.example.thrifty; - -import androidx.appcompat.app.AppCompatActivity; - -import android.content.Intent; -import android.os.Bundle; -import android.util.Log; -import android.view.View; -import android.widget.Button; -import android.widget.EditText; -import android.widget.Toolbar; - -import com.amplifyframework.AmplifyException; -import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; -import com.amplifyframework.api.aws.AWSApiPlugin; -import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; -import com.amplifyframework.core.Amplify; -import com.amplifyframework.datastore.AWSDataStorePlugin; -import com.amplifyframework.storage.s3.AWSS3StoragePlugin; - -public class ConfirmationPage extends AppCompatActivity { - - public static final String TAG = "ConfirmationCode"; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_confirmation_page); - - EditText confirmationText= findViewById(R.id.editTextTextPassword3); - EditText confirmEmail = findViewById(R.id.editTextTextPersonName7); - Button btnConfirm = findViewById(R.id.button5); - - - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - toolbar.setNavigationIcon(R.drawable.ic_baseline_arrow_back_ios_new_24); - - toolbar.setNavigationOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - - Intent intent = new Intent(ConfirmationPage.this, Signup.class); - startActivity(intent); - } - }); - - - try { - Amplify.addPlugin(new AWSPinpointAnalyticsPlugin(getApplication())); - Amplify.addPlugin(new AWSS3StoragePlugin()); - Amplify.addPlugin(new AWSCognitoAuthPlugin()); - Amplify.addPlugin(new AWSDataStorePlugin()); - Amplify.addPlugin(new AWSApiPlugin()); - Amplify.configure(getApplicationContext()); - Log.i("MyAmplifyApp", "Initialized Amplify"); - } catch (AmplifyException error) { - Log.e("MyAmplifyApp", "Could not initialize Amplify", error); - } - - - btnConfirm.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Amplify.Auth.confirmSignUp( - confirmEmail.getText().toString(), - confirmationText.getText().toString(), - result -> Log.i("AuthQuickstart", result.isSignUpComplete() ? "Confirm signUp succeeded" : "Confirm sign up not complete"), - error -> Log.e("AuthQuickstart", error.toString()) - ); - - Intent intent = new Intent(ConfirmationPage.this,MainActivity.class); - startActivity(intent); - } - }); - } +package com.example.thrifty; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toolbar; + +import com.amplifyframework.AmplifyException; +import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; +import com.amplifyframework.api.aws.AWSApiPlugin; +import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; +import com.amplifyframework.core.Amplify; +import com.amplifyframework.datastore.AWSDataStorePlugin; +import com.amplifyframework.storage.s3.AWSS3StoragePlugin; + +public class ConfirmationPage extends AppCompatActivity { + + public static final String TAG = "ConfirmationCode"; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_confirmation_page); + + EditText confirmationText= findViewById(R.id.editTextTextPassword3); + EditText confirmEmail = findViewById(R.id.editTextTextPersonName7); + Button btnConfirm = findViewById(R.id.button5); + + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + toolbar.setNavigationIcon(R.drawable.ic_baseline_arrow_back_ios_new_24); + + toolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + Intent intent = new Intent(ConfirmationPage.this, Signup.class); + startActivity(intent); + } + }); + + + try { + Amplify.addPlugin(new AWSPinpointAnalyticsPlugin(getApplication())); + Amplify.addPlugin(new AWSS3StoragePlugin()); + Amplify.addPlugin(new AWSCognitoAuthPlugin()); + Amplify.addPlugin(new AWSDataStorePlugin()); + Amplify.addPlugin(new AWSApiPlugin()); + Amplify.configure(getApplicationContext()); + Log.i("MyAmplifyApp", "Initialized Amplify"); + } catch (AmplifyException error) { + Log.e("MyAmplifyApp", "Could not initialize Amplify", error); + } + + + btnConfirm.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Amplify.Auth.confirmSignUp( + confirmEmail.getText().toString(), + confirmationText.getText().toString(), + result -> Log.i("AuthQuickstart", result.isSignUpComplete() ? "Confirm signUp succeeded" : "Confirm sign up not complete"), + error -> Log.e("AuthQuickstart", error.toString()) + ); + + Intent intent = new Intent(ConfirmationPage.this,MainActivity.class); + startActivity(intent); + } + }); + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/thrifty/KidsClothes.java b/app/src/main/java/com/example/thrifty/KidsClothes.java index 3e51c65..2a6ff69 100644 --- a/app/src/main/java/com/example/thrifty/KidsClothes.java +++ b/app/src/main/java/com/example/thrifty/KidsClothes.java @@ -1,62 +1,62 @@ -package com.example.thrifty; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; -import android.os.Message; -import android.util.Log; - -import com.amplifyframework.AmplifyException; -import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; -import com.amplifyframework.api.aws.AWSApiPlugin; -import com.amplifyframework.api.graphql.model.ModelQuery; -import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; -import com.amplifyframework.core.Amplify; -import com.amplifyframework.datastore.AWSDataStorePlugin; -import com.amplifyframework.datastore.generated.model.Product; -import com.amplifyframework.storage.s3.AWSS3StoragePlugin; -import com.example.thrifty.adapters.KidsClothesAdapter; - -import java.util.ArrayList; -import java.util.List; - -public class KidsClothes extends AppCompatActivity { - - private List categorizedProducts = new ArrayList<>(); - RecyclerView categorizedRecView; - KidsClothesAdapter kidsClothesAdapter; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_kids_clothes); - - categorizedRecView = findViewById(R.id.categorizedRecView); - categorizedRecView.setAdapter(kidsClothesAdapter); - categorizedRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(),RecyclerView.HORIZONTAL,false)); - - categorizedRecView.setAdapter(new KidsClothesAdapter(categorizedProducts,this)); - Handler categorizedHandler = new Handler(Looper.myLooper(), new Handler.Callback() { - @Override - public boolean handleMessage(@NonNull Message msg) { - categorizedRecView.getAdapter().notifyDataSetChanged(); - return false; - } - }); - Amplify.API.query( - ModelQuery.list(Product.class,Product.CATEGORY_ID.eq("kids_clothes")), - response -> { - for (Product product : response.getData()) { - categorizedProducts.add(product); - } - categorizedHandler.sendEmptyMessage(1); - }, error -> Log.e("MyAmplifyApp", "Query failure", error) - ); - - } +package com.example.thrifty; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.util.Log; + +import com.amplifyframework.AmplifyException; +import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; +import com.amplifyframework.api.aws.AWSApiPlugin; +import com.amplifyframework.api.graphql.model.ModelQuery; +import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; +import com.amplifyframework.core.Amplify; +import com.amplifyframework.datastore.AWSDataStorePlugin; +import com.amplifyframework.datastore.generated.model.Product; +import com.amplifyframework.storage.s3.AWSS3StoragePlugin; +import com.example.thrifty.adapters.KidsClothesAdapter; + +import java.util.ArrayList; +import java.util.List; + +public class KidsClothes extends AppCompatActivity { + + private List categorizedProducts = new ArrayList<>(); + RecyclerView categorizedRecView; + KidsClothesAdapter kidsClothesAdapter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_kids_clothes); + + categorizedRecView = findViewById(R.id.categorizedRecView); + categorizedRecView.setAdapter(kidsClothesAdapter); + categorizedRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(),RecyclerView.HORIZONTAL,false)); + + categorizedRecView.setAdapter(new KidsClothesAdapter(categorizedProducts,this)); + Handler categorizedHandler = new Handler(Looper.myLooper(), new Handler.Callback() { + @Override + public boolean handleMessage(@NonNull Message msg) { + categorizedRecView.getAdapter().notifyDataSetChanged(); + return false; + } + }); + Amplify.API.query( + ModelQuery.list(Product.class,Product.CATEGORY_ID.eq("kids_clothes")), + response -> { + for (Product product : response.getData()) { + categorizedProducts.add(product); + } + categorizedHandler.sendEmptyMessage(1); + }, error -> Log.e("MyAmplifyApp", "Query failure", error) + ); + + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/thrifty/MainActivity.java b/app/src/main/java/com/example/thrifty/MainActivity.java index 391d655..350fd72 100644 --- a/app/src/main/java/com/example/thrifty/MainActivity.java +++ b/app/src/main/java/com/example/thrifty/MainActivity.java @@ -1,274 +1,274 @@ -package com.example.thrifty; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import android.annotation.SuppressLint; -import android.app.NotificationChannel; -import android.app.NotificationManager; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.os.Build; -import android.os.Bundle; - -import android.os.Handler; -import android.os.Looper; -import android.os.Message; -import android.preference.PreferenceManager; - -import android.view.View; - -import android.util.Log; -import android.widget.Button; - -import com.amazonaws.mobile.client.AWSMobileClient; -import com.amazonaws.mobile.client.Callback; -import com.amazonaws.mobile.client.UserStateDetails; -import com.amazonaws.mobile.config.AWSConfiguration; -import com.amazonaws.mobileconnectors.pinpoint.PinpointConfiguration; -import com.amazonaws.mobileconnectors.pinpoint.PinpointManager; -import com.amazonaws.mobileconnectors.pinpoint.targeting.TargetingClient; -import com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile; -import com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileUser; -import com.amplifyframework.AmplifyException; -import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; -import com.amplifyframework.api.aws.AWSApiPlugin; -import com.amplifyframework.api.graphql.model.ModelQuery; -import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; -import com.amplifyframework.core.Amplify; -import com.amplifyframework.datastore.AWSDataStorePlugin; -import com.amplifyframework.datastore.generated.model.Product; -import com.amplifyframework.storage.s3.AWSS3StoragePlugin; -import com.example.thrifty.adapters.NewItemsAdapter; -import com.google.android.gms.tasks.OnCompleteListener; -import com.google.android.material.bottomnavigation.BottomNavigationItemView; -import com.google.android.material.bottomnavigation.BottomNavigationView; -import com.google.firebase.messaging.FirebaseMessaging; - -import java.util.ArrayList; -import java.util.List; - - -public class MainActivity extends AppCompatActivity { - - private static PinpointManager pinpointManager; - private static final String TAG = "MainActivity"; - - private final List newProducts = new ArrayList<>(); - private final List popularProducts = new ArrayList<>(); - private final List suggestProducts = new ArrayList<>(); - private final List categorizedProducts = new ArrayList<>(); - - RecyclerView newItemRecView, suggestedRecView, popularRecView; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - configure(); - bottomNav(); - initRecyclerViews(); - getPinpointManager(getApplicationContext()); - assignUserIdToEndpoint(); - createNotificationChannel(); - - findViewById(R.id.admin).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Intent intent = new Intent(MainActivity.this, Admin.class); - startActivity(intent); - } - }); - - } - - private void configure() { - try { - Amplify.addPlugin(new AWSPinpointAnalyticsPlugin(getApplication())); - Amplify.addPlugin(new AWSS3StoragePlugin()); - Amplify.addPlugin(new AWSCognitoAuthPlugin()); - Amplify.addPlugin(new AWSApiPlugin()); - Amplify.addPlugin(new AWSDataStorePlugin()); - Amplify.addPlugin(new AWSApiPlugin()); - Amplify.configure(getApplicationContext()); - Log.i("MyAmplifyApp", "Initialized Amplify"); - } catch (AmplifyException error) { - Log.e("MyAmplifyApp", "Could not initialize Amplify", error); - } - } - - public void bottomNav(){ - BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavigationView); - bottomNavigationView.setSelectedItemId(R.id.homeNav); - BottomNavigationItemView homeNav = findViewById(R.id.homeNav); - BottomNavigationItemView search = findViewById(R.id.search); -// BottomNavigationItemView cart = findViewById(R.id.cart); -// BottomNavigationItemView wishlist = findViewById(R.id.wishlist); - BottomNavigationItemView profile = findViewById(R.id.profile); - - search.setOnClickListener(view -> { - Intent intent = new Intent(getApplicationContext(), Categories.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - }); - - homeNav.setOnClickListener(view -> { - Intent intent = new Intent(getApplicationContext(), MainActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - }); - - profile.setOnClickListener(view -> { - Intent intent = new Intent(getApplicationContext(), Profile.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - }); - - } - - private void initRecyclerViews(){ - newItemRecView = findViewById(R.id.newItemsRecView); - suggestedRecView = findViewById(R.id.suggestedRecView); - popularRecView = findViewById(R.id.popularRecView); - - newItemRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(),RecyclerView.HORIZONTAL,false)); - suggestedRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(), RecyclerView.HORIZONTAL,false)); - popularRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(),RecyclerView.HORIZONTAL,false)); - - newItemRecView.setAdapter(new NewItemsAdapter(newProducts , MainActivity.this)); - Handler handler = new Handler(Looper.myLooper(), new Handler.Callback() { - @SuppressLint("NotifyDataSetChanged") - @Override - public boolean handleMessage(@NonNull Message message) { - newItemRecView.getAdapter().notifyDataSetChanged(); - return false; - } - }); - - - popularRecView.setAdapter(new NewItemsAdapter(popularProducts , MainActivity.this)); - Handler popularHandler = new Handler(Looper.myLooper(), new Handler.Callback() { - @SuppressLint("NotifyDataSetChanged") - @Override - public boolean handleMessage(@NonNull Message message) { - popularRecView.getAdapter().notifyDataSetChanged(); - return false; - } - }); - - suggestedRecView.setAdapter(new NewItemsAdapter(suggestProducts , MainActivity.this)); - Handler suggestHandler = new Handler(Looper.myLooper(), new Handler.Callback() { - @SuppressLint("NotifyDataSetChanged") - @Override - public boolean handleMessage(@NonNull Message message) { - suggestedRecView.getAdapter().notifyDataSetChanged(); - return false; - } - }); - - Amplify.API.query( - ModelQuery.list(Product.class), - response -> { - for (Product product : response.getData()) { - newProducts.add(product); - } - handler.sendEmptyMessage(1); - }, error -> Log.e("MyAmplifyApp", "Query failure", error) - ); - - Amplify.API.query( - ModelQuery.list(Product.class), - response -> { - for (Product product : response.getData()) { - popularProducts.add(product); - } - popularHandler.sendEmptyMessage(1); - }, error -> Log.e("MyAmplifyApp", "Query failure", error) - ); - - Amplify.API.query( - ModelQuery.list(Product.class), - response -> { - for (Product product : response.getData()) { - suggestProducts.add(product); - } - suggestHandler.sendEmptyMessage(1); - }, error -> Log.e("MyAmplifyApp", "Query failure", error) - ); - } - - @Override - protected void onResume() { - super.onResume(); - Button stopButton = findViewById(R.id.admin); - stopButton.setVisibility(View.GONE); - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainActivity.this); - String email1 = sharedPreferences.getString("email", "Your email"); - if (email1.equals("aboud.coding@gmail.com")){ - stopButton.setVisibility(View.VISIBLE); - } - } - public static PinpointManager getPinpointManager(Context applicationContext) { - if (pinpointManager == null) { - final AWSConfiguration awsConfig = new AWSConfiguration(applicationContext); - AWSMobileClient.getInstance().initialize(applicationContext, awsConfig, new Callback() { - @Override - public void onResult(UserStateDetails userStateDetails) { - Log.i("INIT", userStateDetails.getUserState().toString()); - } - - @Override - public void onError(Exception e) { - Log.e("INIT", "Initialization error.", e); - } - }); - PinpointConfiguration pinpointConfig = new PinpointConfiguration( - applicationContext, - AWSMobileClient.getInstance(), - awsConfig); - - pinpointManager = new PinpointManager(pinpointConfig); - - FirebaseMessaging.getInstance().getToken() - .addOnCompleteListener(new OnCompleteListener() { - @Override - public void onComplete(@NonNull com.google.android.gms.tasks.Task task) { - if (!task.isSuccessful()) { - Log.w("TAG", "Fetching FCM registration token failed", task.getException()); - return; - } - final String token = task.getResult(); - Log.d("TAG", "Registering push notifications token: " + token); - pinpointManager.getNotificationClient().registerDeviceToken(token); - } - }); - } - return pinpointManager; - } - private void createNotificationChannel() { - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - CharSequence name = getString(R.string.channel_name); - String description = getString(R.string.channel_description); - int importance = NotificationManager.IMPORTANCE_DEFAULT; - NotificationChannel channel = new NotificationChannel(PushListenerService.CHANNEL_ID, name, importance); - channel.setDescription(description); - - NotificationManager notificationManager = getSystemService(NotificationManager.class); - notificationManager.createNotificationChannel(channel); - } - } - public void assignUserIdToEndpoint() { - TargetingClient targetingClient = pinpointManager.getTargetingClient(); - EndpointProfile endpointProfile = targetingClient.currentEndpoint(); - EndpointProfileUser endpointProfileUser = new EndpointProfileUser(); - endpointProfileUser.setUserId("UserIdValue"); - endpointProfile.setUser(endpointProfileUser); - targetingClient.updateEndpointProfile(endpointProfile); - Log.d(TAG, "Assigned user ID " + endpointProfileUser.getUserId() + - " to endpoint " + endpointProfile.getEndpointId()); - } +package com.example.thrifty; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import android.annotation.SuppressLint; +import android.app.NotificationChannel; +import android.app.NotificationManager; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Build; +import android.os.Bundle; + +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.preference.PreferenceManager; + +import android.view.View; + +import android.util.Log; +import android.widget.Button; + +import com.amazonaws.mobile.client.AWSMobileClient; +import com.amazonaws.mobile.client.Callback; +import com.amazonaws.mobile.client.UserStateDetails; +import com.amazonaws.mobile.config.AWSConfiguration; +import com.amazonaws.mobileconnectors.pinpoint.PinpointConfiguration; +import com.amazonaws.mobileconnectors.pinpoint.PinpointManager; +import com.amazonaws.mobileconnectors.pinpoint.targeting.TargetingClient; +import com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile; +import com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileUser; +import com.amplifyframework.AmplifyException; +import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; +import com.amplifyframework.api.aws.AWSApiPlugin; +import com.amplifyframework.api.graphql.model.ModelQuery; +import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; +import com.amplifyframework.core.Amplify; +import com.amplifyframework.datastore.AWSDataStorePlugin; +import com.amplifyframework.datastore.generated.model.Product; +import com.amplifyframework.storage.s3.AWSS3StoragePlugin; +import com.example.thrifty.adapters.NewItemsAdapter; +import com.google.android.gms.tasks.OnCompleteListener; +import com.google.android.material.bottomnavigation.BottomNavigationItemView; +import com.google.android.material.bottomnavigation.BottomNavigationView; +import com.google.firebase.messaging.FirebaseMessaging; + +import java.util.ArrayList; +import java.util.List; + + +public class MainActivity extends AppCompatActivity { + + private static PinpointManager pinpointManager; + private static final String TAG = "MainActivity"; + + private final List newProducts = new ArrayList<>(); + private final List popularProducts = new ArrayList<>(); + private final List suggestProducts = new ArrayList<>(); + private final List categorizedProducts = new ArrayList<>(); + + RecyclerView newItemRecView, suggestedRecView, popularRecView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + configure(); + bottomNav(); + initRecyclerViews(); + getPinpointManager(getApplicationContext()); + assignUserIdToEndpoint(); + createNotificationChannel(); + + findViewById(R.id.admin).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(MainActivity.this, Admin.class); + startActivity(intent); + } + }); + + } + + private void configure() { + try { + Amplify.addPlugin(new AWSPinpointAnalyticsPlugin(getApplication())); + Amplify.addPlugin(new AWSS3StoragePlugin()); + Amplify.addPlugin(new AWSCognitoAuthPlugin()); + Amplify.addPlugin(new AWSApiPlugin()); + Amplify.addPlugin(new AWSDataStorePlugin()); + Amplify.addPlugin(new AWSApiPlugin()); + Amplify.configure(getApplicationContext()); + Log.i("MyAmplifyApp", "Initialized Amplify"); + } catch (AmplifyException error) { + Log.e("MyAmplifyApp", "Could not initialize Amplify", error); + } + } + + public void bottomNav(){ + BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavigationView); + bottomNavigationView.setSelectedItemId(R.id.homeNav); + BottomNavigationItemView homeNav = findViewById(R.id.homeNav); + BottomNavigationItemView search = findViewById(R.id.search); +// BottomNavigationItemView cart = findViewById(R.id.cart); +// BottomNavigationItemView wishlist = findViewById(R.id.wishlist); + BottomNavigationItemView profile = findViewById(R.id.profile); + + search.setOnClickListener(view -> { + Intent intent = new Intent(getApplicationContext(), Categories.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + }); + + homeNav.setOnClickListener(view -> { + Intent intent = new Intent(getApplicationContext(), MainActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + }); + + profile.setOnClickListener(view -> { + Intent intent = new Intent(getApplicationContext(), Profile.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + }); + + } + + private void initRecyclerViews(){ + newItemRecView = findViewById(R.id.newItemsRecView); + suggestedRecView = findViewById(R.id.suggestedRecView); + popularRecView = findViewById(R.id.popularRecView); + + newItemRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(),RecyclerView.HORIZONTAL,false)); + suggestedRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(), RecyclerView.HORIZONTAL,false)); + popularRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(),RecyclerView.HORIZONTAL,false)); + + newItemRecView.setAdapter(new NewItemsAdapter(newProducts , MainActivity.this)); + Handler handler = new Handler(Looper.myLooper(), new Handler.Callback() { + @SuppressLint("NotifyDataSetChanged") + @Override + public boolean handleMessage(@NonNull Message message) { + newItemRecView.getAdapter().notifyDataSetChanged(); + return false; + } + }); + + + popularRecView.setAdapter(new NewItemsAdapter(popularProducts , MainActivity.this)); + Handler popularHandler = new Handler(Looper.myLooper(), new Handler.Callback() { + @SuppressLint("NotifyDataSetChanged") + @Override + public boolean handleMessage(@NonNull Message message) { + popularRecView.getAdapter().notifyDataSetChanged(); + return false; + } + }); + + suggestedRecView.setAdapter(new NewItemsAdapter(suggestProducts , MainActivity.this)); + Handler suggestHandler = new Handler(Looper.myLooper(), new Handler.Callback() { + @SuppressLint("NotifyDataSetChanged") + @Override + public boolean handleMessage(@NonNull Message message) { + suggestedRecView.getAdapter().notifyDataSetChanged(); + return false; + } + }); + + Amplify.API.query( + ModelQuery.list(Product.class), + response -> { + for (Product product : response.getData()) { + newProducts.add(product); + } + handler.sendEmptyMessage(1); + }, error -> Log.e("MyAmplifyApp", "Query failure", error) + ); + + Amplify.API.query( + ModelQuery.list(Product.class), + response -> { + for (Product product : response.getData()) { + popularProducts.add(product); + } + popularHandler.sendEmptyMessage(1); + }, error -> Log.e("MyAmplifyApp", "Query failure", error) + ); + + Amplify.API.query( + ModelQuery.list(Product.class), + response -> { + for (Product product : response.getData()) { + suggestProducts.add(product); + } + suggestHandler.sendEmptyMessage(1); + }, error -> Log.e("MyAmplifyApp", "Query failure", error) + ); + } + + @Override + protected void onResume() { + super.onResume(); + Button stopButton = findViewById(R.id.admin); + stopButton.setVisibility(View.GONE); + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainActivity.this); + String email1 = sharedPreferences.getString("email", "Your email"); + if (email1.equals("aboud.coding@gmail.com")){ + stopButton.setVisibility(View.VISIBLE); + } + } + public static PinpointManager getPinpointManager(Context applicationContext) { + if (pinpointManager == null) { + final AWSConfiguration awsConfig = new AWSConfiguration(applicationContext); + AWSMobileClient.getInstance().initialize(applicationContext, awsConfig, new Callback() { + @Override + public void onResult(UserStateDetails userStateDetails) { + Log.i("INIT", userStateDetails.getUserState().toString()); + } + + @Override + public void onError(Exception e) { + Log.e("INIT", "Initialization error.", e); + } + }); + PinpointConfiguration pinpointConfig = new PinpointConfiguration( + applicationContext, + AWSMobileClient.getInstance(), + awsConfig); + + pinpointManager = new PinpointManager(pinpointConfig); + + FirebaseMessaging.getInstance().getToken() + .addOnCompleteListener(new OnCompleteListener() { + @Override + public void onComplete(@NonNull com.google.android.gms.tasks.Task task) { + if (!task.isSuccessful()) { + Log.w("TAG", "Fetching FCM registration token failed", task.getException()); + return; + } + final String token = task.getResult(); + Log.d("TAG", "Registering push notifications token: " + token); + pinpointManager.getNotificationClient().registerDeviceToken(token); + } + }); + } + return pinpointManager; + } + private void createNotificationChannel() { + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + CharSequence name = getString(R.string.channel_name); + String description = getString(R.string.channel_description); + int importance = NotificationManager.IMPORTANCE_DEFAULT; + NotificationChannel channel = new NotificationChannel(PushListenerService.CHANNEL_ID, name, importance); + channel.setDescription(description); + + NotificationManager notificationManager = getSystemService(NotificationManager.class); + notificationManager.createNotificationChannel(channel); + } + } + public void assignUserIdToEndpoint() { + TargetingClient targetingClient = pinpointManager.getTargetingClient(); + EndpointProfile endpointProfile = targetingClient.currentEndpoint(); + EndpointProfileUser endpointProfileUser = new EndpointProfileUser(); + endpointProfileUser.setUserId("UserIdValue"); + endpointProfile.setUser(endpointProfileUser); + targetingClient.updateEndpointProfile(endpointProfile); + Log.d(TAG, "Assigned user ID " + endpointProfileUser.getUserId() + + " to endpoint " + endpointProfile.getEndpointId()); + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/thrifty/OrderTracking.java b/app/src/main/java/com/example/thrifty/OrderTracking.java new file mode 100644 index 0000000..2c1014c --- /dev/null +++ b/app/src/main/java/com/example/thrifty/OrderTracking.java @@ -0,0 +1,45 @@ +package com.example.thrifty; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; + +public class OrderTracking extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_order_tracking); + } + public void OrderPlaced(View view) { +// startActivity(new Intent(OrderTracking.this,TrackActivity.class)); + String orderStatus="0"; + Intent intent=new Intent(OrderTracking.this,TrackActivity.class); + intent.putExtra("orderStatus",orderStatus); + startActivity(intent); + } + + public void OrderConfirmed(View view) { + String orderStatus="1"; + Intent intent=new Intent(OrderTracking.this,TrackActivity.class); + intent.putExtra("orderStatus",orderStatus); + startActivity(intent); + } + + public void OrderProcessed(View view) { + String orderStatus="2"; + Intent intent=new Intent(OrderTracking.this,TrackActivity.class); + intent.putExtra("orderStatus",orderStatus); + startActivity(intent); + } + + public void OrderPickup(View view) { + String orderStatus="3"; + Intent intent=new Intent(OrderTracking.this,TrackActivity.class); + intent.putExtra("orderStatus",orderStatus); + startActivity(intent); + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/example/thrifty/ProductView.java b/app/src/main/java/com/example/thrifty/ProductView.java index 3b99aaf..525d2e0 100644 --- a/app/src/main/java/com/example/thrifty/ProductView.java +++ b/app/src/main/java/com/example/thrifty/ProductView.java @@ -1,60 +1,60 @@ -package com.example.thrifty; - -import androidx.appcompat.app.AppCompatActivity; - -import android.content.Intent; -import android.os.Bundle; -import android.util.Log; -import android.view.View; -import android.widget.TextView; -import android.widget.Toolbar; - -import com.amplifyframework.AmplifyException; -import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; -import com.amplifyframework.api.aws.AWSApiPlugin; -import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; -import com.amplifyframework.core.Amplify; -import com.amplifyframework.datastore.AWSDataStorePlugin; -import com.amplifyframework.storage.s3.AWSS3StoragePlugin; - -public class ProductView extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_product_view); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - toolbar.setNavigationIcon(R.drawable.ic_baseline_arrow_back_ios_new_24); - toolbar.setNavigationOnClickListener(v -> { - Intent intent = new Intent(ProductView.this, MainActivity.class); - startActivity(intent); - }); - - try { - Amplify.addPlugin(new AWSApiPlugin()); - Amplify.addPlugin(new AWSPinpointAnalyticsPlugin(getApplication())); - Amplify.addPlugin(new AWSS3StoragePlugin()); - Amplify.addPlugin(new AWSCognitoAuthPlugin()); - Amplify.addPlugin(new AWSDataStorePlugin()); - Amplify.configure(getApplicationContext()); - Log.i("MyAmplifyApp", "Initialized Amplify"); - } catch (AmplifyException error) { - Log.e("MyAmplifyApp", "Could not initialize Amplify", error); - } - - Intent intent = getIntent(); - String title = intent.getStringExtra("Title"); - String price = intent.getStringExtra("price"); - String category = intent.getStringExtra("category"); - - TextView textView = findViewById(R.id.txtTitle); - TextView priceTxt = findViewById(R.id.txtPrice); - TextView categoryTxt = findViewById(R.id.category); - - textView.setText(title); - priceTxt.setText(price); - categoryTxt.setText(category); - - - } +package com.example.thrifty; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.TextView; +import android.widget.Toolbar; + +import com.amplifyframework.AmplifyException; +import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; +import com.amplifyframework.api.aws.AWSApiPlugin; +import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; +import com.amplifyframework.core.Amplify; +import com.amplifyframework.datastore.AWSDataStorePlugin; +import com.amplifyframework.storage.s3.AWSS3StoragePlugin; + +public class ProductView extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_product_view); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + toolbar.setNavigationIcon(R.drawable.ic_baseline_arrow_back_ios_new_24); + toolbar.setNavigationOnClickListener(v -> { + Intent intent = new Intent(ProductView.this, MainActivity.class); + startActivity(intent); + }); + + try { + Amplify.addPlugin(new AWSApiPlugin()); + Amplify.addPlugin(new AWSPinpointAnalyticsPlugin(getApplication())); + Amplify.addPlugin(new AWSS3StoragePlugin()); + Amplify.addPlugin(new AWSCognitoAuthPlugin()); + Amplify.addPlugin(new AWSDataStorePlugin()); + Amplify.configure(getApplicationContext()); + Log.i("MyAmplifyApp", "Initialized Amplify"); + } catch (AmplifyException error) { + Log.e("MyAmplifyApp", "Could not initialize Amplify", error); + } + + Intent intent = getIntent(); + String title = intent.getStringExtra("Title"); + String price = intent.getStringExtra("price"); + String category = intent.getStringExtra("category"); + + TextView textView = findViewById(R.id.txtTitle); + TextView priceTxt = findViewById(R.id.txtPrice); + TextView categoryTxt = findViewById(R.id.category); + + textView.setText(title); + priceTxt.setText(price); + categoryTxt.setText(category); + + + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/thrifty/Profile.java b/app/src/main/java/com/example/thrifty/Profile.java index 9263091..12ff93e 100644 --- a/app/src/main/java/com/example/thrifty/Profile.java +++ b/app/src/main/java/com/example/thrifty/Profile.java @@ -1,118 +1,118 @@ -package com.example.thrifty; - -import androidx.appcompat.app.AppCompatActivity; -import androidx.recyclerview.widget.RecyclerView; - -import android.content.Intent; -import android.content.SharedPreferences; -import android.os.Bundle; -import android.preference.PreferenceManager; -import android.view.View; -import android.widget.Button; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.TextView; -import android.widget.Toolbar; - -import com.google.android.material.bottomnavigation.BottomNavigationItemView; -import com.google.android.material.bottomnavigation.BottomNavigationView; - -public class Profile extends AppCompatActivity { - private static final String TAG = "SearchActivity"; - private Toolbar toolbar; - private EditText searchBar; - private ImageView btnSearch; - private BottomNavigationView bottomNavigationView; - private RecyclerView recyclerView; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_profile); - - initViews(); - bottomNav(); - - - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - toolbar.setNavigationIcon(R.drawable.ic_baseline_arrow_back_ios_new_24); - toolbar.setNavigationOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(Profile.this, MainActivity.class); - startActivity(intent); - } - }); - - ImageView imageView = findViewById(R.id.fav); - imageView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Intent intent = new Intent(Profile.this,MainActivity.class); - startActivity(intent); - } - }); - - } - - - @Override - protected void onResume() { - super.onResume(); - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(Profile.this); - String email1 = sharedPreferences.getString("email", "Your email"); - TextView email = findViewById(R.id.email); - email.setText(email1); - - String name = sharedPreferences.getString("name", "Your email"); - TextView name1 = findViewById(R.id.name); - TextView name2 = findViewById(R.id.username); - name1.setText(name); - name2.setText(name); - - String phone = sharedPreferences.getString("phone", "Your phone number"); - TextView phone1 = findViewById(R.id.phone); - phone1.setText(phone); - - Button stopButton = (Button) findViewById(R.id.admin1); - stopButton.setVisibility(View.GONE); - if (email1.equals("hebaalmomani1998@gmail.com")){ - stopButton.setVisibility(View.VISIBLE); - } - } - - public void bottomNav(){ - BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavigationView); - bottomNavigationView.setSelectedItemId(R.id.profile); - BottomNavigationItemView homeNav = findViewById(R.id.homeNav); - BottomNavigationItemView search = findViewById(R.id.search); -// BottomNavigationItemView cart = findViewById(R.id.cart); -// BottomNavigationItemView wishlist = findViewById(R.id.wishlist); -// BottomNavigationItemView profile = findViewById(R.id.profile); - - search.setOnClickListener(view -> { - Intent intent = new Intent(getApplicationContext(), Categories.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - }); - - homeNav.setOnClickListener(view -> { - Intent intent = new Intent(getApplicationContext(), MainActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - }); - - } - - - private void initViews() { - toolbar = findViewById(R.id.toolbar); - searchBar = findViewById(R.id.searchBox); - btnSearch = findViewById(R.id.btnSearch); - bottomNavigationView = findViewById(R.id.bottomNavigationView); - recyclerView = findViewById(R.id.recViewSearchResults); - } - - - +package com.example.thrifty; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.RecyclerView; + +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toolbar; + +import com.google.android.material.bottomnavigation.BottomNavigationItemView; +import com.google.android.material.bottomnavigation.BottomNavigationView; + +public class Profile extends AppCompatActivity { + private static final String TAG = "SearchActivity"; + private Toolbar toolbar; + private EditText searchBar; + private ImageView btnSearch; + private BottomNavigationView bottomNavigationView; + private RecyclerView recyclerView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_profile); + + initViews(); + bottomNav(); + + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + toolbar.setNavigationIcon(R.drawable.ic_baseline_arrow_back_ios_new_24); + toolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(Profile.this, MainActivity.class); + startActivity(intent); + } + }); + + ImageView imageView = findViewById(R.id.fav); + imageView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(Profile.this,MainActivity.class); + startActivity(intent); + } + }); + + } + + + @Override + protected void onResume() { + super.onResume(); + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(Profile.this); + String email1 = sharedPreferences.getString("email", "Your email"); + TextView email = findViewById(R.id.email); + email.setText(email1); + + String name = sharedPreferences.getString("name", "Your email"); + TextView name1 = findViewById(R.id.name); + TextView name2 = findViewById(R.id.username); + name1.setText(name); + name2.setText(name); + + String phone = sharedPreferences.getString("phone", "Your phone number"); + TextView phone1 = findViewById(R.id.phone); + phone1.setText(phone); + + Button stopButton = (Button) findViewById(R.id.admin1); + stopButton.setVisibility(View.GONE); + if (email1.equals("hebaalmomani1998@gmail.com")){ + stopButton.setVisibility(View.VISIBLE); + } + } + + public void bottomNav(){ + BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavigationView); + bottomNavigationView.setSelectedItemId(R.id.profile); + BottomNavigationItemView homeNav = findViewById(R.id.homeNav); + BottomNavigationItemView search = findViewById(R.id.search); +// BottomNavigationItemView cart = findViewById(R.id.cart); +// BottomNavigationItemView wishlist = findViewById(R.id.wishlist); +// BottomNavigationItemView profile = findViewById(R.id.profile); + + search.setOnClickListener(view -> { + Intent intent = new Intent(getApplicationContext(), Categories.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + }); + + homeNav.setOnClickListener(view -> { + Intent intent = new Intent(getApplicationContext(), MainActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + }); + + } + + + private void initViews() { + toolbar = findViewById(R.id.toolbar); + searchBar = findViewById(R.id.searchBox); + btnSearch = findViewById(R.id.btnSearch); + bottomNavigationView = findViewById(R.id.bottomNavigationView); + recyclerView = findViewById(R.id.recViewSearchResults); + } + + + } \ No newline at end of file diff --git a/app/src/main/java/com/example/thrifty/SearchActivity.java b/app/src/main/java/com/example/thrifty/SearchActivity.java index 6a1f191..8a8a49d 100644 --- a/app/src/main/java/com/example/thrifty/SearchActivity.java +++ b/app/src/main/java/com/example/thrifty/SearchActivity.java @@ -1,69 +1,69 @@ -package com.example.thrifty; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; -import androidx.recyclerview.widget.RecyclerView; - -import android.content.Intent; -import android.os.Bundle; -import android.view.MenuItem; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.Toast; -import android.widget.Toolbar; - -import com.google.android.material.bottomnavigation.BottomNavigationItemView; -import com.google.android.material.bottomnavigation.BottomNavigationView; -import com.google.android.material.navigation.NavigationBarView; - -public class SearchActivity extends AppCompatActivity { - private static final String TAG = "SearchActivity"; - private Toolbar toolbar; - private EditText searchBar; - private ImageView btnSearch; - private BottomNavigationView bottomNavigationView; - private RecyclerView recyclerView; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_search); - initViews(); - bottomNav(); - } - public void bottomNav(){ - BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavigationView); - bottomNavigationView.setSelectedItemId(R.id.search); - BottomNavigationItemView homeNav = findViewById(R.id.homeNav); - BottomNavigationItemView search = findViewById(R.id.search); - BottomNavigationItemView profile = findViewById(R.id.profile); - - search.setOnClickListener(view -> { - Intent intent = new Intent(getApplicationContext(), SearchActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - }); - - homeNav.setOnClickListener(view -> { - Intent intent = new Intent(getApplicationContext(), MainActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - }); - - profile.setOnClickListener(view -> { - Intent intent = new Intent(getApplicationContext(), Profile.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - }); - - } - - - private void initViews() { - toolbar = findViewById(R.id.toolbar); - searchBar = findViewById(R.id.searchBox); - btnSearch = findViewById(R.id.btnSearch); - bottomNavigationView = findViewById(R.id.bottomNavigationView); - recyclerView = findViewById(R.id.recViewSearchResults); - } +package com.example.thrifty; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.RecyclerView; + +import android.content.Intent; +import android.os.Bundle; +import android.view.MenuItem; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.Toast; +import android.widget.Toolbar; + +import com.google.android.material.bottomnavigation.BottomNavigationItemView; +import com.google.android.material.bottomnavigation.BottomNavigationView; +import com.google.android.material.navigation.NavigationBarView; + +public class SearchActivity extends AppCompatActivity { + private static final String TAG = "SearchActivity"; + private Toolbar toolbar; + private EditText searchBar; + private ImageView btnSearch; + private BottomNavigationView bottomNavigationView; + private RecyclerView recyclerView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_search); + initViews(); + bottomNav(); + } + public void bottomNav(){ + BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavigationView); + bottomNavigationView.setSelectedItemId(R.id.search); + BottomNavigationItemView homeNav = findViewById(R.id.homeNav); + BottomNavigationItemView search = findViewById(R.id.search); + BottomNavigationItemView profile = findViewById(R.id.profile); + + search.setOnClickListener(view -> { + Intent intent = new Intent(getApplicationContext(), SearchActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + }); + + homeNav.setOnClickListener(view -> { + Intent intent = new Intent(getApplicationContext(), MainActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + }); + + profile.setOnClickListener(view -> { + Intent intent = new Intent(getApplicationContext(), Profile.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + }); + + } + + + private void initViews() { + toolbar = findViewById(R.id.toolbar); + searchBar = findViewById(R.id.searchBox); + btnSearch = findViewById(R.id.btnSearch); + bottomNavigationView = findViewById(R.id.bottomNavigationView); + recyclerView = findViewById(R.id.recViewSearchResults); + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/thrifty/Signin.java b/app/src/main/java/com/example/thrifty/Signin.java index 8754dfc..c16cec1 100644 --- a/app/src/main/java/com/example/thrifty/Signin.java +++ b/app/src/main/java/com/example/thrifty/Signin.java @@ -1,101 +1,101 @@ -package com.example.thrifty; - -import androidx.appcompat.app.AppCompatActivity; - -import android.annotation.SuppressLint; -import android.content.Intent; -import android.content.SharedPreferences; -import android.os.Bundle; -import android.preference.PreferenceManager; -import android.util.Log; -import android.view.Gravity; -import android.view.View; -import android.widget.Button; -import android.widget.EditText; -import android.widget.Toast; -import android.widget.Toolbar; - -import com.amplifyframework.AmplifyException; -import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; -import com.amplifyframework.api.aws.AWSApiPlugin; -import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; -import com.amplifyframework.core.Amplify; -import com.amplifyframework.datastore.AWSDataStorePlugin; -import com.amplifyframework.storage.s3.AWSS3StoragePlugin; - -public class Signin extends AppCompatActivity { - public static final String TAG = "SignIn"; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_signin); - configure(); - - Button btnSignIn = findViewById(R.id.signin); - EditText emailText = findViewById(R.id.editTextTextPersonName6); - EditText passwordSignIn = findViewById(R.id.editTextTextPassword2); - EditText username = findViewById(R.id.fullnameT); - - - try { - // Add these lines to add the AWSApiPlugin plugins - Amplify.addPlugin(new AWSApiPlugin()); // stores things in DynamoDB and allows us to perform GraphQL queries - Amplify.addPlugin(new AWSCognitoAuthPlugin()); - Amplify.addPlugin(new AWSS3StoragePlugin()); - Amplify.configure(getApplicationContext()); - - - Log.i(TAG, "Initialized Amplify"); - } catch (AmplifyException error) { - Log.e(TAG, "Could not initialize Amplify", error); - } - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - @SuppressLint("CommitPrefEdits") SharedPreferences.Editor editor = sharedPreferences.edit(); - - - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - toolbar.setNavigationIcon(R.drawable.ic_baseline_arrow_back_ios_new_24); - toolbar.setNavigationOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(Signin.this, MainActivity.class); - startActivity(intent); - } - }); - btnSignIn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Amplify.Auth.signIn( - emailText.getText().toString(), - passwordSignIn.getText().toString(), - result -> { - Log.i("AuthQuickstart", result.isSignInComplete() ? "Sign in succeeded" : "Sign in not complete"); - Intent intent = new Intent(Signin.this, MainActivity.class); - startActivity(intent); - }, - error -> Log.e("AuthQuickstart", error.toString()) - ); - editor.putString("name",username.getText().toString()); - editor.apply(); - editor.putString("email",emailText.getText().toString()); - editor.apply(); - } - }); - } - - public void configure() { - try { - Amplify.addPlugin(new AWSPinpointAnalyticsPlugin(getApplication())); - Amplify.addPlugin(new AWSS3StoragePlugin()); - Amplify.addPlugin(new AWSCognitoAuthPlugin()); - Amplify.addPlugin(new AWSApiPlugin()); - Amplify.addPlugin(new AWSDataStorePlugin()); - Amplify.configure(getApplicationContext()); - Log.i("MyAmplifyApp", "Initialized Amplify"); - } catch (AmplifyException error) { - Log.e("MyAmplifyApp", "Could not initialize Amplify", error); - } - - } +package com.example.thrifty; + +import androidx.appcompat.app.AppCompatActivity; + +import android.annotation.SuppressLint; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.util.Log; +import android.view.Gravity; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; +import android.widget.Toolbar; + +import com.amplifyframework.AmplifyException; +import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; +import com.amplifyframework.api.aws.AWSApiPlugin; +import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; +import com.amplifyframework.core.Amplify; +import com.amplifyframework.datastore.AWSDataStorePlugin; +import com.amplifyframework.storage.s3.AWSS3StoragePlugin; + +public class Signin extends AppCompatActivity { + public static final String TAG = "SignIn"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_signin); + configure(); + + Button btnSignIn = findViewById(R.id.signin); + EditText emailText = findViewById(R.id.editTextTextPersonName6); + EditText passwordSignIn = findViewById(R.id.editTextTextPassword2); + EditText username = findViewById(R.id.fullnameT); + + + try { + // Add these lines to add the AWSApiPlugin plugins + Amplify.addPlugin(new AWSApiPlugin()); // stores things in DynamoDB and allows us to perform GraphQL queries + Amplify.addPlugin(new AWSCognitoAuthPlugin()); + Amplify.addPlugin(new AWSS3StoragePlugin()); + Amplify.configure(getApplicationContext()); + + + Log.i(TAG, "Initialized Amplify"); + } catch (AmplifyException error) { + Log.e(TAG, "Could not initialize Amplify", error); + } + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); + @SuppressLint("CommitPrefEdits") SharedPreferences.Editor editor = sharedPreferences.edit(); + + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + toolbar.setNavigationIcon(R.drawable.ic_baseline_arrow_back_ios_new_24); + toolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(Signin.this, MainActivity.class); + startActivity(intent); + } + }); + btnSignIn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Amplify.Auth.signIn( + emailText.getText().toString(), + passwordSignIn.getText().toString(), + result -> { + Log.i("AuthQuickstart", result.isSignInComplete() ? "Sign in succeeded" : "Sign in not complete"); + Intent intent = new Intent(Signin.this, MainActivity.class); + startActivity(intent); + }, + error -> Log.e("AuthQuickstart", error.toString()) + ); + editor.putString("name",username.getText().toString()); + editor.apply(); + editor.putString("email",emailText.getText().toString()); + editor.apply(); + } + }); + } + + public void configure() { + try { + Amplify.addPlugin(new AWSPinpointAnalyticsPlugin(getApplication())); + Amplify.addPlugin(new AWSS3StoragePlugin()); + Amplify.addPlugin(new AWSCognitoAuthPlugin()); + Amplify.addPlugin(new AWSApiPlugin()); + Amplify.addPlugin(new AWSDataStorePlugin()); + Amplify.configure(getApplicationContext()); + Log.i("MyAmplifyApp", "Initialized Amplify"); + } catch (AmplifyException error) { + Log.e("MyAmplifyApp", "Could not initialize Amplify", error); + } + + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/thrifty/Signup.java b/app/src/main/java/com/example/thrifty/Signup.java index e49cfb9..843720f 100644 --- a/app/src/main/java/com/example/thrifty/Signup.java +++ b/app/src/main/java/com/example/thrifty/Signup.java @@ -1,121 +1,121 @@ -package com.example.thrifty; - -import androidx.appcompat.app.AppCompatActivity; - -import android.annotation.SuppressLint; -import android.content.Intent; -import android.content.SharedPreferences; -import android.os.Bundle; -import android.preference.PreferenceManager; -import android.util.Log; -import android.view.View; -import android.widget.Button; -import android.widget.EditText; -import android.widget.TextView; -import android.widget.Toolbar; - -import com.amplifyframework.AmplifyException; -import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; -import com.amplifyframework.api.aws.AWSApiPlugin; -import com.amplifyframework.auth.AuthUserAttributeKey; -import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; -import com.amplifyframework.auth.options.AuthSignUpOptions; -import com.amplifyframework.core.Amplify; -import com.amplifyframework.datastore.AWSDataStorePlugin; -import com.amplifyframework.storage.s3.AWSS3StoragePlugin; - -public class Signup extends AppCompatActivity { - public static final String TAG = "SignUp"; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_signup); - - try { - Amplify.addPlugin(new AWSPinpointAnalyticsPlugin(getApplication())); - Amplify.addPlugin(new AWSS3StoragePlugin()); - Amplify.addPlugin(new AWSCognitoAuthPlugin()); - Amplify.addPlugin(new AWSApiPlugin()); - Amplify.addPlugin(new AWSDataStorePlugin()); - Amplify.configure(getApplicationContext()); - Log.i("MyAmplifyApp", "Initialized Amplify"); - } catch (AmplifyException error) { - Log.e("MyAmplifyApp", "Could not initialize Amplify", error); - } - - EditText username = findViewById(R.id.firstName); - EditText emailText = findViewById(R.id.editTextTextPersonName5); - EditText password = findViewById(R.id.editTextTextPassword); - Button btnSignUp = findViewById(R.id.signup); - Button btnSignIn = findViewById(R.id.signin); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - toolbar.setNavigationIcon(R.drawable.ic_baseline_arrow_back_ios_new_24); - toolbar.setNavigationOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - - Intent intent = new Intent(Signup.this, MainActivity.class); - startActivity(intent); - } - }); - - try { - // Add these lines to add the AWSApiPlugin plugins - Amplify.addPlugin(new AWSApiPlugin()); // stores things in DynamoDB and allows us to perform GraphQL queries - Amplify.addPlugin(new AWSCognitoAuthPlugin()); - Amplify.addPlugin(new AWSS3StoragePlugin()); - Amplify.addPlugin(new AWSPinpointAnalyticsPlugin(getApplication())); - Amplify.configure(getApplicationContext()); - - - Log.i(TAG, "Initialized Amplify"); - } catch (AmplifyException error) { - Log.e(TAG, "Could not initialize Amplify", error); - } - - - TextView phone = findViewById(R.id.phoneText); - - findViewById(R.id.signup).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(Signup.this); - @SuppressLint("CommitPrefEdits") SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.putString("phone",phone.getText().toString()); - editor.apply(); - - Intent intent = new Intent(Signup.this, ConfirmationPage.class); - startActivity(intent); - - } - }); - btnSignIn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Intent intent = new Intent(Signup.this, Signin.class); - startActivity(intent); - } - }); - btnSignUp.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Amplify.Auth.fetchAuthSession( - result -> Log.i("AmplifyQuickstart", result.toString()), - error -> Log.e("AmplifyQuickstart", error.toString()) - ); - AuthSignUpOptions options = AuthSignUpOptions.builder() - .userAttribute(AuthUserAttributeKey.email(), emailText.getText().toString()) - .build(); - - Amplify.Auth.signUp(emailText.getText().toString(), password.getText().toString(), options, - result -> Log.i("AuthQuickStart", "Result: " + result.toString()), - error -> Log.e("AuthQuickStart", "Sign up failed", error) - ); - Intent intent = new Intent(Signup.this, ConfirmationPage.class); - startActivity(intent); - } - }); - - - } +package com.example.thrifty; + +import androidx.appcompat.app.AppCompatActivity; + +import android.annotation.SuppressLint; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toolbar; + +import com.amplifyframework.AmplifyException; +import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; +import com.amplifyframework.api.aws.AWSApiPlugin; +import com.amplifyframework.auth.AuthUserAttributeKey; +import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; +import com.amplifyframework.auth.options.AuthSignUpOptions; +import com.amplifyframework.core.Amplify; +import com.amplifyframework.datastore.AWSDataStorePlugin; +import com.amplifyframework.storage.s3.AWSS3StoragePlugin; + +public class Signup extends AppCompatActivity { + public static final String TAG = "SignUp"; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_signup); + + try { + Amplify.addPlugin(new AWSPinpointAnalyticsPlugin(getApplication())); + Amplify.addPlugin(new AWSS3StoragePlugin()); + Amplify.addPlugin(new AWSCognitoAuthPlugin()); + Amplify.addPlugin(new AWSApiPlugin()); + Amplify.addPlugin(new AWSDataStorePlugin()); + Amplify.configure(getApplicationContext()); + Log.i("MyAmplifyApp", "Initialized Amplify"); + } catch (AmplifyException error) { + Log.e("MyAmplifyApp", "Could not initialize Amplify", error); + } + + EditText username = findViewById(R.id.firstName); + EditText emailText = findViewById(R.id.editTextTextPersonName5); + EditText password = findViewById(R.id.editTextTextPassword); + Button btnSignUp = findViewById(R.id.signup); + Button btnSignIn = findViewById(R.id.signin); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + toolbar.setNavigationIcon(R.drawable.ic_baseline_arrow_back_ios_new_24); + toolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + Intent intent = new Intent(Signup.this, MainActivity.class); + startActivity(intent); + } + }); + + try { + // Add these lines to add the AWSApiPlugin plugins + Amplify.addPlugin(new AWSApiPlugin()); // stores things in DynamoDB and allows us to perform GraphQL queries + Amplify.addPlugin(new AWSCognitoAuthPlugin()); + Amplify.addPlugin(new AWSS3StoragePlugin()); + Amplify.addPlugin(new AWSPinpointAnalyticsPlugin(getApplication())); + Amplify.configure(getApplicationContext()); + + + Log.i(TAG, "Initialized Amplify"); + } catch (AmplifyException error) { + Log.e(TAG, "Could not initialize Amplify", error); + } + + + TextView phone = findViewById(R.id.phoneText); + + findViewById(R.id.signup).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(Signup.this); + @SuppressLint("CommitPrefEdits") SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putString("phone",phone.getText().toString()); + editor.apply(); + + Intent intent = new Intent(Signup.this, ConfirmationPage.class); + startActivity(intent); + + } + }); + btnSignIn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(Signup.this, Signin.class); + startActivity(intent); + } + }); + btnSignUp.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Amplify.Auth.fetchAuthSession( + result -> Log.i("AmplifyQuickstart", result.toString()), + error -> Log.e("AmplifyQuickstart", error.toString()) + ); + AuthSignUpOptions options = AuthSignUpOptions.builder() + .userAttribute(AuthUserAttributeKey.email(), emailText.getText().toString()) + .build(); + + Amplify.Auth.signUp(emailText.getText().toString(), password.getText().toString(), options, + result -> Log.i("AuthQuickStart", "Result: " + result.toString()), + error -> Log.e("AuthQuickStart", "Sign up failed", error) + ); + Intent intent = new Intent(Signup.this, ConfirmationPage.class); + startActivity(intent); + } + }); + + + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/thrifty/Splash.java b/app/src/main/java/com/example/thrifty/Splash.java index 1f08a4f..fcab1b2 100644 --- a/app/src/main/java/com/example/thrifty/Splash.java +++ b/app/src/main/java/com/example/thrifty/Splash.java @@ -1,56 +1,56 @@ -package com.example.thrifty; - -import androidx.appcompat.app.AppCompatActivity; - -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; -import android.os.Handler; -import android.util.Log; - -import com.amplifyframework.AmplifyException; -import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; -import com.amplifyframework.api.aws.AWSApiPlugin; -import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; -import com.amplifyframework.core.Amplify; -import com.amplifyframework.datastore.AWSDataStorePlugin; -import com.amplifyframework.storage.s3.AWSS3StoragePlugin; - -import com.amazonaws.mobileconnectors.cognitoidentityprovider.handlers.SignUpHandler; - -public class Splash extends Activity { - - /** Duration of wait **/ - private final int SPLASH_DISPLAY_LENGTH = 3000; - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - setContentView(R.layout.activity_splash); - - try { - Amplify.addPlugin(new AWSPinpointAnalyticsPlugin(getApplication())); - Amplify.addPlugin(new AWSS3StoragePlugin()); - Amplify.addPlugin(new AWSCognitoAuthPlugin()); - Amplify.addPlugin(new AWSApiPlugin()); - Amplify.addPlugin(new AWSDataStorePlugin()); - Amplify.configure(getApplicationContext()); - Log.i("MyAmplifyApp", "Initialized Amplify"); - } catch (AmplifyException error) { - Log.e("MyAmplifyApp", "Could not initialize Amplify", error); - } - - /* New Handler to start the Menu-Activity - * and close this Splash-Screen after some seconds.*/ - new Handler().postDelayed(new Runnable(){ - @Override - public void run() { - /* Create an Intent that will start the Menu-Activity. */ - Intent mainIntent = new Intent(Splash.this,Signup.class); - Splash.this.startActivity(mainIntent); - Splash.this.finish(); - } - }, SPLASH_DISPLAY_LENGTH); - } +package com.example.thrifty; + +import androidx.appcompat.app.AppCompatActivity; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; +import android.util.Log; + +import com.amplifyframework.AmplifyException; +import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; +import com.amplifyframework.api.aws.AWSApiPlugin; +import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; +import com.amplifyframework.core.Amplify; +import com.amplifyframework.datastore.AWSDataStorePlugin; +import com.amplifyframework.storage.s3.AWSS3StoragePlugin; + +import com.amazonaws.mobileconnectors.cognitoidentityprovider.handlers.SignUpHandler; + +public class Splash extends Activity { + + /** Duration of wait **/ + private final int SPLASH_DISPLAY_LENGTH = 3000; + + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + setContentView(R.layout.activity_splash); + + try { + Amplify.addPlugin(new AWSPinpointAnalyticsPlugin(getApplication())); + Amplify.addPlugin(new AWSS3StoragePlugin()); + Amplify.addPlugin(new AWSCognitoAuthPlugin()); + Amplify.addPlugin(new AWSApiPlugin()); + Amplify.addPlugin(new AWSDataStorePlugin()); + Amplify.configure(getApplicationContext()); + Log.i("MyAmplifyApp", "Initialized Amplify"); + } catch (AmplifyException error) { + Log.e("MyAmplifyApp", "Could not initialize Amplify", error); + } + + /* New Handler to start the Menu-Activity + * and close this Splash-Screen after some seconds.*/ + new Handler().postDelayed(new Runnable(){ + @Override + public void run() { + /* Create an Intent that will start the Menu-Activity. */ + Intent mainIntent = new Intent(Splash.this,Signup.class); + Splash.this.startActivity(mainIntent); + Splash.this.finish(); + } + }, SPLASH_DISPLAY_LENGTH); + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/thrifty/Team.java b/app/src/main/java/com/example/thrifty/Team.java new file mode 100644 index 0000000..e08c961 --- /dev/null +++ b/app/src/main/java/com/example/thrifty/Team.java @@ -0,0 +1,14 @@ +package com.example.thrifty; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; + +public class Team extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_team); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/thrifty/TrackActivity.java b/app/src/main/java/com/example/thrifty/TrackActivity.java new file mode 100644 index 0000000..aca70dd --- /dev/null +++ b/app/src/main/java/com/example/thrifty/TrackActivity.java @@ -0,0 +1,149 @@ +package com.example.thrifty; + +import androidx.appcompat.app.AppCompatActivity; + +import android.annotation.SuppressLint; +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +public class TrackActivity extends AppCompatActivity { + View view_order_placed,view_order_confirmed,view_order_processed,view_order_pickup,con_divider,ready_divider,placed_divider; + ImageView img_orderconfirmed,orderprocessed,orderpickup; + TextView textorderpickup,text_confirmed,textorderprocessed; + Button btnCancel; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_track); + btnCancel = findViewById(R.id.btnCancel); + view_order_placed=findViewById(R.id.view_order_placed); + view_order_confirmed=findViewById(R.id.view_order_confirmed); + view_order_processed=findViewById(R.id.view_order_processed); + view_order_pickup=findViewById(R.id.view_order_pickup); + placed_divider=findViewById(R.id.placed_divider); + con_divider=findViewById(R.id.con_divider); + ready_divider=findViewById(R.id.ready_divider); + + textorderpickup=findViewById(R.id.textorderpickup); + text_confirmed=findViewById(R.id.text_confirmed); + textorderprocessed=findViewById(R.id.textorderprocessed); + + img_orderconfirmed=findViewById(R.id.img_orderconfirmed); + orderprocessed=findViewById(R.id.orderprocessed); + orderpickup=findViewById(R.id.orderpickup); + Intent intent=getIntent(); + String orderStatus=intent.getStringExtra("orderStatus"); + + getOrderStatus(orderStatus); + + btnCancel.setOnClickListener(view ->{ + Intent intent1 = new Intent(TrackActivity.this, OrderTracking.class); + Toast.makeText(getApplicationContext(), "Order Canceled", Toast.LENGTH_SHORT).show(); + startActivity(intent1); + }); + } + + private void getOrderStatus(String orderStatus) { + if (orderStatus.equals("0")){ + float alfa= (float) 0.5; + setStatus(alfa); + + }else if (orderStatus.equals("1")){ + float alfa= (float) 1; + setStatus1(alfa); + + }else if (orderStatus.equals("2")){ + float alfa= (float) 1; + setStatus2(alfa); + + + }else if (orderStatus.equals("3")){ + float alfa= (float) 1; + setStatus3(alfa); + } + } + + @SuppressLint("UseCompatLoadingForDrawables") + private void setStatus(float alfa) { + float myf= (float) 0.5; + view_order_placed.setBackground(getResources().getDrawable(R.drawable.shape_status_completed)); + view_order_confirmed.setBackground(getResources().getDrawable(R.drawable.shape_status_current)); + orderprocessed.setAlpha(alfa); + view_order_processed.setBackground(getResources().getDrawable(R.drawable.shape_status_current)); + con_divider.setBackground(getResources().getDrawable(R.drawable.shape_status_current)); + placed_divider.setAlpha(alfa); + img_orderconfirmed.setAlpha(alfa); + placed_divider.setBackground(getResources().getDrawable(R.drawable.shape_status_current)); + text_confirmed.setAlpha(alfa); + textorderprocessed.setAlpha(alfa); + view_order_pickup.setBackground(getResources().getDrawable(R.drawable.shape_status_current)); + ready_divider.setBackground(getResources().getDrawable(R.drawable.shape_status_current)); + orderpickup.setAlpha(alfa); + + textorderpickup.setAlpha(myf); + } + + @SuppressLint("UseCompatLoadingForDrawables") + private void setStatus1(float alfa) { + float myf= (float) 0.5; + view_order_placed.setBackground(getResources().getDrawable(R.drawable.shape_status_completed)); + view_order_confirmed.setBackground(getResources().getDrawable(R.drawable.shape_status_completed)); + orderprocessed.setAlpha(myf); + view_order_processed.setBackground(getResources().getDrawable(R.drawable.shape_status_current)); + con_divider.setBackground(getResources().getDrawable(R.drawable.shape_status_current)); + placed_divider.setBackground(getResources().getDrawable(R.drawable.shape_status_completed)); + img_orderconfirmed.setAlpha(alfa); + + text_confirmed.setAlpha(alfa); + textorderprocessed.setAlpha(myf); + view_order_pickup.setAlpha(myf); + ready_divider.setBackground(getResources().getDrawable(R.drawable.shape_status_current)); + orderpickup.setAlpha(myf); + view_order_pickup.setBackground(getResources().getDrawable(R.drawable.shape_status_current)); + textorderpickup.setAlpha(myf); + } + + @SuppressLint("UseCompatLoadingForDrawables") + private void setStatus2(float alfa) { + float myf= (float) 0.5; + view_order_placed.setBackground(getResources().getDrawable(R.drawable.shape_status_completed)); + view_order_confirmed.setBackground(getResources().getDrawable(R.drawable.shape_status_completed)); + orderprocessed.setAlpha(alfa); + view_order_processed.setBackground(getResources().getDrawable(R.drawable.shape_status_completed)); + con_divider.setBackground(getResources().getDrawable(R.drawable.shape_status_completed)); + placed_divider.setBackground(getResources().getDrawable(R.drawable.shape_status_completed)); + img_orderconfirmed.setAlpha(alfa); + + text_confirmed.setAlpha(alfa); + textorderprocessed.setAlpha(alfa); + view_order_pickup.setBackground(getResources().getDrawable(R.drawable.shape_status_current)); + ready_divider.setBackground(getResources().getDrawable(R.drawable.shape_status_current)); + textorderpickup.setAlpha(myf); + orderpickup.setAlpha(myf); + + } + + @SuppressLint("UseCompatLoadingForDrawables") + private void setStatus3(float alfa) { + view_order_placed.setBackground(getResources().getDrawable(R.drawable.shape_status_completed)); + view_order_confirmed.setBackground(getResources().getDrawable(R.drawable.shape_status_completed)); + orderprocessed.setAlpha(alfa); + view_order_processed.setBackground(getResources().getDrawable(R.drawable.shape_status_completed)); + con_divider.setBackground(getResources().getDrawable(R.drawable.shape_status_completed)); + + img_orderconfirmed.setAlpha(alfa); + placed_divider.setBackground(getResources().getDrawable(R.drawable.shape_status_completed)); + text_confirmed.setAlpha(alfa); + textorderprocessed.setAlpha(alfa); + view_order_pickup.setBackground(getResources().getDrawable(R.drawable.shape_status_completed)); + ready_divider.setBackground(getResources().getDrawable(R.drawable.shape_status_completed)); + textorderpickup.setAlpha(alfa); + orderpickup.setAlpha(alfa); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/thrifty/Watches.java b/app/src/main/java/com/example/thrifty/Watches.java index 7d1d7b1..6c8add1 100644 --- a/app/src/main/java/com/example/thrifty/Watches.java +++ b/app/src/main/java/com/example/thrifty/Watches.java @@ -1,63 +1,63 @@ -package com.example.thrifty; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; -import android.os.Message; -import android.util.Log; - -import com.amplifyframework.AmplifyException; -import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; -import com.amplifyframework.api.aws.AWSApiPlugin; -import com.amplifyframework.api.graphql.model.ModelQuery; -import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; -import com.amplifyframework.core.Amplify; -import com.amplifyframework.datastore.AWSDataStorePlugin; -import com.amplifyframework.datastore.generated.model.Product; -import com.amplifyframework.storage.s3.AWSS3StoragePlugin; -import com.example.thrifty.adapters.KidsClothesAdapter; -import com.example.thrifty.adapters.WatchesAdapter; - -import java.util.ArrayList; -import java.util.List; - -public class Watches extends AppCompatActivity { - - private List categorizedProducts = new ArrayList<>(); - RecyclerView categorizedRecView; - WatchesAdapter watchesAdapter; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_watches); - - categorizedRecView = findViewById(R.id.categorizedRecView); - categorizedRecView.setAdapter(watchesAdapter); - categorizedRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(),RecyclerView.HORIZONTAL,false)); - - categorizedRecView.setAdapter(new WatchesAdapter(categorizedProducts,this)); - Handler categorizedHandler = new Handler(Looper.myLooper(), new Handler.Callback() { - @Override - public boolean handleMessage(@NonNull Message msg) { - categorizedRecView.getAdapter().notifyDataSetChanged(); - return false; - } - }); - Amplify.API.query( - ModelQuery.list(Product.class,Product.CATEGORY_ID.eq("watches")), - response -> { - for (Product product : response.getData()) { - categorizedProducts.add(product); - } - categorizedHandler.sendEmptyMessage(1); - }, error -> Log.e("MyAmplifyApp", "Query failure", error) - ); - - } +package com.example.thrifty; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.util.Log; + +import com.amplifyframework.AmplifyException; +import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; +import com.amplifyframework.api.aws.AWSApiPlugin; +import com.amplifyframework.api.graphql.model.ModelQuery; +import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; +import com.amplifyframework.core.Amplify; +import com.amplifyframework.datastore.AWSDataStorePlugin; +import com.amplifyframework.datastore.generated.model.Product; +import com.amplifyframework.storage.s3.AWSS3StoragePlugin; +import com.example.thrifty.adapters.KidsClothesAdapter; +import com.example.thrifty.adapters.WatchesAdapter; + +import java.util.ArrayList; +import java.util.List; + +public class Watches extends AppCompatActivity { + + private List categorizedProducts = new ArrayList<>(); + RecyclerView categorizedRecView; + WatchesAdapter watchesAdapter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_watches); + + categorizedRecView = findViewById(R.id.categorizedRecView); + categorizedRecView.setAdapter(watchesAdapter); + categorizedRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(),RecyclerView.HORIZONTAL,false)); + + categorizedRecView.setAdapter(new WatchesAdapter(categorizedProducts,this)); + Handler categorizedHandler = new Handler(Looper.myLooper(), new Handler.Callback() { + @Override + public boolean handleMessage(@NonNull Message msg) { + categorizedRecView.getAdapter().notifyDataSetChanged(); + return false; + } + }); + Amplify.API.query( + ModelQuery.list(Product.class,Product.CATEGORY_ID.eq("watches")), + response -> { + for (Product product : response.getData()) { + categorizedProducts.add(product); + } + categorizedHandler.sendEmptyMessage(1); + }, error -> Log.e("MyAmplifyApp", "Query failure", error) + ); + + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/thrifty/WomenClothes.java b/app/src/main/java/com/example/thrifty/WomenClothes.java index 2cfb8c4..cb05ef1 100644 --- a/app/src/main/java/com/example/thrifty/WomenClothes.java +++ b/app/src/main/java/com/example/thrifty/WomenClothes.java @@ -1,64 +1,64 @@ -package com.example.thrifty; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; -import android.os.Message; -import android.util.Log; - -import com.amplifyframework.AmplifyException; -import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; -import com.amplifyframework.api.aws.AWSApiPlugin; -import com.amplifyframework.api.graphql.model.ModelQuery; -import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; -import com.amplifyframework.core.Amplify; -import com.amplifyframework.datastore.AWSDataStorePlugin; -import com.amplifyframework.datastore.generated.model.Product; -import com.amplifyframework.storage.s3.AWSS3StoragePlugin; -import com.example.thrifty.adapters.WomenClothesAdapter; - -import java.util.ArrayList; -import java.util.List; - -public class WomenClothes extends AppCompatActivity { - - private List categorizedProducts = new ArrayList<>(); - RecyclerView categorizedRecView; - WomenClothesAdapter womenClothesAdapter; - - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_women_clothes); - - categorizedRecView = findViewById(R.id.categorizedRecView); - categorizedRecView.setAdapter(womenClothesAdapter); - categorizedRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(),RecyclerView.HORIZONTAL,false)); - - categorizedRecView.setAdapter(new WomenClothesAdapter(categorizedProducts, WomenClothes.this)); - Handler categorizedHandler = new Handler(Looper.myLooper(), new Handler.Callback() { - @Override - public boolean handleMessage(@NonNull Message msg) { - categorizedRecView.getAdapter().notifyDataSetChanged(); - return false; - } - }); - - Amplify.API.query( - ModelQuery.list(Product.class,Product.CATEGORY_ID.eq("women_clothes")), - response -> { - for (Product product : response.getData()) { - categorizedProducts.add(product); - } - categorizedHandler.sendEmptyMessage(1); - }, error -> Log.e("MyAmplifyApp", "Query failure", error) - ); - - } +package com.example.thrifty; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.util.Log; + +import com.amplifyframework.AmplifyException; +import com.amplifyframework.analytics.pinpoint.AWSPinpointAnalyticsPlugin; +import com.amplifyframework.api.aws.AWSApiPlugin; +import com.amplifyframework.api.graphql.model.ModelQuery; +import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin; +import com.amplifyframework.core.Amplify; +import com.amplifyframework.datastore.AWSDataStorePlugin; +import com.amplifyframework.datastore.generated.model.Product; +import com.amplifyframework.storage.s3.AWSS3StoragePlugin; +import com.example.thrifty.adapters.WomenClothesAdapter; + +import java.util.ArrayList; +import java.util.List; + +public class WomenClothes extends AppCompatActivity { + + private List categorizedProducts = new ArrayList<>(); + RecyclerView categorizedRecView; + WomenClothesAdapter womenClothesAdapter; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_women_clothes); + + categorizedRecView = findViewById(R.id.categorizedRecView); + categorizedRecView.setAdapter(womenClothesAdapter); + categorizedRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(),RecyclerView.HORIZONTAL,false)); + + categorizedRecView.setAdapter(new WomenClothesAdapter(categorizedProducts, WomenClothes.this)); + Handler categorizedHandler = new Handler(Looper.myLooper(), new Handler.Callback() { + @Override + public boolean handleMessage(@NonNull Message msg) { + categorizedRecView.getAdapter().notifyDataSetChanged(); + return false; + } + }); + + Amplify.API.query( + ModelQuery.list(Product.class,Product.CATEGORY_ID.eq("women_clothes")), + response -> { + for (Product product : response.getData()) { + categorizedProducts.add(product); + } + categorizedHandler.sendEmptyMessage(1); + }, error -> Log.e("MyAmplifyApp", "Query failure", error) + ); + + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/thrifty/adapters/NewItemsAdapter.java b/app/src/main/java/com/example/thrifty/adapters/NewItemsAdapter.java index 7b70297..e7fdffc 100644 --- a/app/src/main/java/com/example/thrifty/adapters/NewItemsAdapter.java +++ b/app/src/main/java/com/example/thrifty/adapters/NewItemsAdapter.java @@ -1,115 +1,115 @@ -package com.example.thrifty.adapters; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.preference.PreferenceManager; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Button; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.RecyclerView; - -import com.amplifyframework.api.graphql.model.ModelMutation; -import com.amplifyframework.core.Amplify; -import com.amplifyframework.datastore.generated.model.Favorite; -import com.amplifyframework.datastore.generated.model.Product; - -import java.util.ArrayList; -import java.util.List; - -import com.example.thrifty.MainActivity; -import com.example.thrifty.ProductView; -import com.example.thrifty.R; - - - - -public class NewItemsAdapter extends RecyclerView.Adapter { - List products = new ArrayList<>(); - - public NewItemsAdapter(List products, MainActivity mainActivity){ - this.products = products; - } - - - @NonNull - @Override - public NewItemsHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_layout, parent , false); - return new NewItemsAdapter.NewItemsHolder(view); - } - - @Override - public void onBindViewHolder(@NonNull NewItemsHolder holder, @SuppressLint("RecyclerView") int position) { - holder.product = products.get(position); - TextView title = holder.itemView.findViewById(R.id.titlefrag1); - TextView category = holder.itemView.findViewById(R.id.categoryfrag); - TextView price = holder.itemView.findViewById(R.id.price); - // TextView email = holder.itemView.findViewById(R.id.editTextTextPersonName6); - - Button btn = holder.itemView.findViewById(R.id.button2); - btn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Toast.makeText(view.getContext(), "fav Button Clicked", Toast.LENGTH_LONG).show(); - String name = title.getText().toString(); - String cat = category.getText().toString(); -// String emailText = email.getText().toString(); - Favorite favorite = new Favorite.Builder() - .titleFav(name) - .imageFav("categoryFav") - .priceFav("15") - .sizeFav("15") - .categoryFav(cat) - .userId("emailText") - .build(); - Amplify.API.mutate( - ModelMutation.create(favorite), - response -> Log.i("MyAmplifyApp", "Added Todo with id: " + response.getData().getId()), - error -> Log.e("MyAmplifyApp", "Create failed", error) - - ); - } - }); - - title.setText(holder.product.getTitle()); - category.setText(holder.product.getCategoryId()); - price.setText(holder.product.getPrice()); - - - holder.itemView.findViewById(R.id.card).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Intent goToDetails = new Intent(view.getContext(), ProductView.class); - goToDetails.putExtra("Title",products.get(position).getTitle()); - goToDetails.putExtra("category",products.get(position).getCategoryId()); - goToDetails.putExtra("price", products.get(position).getPrice()); - - view.getContext().startActivity(goToDetails); - } - }); - } - - - @Override - public int getItemCount() { - return products.size(); - } - - public static class NewItemsHolder extends RecyclerView.ViewHolder{ - public Product product; - public View itemView; - public NewItemsHolder(@NonNull View itemView) { - super(itemView); - this.itemView = itemView; - } - } -} - +package com.example.thrifty.adapters; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.amplifyframework.api.graphql.model.ModelMutation; +import com.amplifyframework.core.Amplify; +import com.amplifyframework.datastore.generated.model.Favorite; +import com.amplifyframework.datastore.generated.model.Product; + +import java.util.ArrayList; +import java.util.List; + +import com.example.thrifty.MainActivity; +import com.example.thrifty.ProductView; +import com.example.thrifty.R; + + + + +public class NewItemsAdapter extends RecyclerView.Adapter { + List products = new ArrayList<>(); + + public NewItemsAdapter(List products, MainActivity mainActivity){ + this.products = products; + } + + + @NonNull + @Override + public NewItemsHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_layout, parent , false); + return new NewItemsAdapter.NewItemsHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull NewItemsHolder holder, @SuppressLint("RecyclerView") int position) { + holder.product = products.get(position); + TextView title = holder.itemView.findViewById(R.id.titlefrag1); + TextView category = holder.itemView.findViewById(R.id.categoryfrag); + TextView price = holder.itemView.findViewById(R.id.price); + // TextView email = holder.itemView.findViewById(R.id.editTextTextPersonName6); + + Button btn = holder.itemView.findViewById(R.id.button2); + btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Toast.makeText(view.getContext(), "fav Button Clicked", Toast.LENGTH_LONG).show(); + String name = title.getText().toString(); + String cat = category.getText().toString(); +// String emailText = email.getText().toString(); + Favorite favorite = new Favorite.Builder() + .titleFav(name) + .imageFav("categoryFav") + .priceFav("15") + .sizeFav("15") + .categoryFav(cat) + .userId("emailText") + .build(); + Amplify.API.mutate( + ModelMutation.create(favorite), + response -> Log.i("MyAmplifyApp", "Added Todo with id: " + response.getData().getId()), + error -> Log.e("MyAmplifyApp", "Create failed", error) + + ); + } + }); + + title.setText(holder.product.getTitle()); + category.setText(holder.product.getCategoryId()); + price.setText(holder.product.getPrice()); + + + holder.itemView.findViewById(R.id.card).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent goToDetails = new Intent(view.getContext(), ProductView.class); + goToDetails.putExtra("Title",products.get(position).getTitle()); + goToDetails.putExtra("category",products.get(position).getCategoryId()); + goToDetails.putExtra("price", products.get(position).getPrice()); + + view.getContext().startActivity(goToDetails); + } + }); + } + + + @Override + public int getItemCount() { + return products.size(); + } + + public static class NewItemsHolder extends RecyclerView.ViewHolder{ + public Product product; + public View itemView; + public NewItemsHolder(@NonNull View itemView) { + super(itemView); + this.itemView = itemView; + } + } +} + diff --git a/app/src/main/java/com/example/thrifty/adapters/PopularItemsAdapter.java b/app/src/main/java/com/example/thrifty/adapters/PopularItemsAdapter.java index 89f83ba..0173217 100644 --- a/app/src/main/java/com/example/thrifty/adapters/PopularItemsAdapter.java +++ b/app/src/main/java/com/example/thrifty/adapters/PopularItemsAdapter.java @@ -1,47 +1,47 @@ -package com.example.thrifty.adapters; - -import android.view.View; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.RecyclerView; - -import com.amplifyframework.datastore.generated.model.Product; - -import java.util.ArrayList; -import java.util.List; - - -public class PopularItemsAdapter extends RecyclerView.Adapter{ - - List popularItems = new ArrayList<>(); - -public PopularItemsAdapter(List popularItems){ - this.popularItems = popularItems; -} - - @NonNull - @Override - public PopularItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - return null; - } - - @Override - public void onBindViewHolder(@NonNull PopularItemViewHolder holder, int position) { - - } - - @Override - public int getItemCount() { - return 0; - } - - public static class PopularItemViewHolder extends RecyclerView.ViewHolder{ - public View itemView; - public Product product; - public PopularItemViewHolder(@NonNull View itemView) { - super(itemView); - this.itemView = itemView; - } -} -} +package com.example.thrifty.adapters; + +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.amplifyframework.datastore.generated.model.Product; + +import java.util.ArrayList; +import java.util.List; + + +public class PopularItemsAdapter extends RecyclerView.Adapter{ + + List popularItems = new ArrayList<>(); + +public PopularItemsAdapter(List popularItems){ + this.popularItems = popularItems; +} + + @NonNull + @Override + public PopularItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return null; + } + + @Override + public void onBindViewHolder(@NonNull PopularItemViewHolder holder, int position) { + + } + + @Override + public int getItemCount() { + return 0; + } + + public static class PopularItemViewHolder extends RecyclerView.ViewHolder{ + public View itemView; + public Product product; + public PopularItemViewHolder(@NonNull View itemView) { + super(itemView); + this.itemView = itemView; + } +} +} diff --git a/app/src/main/java/com/example/thrifty/adapters/SuggestedItemsAdapter.java b/app/src/main/java/com/example/thrifty/adapters/SuggestedItemsAdapter.java index 0d1bdf0..06aa47e 100644 --- a/app/src/main/java/com/example/thrifty/adapters/SuggestedItemsAdapter.java +++ b/app/src/main/java/com/example/thrifty/adapters/SuggestedItemsAdapter.java @@ -1,45 +1,45 @@ - package com.example.thrifty.adapters; - -import android.view.View; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.RecyclerView; - -import com.amplifyframework.datastore.generated.model.Product; - -import java.util.ArrayList; -import java.util.List; - -public class SuggestedItemsAdapter extends RecyclerView.Adapter{ - List suggestedProducts = new ArrayList<>(); - - public SuggestedItemsAdapter(List suggestedProducts){ - this.suggestedProducts = suggestedProducts; - } - - @NonNull - @Override - public SuggestedItemsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - return null; - } - - @Override - public void onBindViewHolder(@NonNull SuggestedItemsViewHolder holder, int position) { - - } - - @Override - public int getItemCount() { - return 0; - } - - public static class SuggestedItemsViewHolder extends RecyclerView.ViewHolder { - - public View itemView; - public SuggestedItemsViewHolder(@NonNull View itemView) { - super(itemView); - this.itemView = itemView; - } - } -} + package com.example.thrifty.adapters; + +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.amplifyframework.datastore.generated.model.Product; + +import java.util.ArrayList; +import java.util.List; + +public class SuggestedItemsAdapter extends RecyclerView.Adapter{ + List suggestedProducts = new ArrayList<>(); + + public SuggestedItemsAdapter(List suggestedProducts){ + this.suggestedProducts = suggestedProducts; + } + + @NonNull + @Override + public SuggestedItemsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return null; + } + + @Override + public void onBindViewHolder(@NonNull SuggestedItemsViewHolder holder, int position) { + + } + + @Override + public int getItemCount() { + return 0; + } + + public static class SuggestedItemsViewHolder extends RecyclerView.ViewHolder { + + public View itemView; + public SuggestedItemsViewHolder(@NonNull View itemView) { + super(itemView); + this.itemView = itemView; + } + } +} diff --git a/app/src/main/java/com/example/thrifty/fragments/MainMenuFragment.java b/app/src/main/java/com/example/thrifty/fragments/MainMenuFragment.java index 1c0e922..40ed876 100644 --- a/app/src/main/java/com/example/thrifty/fragments/MainMenuFragment.java +++ b/app/src/main/java/com/example/thrifty/fragments/MainMenuFragment.java @@ -1,118 +1,118 @@ -package com.example.thrifty.fragments; - -import android.annotation.SuppressLint; -import android.content.Intent; -import android.os.Bundle; - -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; - -import android.view.LayoutInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Toast; - -import com.example.thrifty.MainActivity; -import com.example.thrifty.R; -import com.example.thrifty.SearchActivity; -import com.google.android.material.bottomnavigation.BottomNavigationView; -import com.google.android.material.navigation.NavigationBarView; - - -public class MainMenuFragment extends Fragment { - BottomNavigationView bottomNavigationView; - public MainMenuFragment() { - // Required empty public constructor - } - - - - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_main_menu, container, false); - // Inflate the layout for this fragment - initView(view); - bottomNav(); - return view; - - } - private void initView(View view){ - - bottomNavigationView = view.findViewById(R.id.bottomNavigationView); - } - @SuppressLint("NonConstantResourceId") - public void bottomNav(){ - bottomNavigationView.setSelectedItemId(R.id.search); - bottomNavigationView.setOnItemSelectedListener(item -> { - switch (item.getItemId()){ - case R.id.homeNav: - Toast.makeText(getActivity(),"Home Clicked", Toast.LENGTH_LONG).show(); - Intent intent = new Intent(getContext(), MainActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - break; - - case R.id.search: - Toast.makeText(getContext(),"Search Clicked", Toast.LENGTH_LONG).show(); - Intent intent1 = new Intent(getContext(), SearchActivity.class); - intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent1); - break; - - case R.id.cart: - Toast.makeText(getContext(),"Cart Clicked", Toast.LENGTH_LONG).show(); -// Intent intent2 = new Intent(getContext(), Cart.class); -// intent2.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); -// startActivity(intent2); - break; - case R.id.wishlist: - Toast.makeText(getContext(),"Wishlist Clicked", Toast.LENGTH_LONG).show(); -// Intent intent3 = new Intent(getContext(), Wishlist.class); -// intent3.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); -// startActivity(intent3); - break; - - case R.id.profile: - Toast.makeText(getContext(),"Profile Clicked", Toast.LENGTH_LONG).show(); -// Intent intent4 = new Intent(getContext(), Profile.class); -// intent4.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); -// startActivity(intent4); - break; - default: - Toast.makeText(getContext(),"None", Toast.LENGTH_LONG).show(); - break; - } - return false; - }); -// bottomNavigationView.setOnNavigationItemSelectedListener(item -> { -// switch (item.getItemId()){ -// case R.id.homeNav: -// Toast.makeText(getContext(),"Home Clicked", Toast.LENGTH_LONG).show(); -// break; -// -// case R.id.search: -// Toast.makeText(getContext(),"Search Clicked", Toast.LENGTH_LONG).show(); -// break; -// -// case R.id.cart: -// Toast.makeText(getContext(),"Cart Clicked", Toast.LENGTH_LONG).show(); -// break; -// case R.id.wishlist: -// Toast.makeText(getContext(),"Wishlist Clicked", Toast.LENGTH_LONG).show(); -// break; -// -// case R.id.profile: -// Toast.makeText(getContext(),"Profile Clicked", Toast.LENGTH_LONG).show(); -// break; -// default: -// Toast.makeText(getContext(),"None", Toast.LENGTH_LONG).show(); -// break; -// } -// -// return false; -// }); - } +package com.example.thrifty.fragments; + +import android.annotation.SuppressLint; +import android.content.Intent; +import android.os.Bundle; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + +import android.view.LayoutInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Toast; + +import com.example.thrifty.MainActivity; +import com.example.thrifty.R; +import com.example.thrifty.SearchActivity; +import com.google.android.material.bottomnavigation.BottomNavigationView; +import com.google.android.material.navigation.NavigationBarView; + + +public class MainMenuFragment extends Fragment { + BottomNavigationView bottomNavigationView; + public MainMenuFragment() { + // Required empty public constructor + } + + + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_main_menu, container, false); + // Inflate the layout for this fragment + initView(view); + bottomNav(); + return view; + + } + private void initView(View view){ + + bottomNavigationView = view.findViewById(R.id.bottomNavigationView); + } + @SuppressLint("NonConstantResourceId") + public void bottomNav(){ + bottomNavigationView.setSelectedItemId(R.id.search); + bottomNavigationView.setOnItemSelectedListener(item -> { + switch (item.getItemId()){ + case R.id.homeNav: + Toast.makeText(getActivity(),"Home Clicked", Toast.LENGTH_LONG).show(); + Intent intent = new Intent(getContext(), MainActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + break; + + case R.id.search: + Toast.makeText(getContext(),"Search Clicked", Toast.LENGTH_LONG).show(); + Intent intent1 = new Intent(getContext(), SearchActivity.class); + intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent1); + break; + + case R.id.cart: + Toast.makeText(getContext(),"Cart Clicked", Toast.LENGTH_LONG).show(); +// Intent intent2 = new Intent(getContext(), Cart.class); +// intent2.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); +// startActivity(intent2); + break; + case R.id.wishlist: + Toast.makeText(getContext(),"Wishlist Clicked", Toast.LENGTH_LONG).show(); +// Intent intent3 = new Intent(getContext(), Wishlist.class); +// intent3.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); +// startActivity(intent3); + break; + + case R.id.profile: + Toast.makeText(getContext(),"Profile Clicked", Toast.LENGTH_LONG).show(); +// Intent intent4 = new Intent(getContext(), Profile.class); +// intent4.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK); +// startActivity(intent4); + break; + default: + Toast.makeText(getContext(),"None", Toast.LENGTH_LONG).show(); + break; + } + return false; + }); +// bottomNavigationView.setOnNavigationItemSelectedListener(item -> { +// switch (item.getItemId()){ +// case R.id.homeNav: +// Toast.makeText(getContext(),"Home Clicked", Toast.LENGTH_LONG).show(); +// break; +// +// case R.id.search: +// Toast.makeText(getContext(),"Search Clicked", Toast.LENGTH_LONG).show(); +// break; +// +// case R.id.cart: +// Toast.makeText(getContext(),"Cart Clicked", Toast.LENGTH_LONG).show(); +// break; +// case R.id.wishlist: +// Toast.makeText(getContext(),"Wishlist Clicked", Toast.LENGTH_LONG).show(); +// break; +// +// case R.id.profile: +// Toast.makeText(getContext(),"Profile Clicked", Toast.LENGTH_LONG).show(); +// break; +// default: +// Toast.makeText(getContext(),"None", Toast.LENGTH_LONG).show(); +// break; +// } +// +// return false; +// }); + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/thrifty/fragments/ProductFragment.java b/app/src/main/java/com/example/thrifty/fragments/ProductFragment.java index f6c13eb..fd3ff28 100644 --- a/app/src/main/java/com/example/thrifty/fragments/ProductFragment.java +++ b/app/src/main/java/com/example/thrifty/fragments/ProductFragment.java @@ -1,66 +1,66 @@ -package com.example.thrifty.fragments; - -import android.os.Bundle; - -import androidx.fragment.app.Fragment; - -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import com.example.thrifty.R; - -/** - * A simple {@link Fragment} subclass. - * Use the {@link ProductFragment#newInstance} factory method to - * create an instance of this fragment. - */ -public class ProductFragment extends Fragment { - - // TODO: Rename parameter arguments, choose names that match - // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER - private static final String ARG_PARAM1 = "title"; - private static final String ARG_PARAM2 = "categoryID"; - - // TODO: Rename and change types of parameters - private String Title; - private String CategoryID; - - public ProductFragment() { - // Required empty public constructor - } - - /** - * Use this factory method to create a new instance of - * this fragment using the provided parameters. - * - * @param Title Parameter 1. - * @param CategoryID Parameter 2. - * @return A new instance of fragment ProductFragment. - */ - // TODO: Rename and change types and number of parameters - public static ProductFragment newInstance(String Title, String CategoryID) { - ProductFragment fragment = new ProductFragment(); - Bundle args = new Bundle(); - args.putString(ARG_PARAM1, Title); - args.putString(ARG_PARAM2, CategoryID); - fragment.setArguments(args); - return fragment; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - if (getArguments() != null) { - Title = getArguments().getString(ARG_PARAM1); - CategoryID = getArguments().getString(ARG_PARAM2); - } - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_product, container, false); - } +package com.example.thrifty.fragments; + +import android.os.Bundle; + +import androidx.fragment.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.example.thrifty.R; + +/** + * A simple {@link Fragment} subclass. + * Use the {@link ProductFragment#newInstance} factory method to + * create an instance of this fragment. + */ +public class ProductFragment extends Fragment { + + // TODO: Rename parameter arguments, choose names that match + // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER + private static final String ARG_PARAM1 = "title"; + private static final String ARG_PARAM2 = "categoryID"; + + // TODO: Rename and change types of parameters + private String Title; + private String CategoryID; + + public ProductFragment() { + // Required empty public constructor + } + + /** + * Use this factory method to create a new instance of + * this fragment using the provided parameters. + * + * @param Title Parameter 1. + * @param CategoryID Parameter 2. + * @return A new instance of fragment ProductFragment. + */ + // TODO: Rename and change types and number of parameters + public static ProductFragment newInstance(String Title, String CategoryID) { + ProductFragment fragment = new ProductFragment(); + Bundle args = new Bundle(); + args.putString(ARG_PARAM1, Title); + args.putString(ARG_PARAM2, CategoryID); + fragment.setArguments(args); + return fragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (getArguments() != null) { + Title = getArguments().getString(ARG_PARAM1); + CategoryID = getArguments().getString(ARG_PARAM2); + } + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_product, container, false); + } } \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml index 2b068d1..cc14f03 100644 --- a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -1,30 +1,30 @@ - - - - - - - - - - + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/abdelqader.jpg b/app/src/main/res/drawable/abdelqader.jpg new file mode 100644 index 0000000..a49c1d7 Binary files /dev/null and b/app/src/main/res/drawable/abdelqader.jpg differ diff --git a/app/src/main/res/drawable/btn_bg.xml b/app/src/main/res/drawable/btn_bg.xml new file mode 100644 index 0000000..c4c83f6 --- /dev/null +++ b/app/src/main/res/drawable/btn_bg.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/drop_shadow.xml b/app/src/main/res/drawable/drop_shadow.xml new file mode 100644 index 0000000..329c7f5 --- /dev/null +++ b/app/src/main/res/drawable/drop_shadow.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/heba.jpg b/app/src/main/res/drawable/heba.jpg new file mode 100644 index 0000000..2fadc7b Binary files /dev/null and b/app/src/main/res/drawable/heba.jpg differ diff --git a/app/src/main/res/drawable/ic_back.xml b/app/src/main/res/drawable/ic_back.xml new file mode 100644 index 0000000..eb30833 --- /dev/null +++ b/app/src/main/res/drawable/ic_back.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_baseline_alternate_email_24.xml b/app/src/main/res/drawable/ic_baseline_alternate_email_24.xml index 13a64aa..5d327fa 100644 --- a/app/src/main/res/drawable/ic_baseline_alternate_email_24.xml +++ b/app/src/main/res/drawable/ic_baseline_alternate_email_24.xml @@ -1,10 +1,10 @@ - - - + + + diff --git a/app/src/main/res/drawable/ic_baseline_arrow_back_ios_new_24.xml b/app/src/main/res/drawable/ic_baseline_arrow_back_ios_new_24.xml index c056a2e..1e7d457 100644 --- a/app/src/main/res/drawable/ic_baseline_arrow_back_ios_new_24.xml +++ b/app/src/main/res/drawable/ic_baseline_arrow_back_ios_new_24.xml @@ -1,10 +1,10 @@ - - - + + + diff --git a/app/src/main/res/drawable/ic_baseline_favorite_24.xml b/app/src/main/res/drawable/ic_baseline_favorite_24.xml index 52d4d9b..ff8bc58 100644 --- a/app/src/main/res/drawable/ic_baseline_favorite_24.xml +++ b/app/src/main/res/drawable/ic_baseline_favorite_24.xml @@ -1,10 +1,10 @@ - - - + + + diff --git a/app/src/main/res/drawable/ic_baseline_home_24.xml b/app/src/main/res/drawable/ic_baseline_home_24.xml index 3a4c7da..f47d904 100644 --- a/app/src/main/res/drawable/ic_baseline_home_24.xml +++ b/app/src/main/res/drawable/ic_baseline_home_24.xml @@ -1,10 +1,10 @@ - - - + + + diff --git a/app/src/main/res/drawable/ic_baseline_person_24.xml b/app/src/main/res/drawable/ic_baseline_person_24.xml index 6bdced2..39bbca1 100644 --- a/app/src/main/res/drawable/ic_baseline_person_24.xml +++ b/app/src/main/res/drawable/ic_baseline_person_24.xml @@ -1,10 +1,10 @@ - - - + + + diff --git a/app/src/main/res/drawable/ic_baseline_phone_24.xml b/app/src/main/res/drawable/ic_baseline_phone_24.xml index e1d37c4..72daa46 100644 --- a/app/src/main/res/drawable/ic_baseline_phone_24.xml +++ b/app/src/main/res/drawable/ic_baseline_phone_24.xml @@ -1,10 +1,10 @@ - - - + + + diff --git a/app/src/main/res/drawable/ic_baseline_search_24.xml b/app/src/main/res/drawable/ic_baseline_search_24.xml index 07b76d6..2dcfad9 100644 --- a/app/src/main/res/drawable/ic_baseline_search_24.xml +++ b/app/src/main/res/drawable/ic_baseline_search_24.xml @@ -1,10 +1,10 @@ - - - + + + diff --git a/app/src/main/res/drawable/ic_baseline_shopping_cart_24.xml b/app/src/main/res/drawable/ic_baseline_shopping_cart_24.xml index cf0dcc8..aa7453a 100644 --- a/app/src/main/res/drawable/ic_baseline_shopping_cart_24.xml +++ b/app/src/main/res/drawable/ic_baseline_shopping_cart_24.xml @@ -1,10 +1,10 @@ - - - + + + diff --git a/app/src/main/res/drawable/ic_baseline_star_24.xml b/app/src/main/res/drawable/ic_baseline_star_24.xml index 1500caa..cf3037b 100644 --- a/app/src/main/res/drawable/ic_baseline_star_24.xml +++ b/app/src/main/res/drawable/ic_baseline_star_24.xml @@ -1,5 +1,5 @@ - - - + + + diff --git a/app/src/main/res/drawable/ic_baseline_star_border_24.xml b/app/src/main/res/drawable/ic_baseline_star_border_24.xml index b6d93ca..2e2a393 100644 --- a/app/src/main/res/drawable/ic_baseline_star_border_24.xml +++ b/app/src/main/res/drawable/ic_baseline_star_border_24.xml @@ -1,10 +1,10 @@ - - - + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml index 07d5da9..a4f78de 100644 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -1,170 +1,170 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/jamal.png b/app/src/main/res/drawable/jamal.png new file mode 100644 index 0000000..b18d18f Binary files /dev/null and b/app/src/main/res/drawable/jamal.png differ diff --git a/app/src/main/res/drawable/khair.jpg b/app/src/main/res/drawable/khair.jpg new file mode 100644 index 0000000..8657084 Binary files /dev/null and b/app/src/main/res/drawable/khair.jpg differ diff --git a/app/src/main/res/drawable/mohammed.jpg b/app/src/main/res/drawable/mohammed.jpg new file mode 100644 index 0000000..c908ebf Binary files /dev/null and b/app/src/main/res/drawable/mohammed.jpg differ diff --git a/app/src/main/res/drawable/nawal.jpg b/app/src/main/res/drawable/nawal.jpg new file mode 100644 index 0000000..02d5f1d Binary files /dev/null and b/app/src/main/res/drawable/nawal.jpg differ diff --git a/app/src/main/res/drawable/orderconfirmed.png b/app/src/main/res/drawable/orderconfirmed.png new file mode 100644 index 0000000..67427cf Binary files /dev/null and b/app/src/main/res/drawable/orderconfirmed.png differ diff --git a/app/src/main/res/drawable/orderplaced.png b/app/src/main/res/drawable/orderplaced.png new file mode 100644 index 0000000..ff41806 Binary files /dev/null and b/app/src/main/res/drawable/orderplaced.png differ diff --git a/app/src/main/res/drawable/orderprocessed.png b/app/src/main/res/drawable/orderprocessed.png new file mode 100644 index 0000000..9b2c5cf Binary files /dev/null and b/app/src/main/res/drawable/orderprocessed.png differ diff --git a/app/src/main/res/drawable/readytopickup.png b/app/src/main/res/drawable/readytopickup.png new file mode 100644 index 0000000..3e49ce1 Binary files /dev/null and b/app/src/main/res/drawable/readytopickup.png differ diff --git a/app/src/main/res/drawable/shape_status_completed.xml b/app/src/main/res/drawable/shape_status_completed.xml new file mode 100644 index 0000000..da9c7bc --- /dev/null +++ b/app/src/main/res/drawable/shape_status_completed.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_status_current.xml b/app/src/main/res/drawable/shape_status_current.xml new file mode 100644 index 0000000..8ed365e --- /dev/null +++ b/app/src/main/res/drawable/shape_status_current.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/text_bg.xml b/app/src/main/res/drawable/text_bg.xml new file mode 100644 index 0000000..411121f --- /dev/null +++ b/app/src/main/res/drawable/text_bg.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/twitter.png b/app/src/main/res/drawable/twitter.png new file mode 100644 index 0000000..7dde94a Binary files /dev/null and b/app/src/main/res/drawable/twitter.png differ diff --git a/app/src/main/res/layout/activity_accessories.xml b/app/src/main/res/layout/activity_accessories.xml index a74ad80..09b9368 100644 --- a/app/src/main/res/layout/activity_accessories.xml +++ b/app/src/main/res/layout/activity_accessories.xml @@ -1,75 +1,75 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_admin.xml b/app/src/main/res/layout/activity_admin.xml index ab1a936..475f4e2 100644 --- a/app/src/main/res/layout/activity_admin.xml +++ b/app/src/main/res/layout/activity_admin.xml @@ -1,186 +1,186 @@ - - - - - - -