Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
Binary file modified .idea/caches/gradle_models.ser
Binary file not shown.
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ dependencies {
implementation 'com.amazonaws:aws-android-sdk-s3:2.15.+'
implementation('com.amazonaws:aws-android-sdk-mobile-client:2.15.+@aar') { transitive = true }
implementation('com.amazonaws:aws-android-sdk-auth-userpools:2.15.+@aar') { transitive = true }
//picasso
implementation 'com.squareup.picasso:picasso:2.71828'



// CameraX core library
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".UserProfile" />

</application>

Expand Down
12 changes: 9 additions & 3 deletions app/src/main/java/com/javaawesome/tag/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import static android.Manifest.permission.ACCESS_FINE_LOCATION;

public class MainActivity extends AppCompatActivity implements SessionAdapter.OnSessionInteractionListener {

protected static String photoBucketPath = "https://javatag091c7e33ab0441e4bdf34cbdf68d2bd1-local.s3-us-west-2.amazonaws.com/";
private final String TAG = "javatag";
RecyclerView recyclerNearbySessions;
SessionAdapter sessionAdapter;
Expand Down Expand Up @@ -162,14 +162,17 @@ public void onFailure(@Nonnull ApolloException e) {
///////////// Go to user page ///////////////////
public void goToUserPage(View view){
Intent goToUserPage = new Intent(this, UserProfile.class);
this.startActivity(goToUserPage);
this.startActivity(goToUserPage.putExtra("playerId",playerId));
}

//////// TEST BUTTON /////
public void onTestyClick(View view) {
startActivity(new Intent(MainActivity.this, NotificationActivity.class));
}




// Direct users to sign in page
private void signInUser() {
AWSMobileClient.getInstance().showSignIn(MainActivity.this,
Expand Down Expand Up @@ -327,13 +330,16 @@ private void createPlayer() {
.lon(currentUserLocation.longitude)
.username(AWSMobileClient.getInstance().getUsername())
.isIt(false)
.photo(MainActivity.photoBucketPath + "avatar.png")
.build();
CreatePlayerMutation createPlayerMutation = CreatePlayerMutation.builder().input(input).build();
awsAppSyncClient.mutate(createPlayerMutation).enqueue(new GraphQLCall.Callback<CreatePlayerMutation.Data>() {
@Override
public void onResponse(@Nonnull Response<CreatePlayerMutation.Data> response) {
Log.i(TAG, "created a player");

playerId = response.data().createPlayer().id();
Log.i(TAG, "created a player"+ playerId);

}

@Override
Expand Down
13 changes: 9 additions & 4 deletions app/src/main/java/com/javaawesome/tag/MapsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public void onLocationResult(LocationResult locationResult) {

updateMarkerAndCircleForAllPlayers(players);
sendUserLocationQuery(locationResult);

}
};
}
Expand Down Expand Up @@ -236,10 +237,10 @@ public void handleMessage (Message inputMessage) {
//if the player is in the session, but not in the player list, then make a new player and add them to the players list and add a marker
if(contains == false){
Marker marker = mMap.addMarker(new MarkerOptions()
.position(new LatLng(updatePlayer.lat(), updatePlayer.lon()))
.title(updatePlayer.username()));
.position(player.getLastLocation())
.title(player.getUsername()));
Circle circle = mMap.addCircle(new CircleOptions()
.center(new LatLng(updatePlayer.lat(), updatePlayer.lon()))
.center(player.getLastLocation())
.radius(tagDistance)
.fillColor(Color.TRANSPARENT)
.strokeWidth(3));
Expand Down Expand Up @@ -640,7 +641,11 @@ public void onResponse(@Nonnull final Response<GetSessionQuery.Data> response) {
Log.i(TAG, "Starting point is " + startingPoint);

//once the session ID and starting loc are in place, then make the first player.
queryForPlayerObject();
if (playerID == null) {
createPlayer();
} else {
queryForPlayerObject();
}

Log.i(TAG, "Made it to the after the if/else within getSessionCallBack");
//converting from GetSessionItems to players
Expand Down
69 changes: 65 additions & 4 deletions app/src/main/java/com/javaawesome/tag/ShowMeYourFace.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,47 @@
import android.widget.ImageView;
import android.widget.Toast;

import com.amazonaws.amplify.generated.graphql.GetPlayerQuery;
import com.amazonaws.amplify.generated.graphql.UpdatePlayerMutation;
import com.amazonaws.mobile.client.AWSMobileClient;
import com.amazonaws.mobile.config.AWSConfiguration;
import com.amazonaws.mobileconnectors.appsync.AWSAppSyncClient;
import com.amazonaws.mobileconnectors.appsync.fetcher.AppSyncResponseFetchers;
import com.amazonaws.mobileconnectors.s3.transferutility.TransferListener;
import com.amazonaws.mobileconnectors.s3.transferutility.TransferObserver;
import com.amazonaws.mobileconnectors.s3.transferutility.TransferState;
import com.amazonaws.mobileconnectors.s3.transferutility.TransferUtility;
import com.amazonaws.services.s3.AmazonS3Client;
import com.apollographql.apollo.GraphQLCall;
import com.apollographql.apollo.api.Response;
import com.apollographql.apollo.exception.ApolloException;
import com.google.android.material.floatingactionbutton.FloatingActionButton;

import java.io.File;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

import javax.annotation.Nonnull;

import type.UpdatePlayerInput;


public class ShowMeYourFace extends AppCompatActivity {
private static final String TAG = "ahren:javatag";
private static boolean upload = false;
private ImageCapture imageCapture;
final CameraX.LensFacing camera = CameraX.LensFacing.FRONT;

// set to absolute path eventualy
String profPicPath = null;
//
String s3path = null;
String userPhoto;
AWSAppSyncClient mAWSAppSyncClient;
// created by picSnap
File profilePic = null;


public static boolean isUpload() {
return upload;
}
Expand All @@ -69,6 +85,7 @@ protected void onResume() {
super.onResume();
if(upload && profPicPath != null && profilePic != null){
uploadDataToS3(s3path, profilePic);
// update photo in Dynamo
finish();
}
}
Expand Down Expand Up @@ -97,14 +114,14 @@ protected void onCreate(Bundle savedInstanceState) {
} else {
// No explanation needed; request the permission
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.CAMERA},
new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE},
1);
}
}else {

//************************************ Setup Buttons **********************************************
FloatingActionButton picSnap = findViewById(R.id.picSnap);
// FloatingActionButton switchCamera = findViewById(R.id.fab_switch_camera);
// FloatingActionButton switchCamera = findViewById(R.id.fab_switch_camera);,
// FloatingActionButton fab_flash = findViewById(R.id.fab_flash);

// ********************************** Setup Camera **********************************************
Expand All @@ -113,6 +130,7 @@ protected void onCreate(Bundle savedInstanceState) {
//*************************************** Shutter Button Action ****************************************

picSnap.setOnClickListener(event -> {
// put picture localy in the phone
s3path = AWSMobileClient.getInstance().getUsername()+ "profilePic.png";
profilePic = new File(Environment.getExternalStorageDirectory() + "/" + s3path);
//
Expand Down Expand Up @@ -254,8 +272,9 @@ public void onStateChanged(int id, TransferState state) {
upload=false;
Log.i(TAG, "onStateChanged: Uploaded Profile Pic");
Toast.makeText(getBaseContext(), "Picture Save Complete",Toast.LENGTH_LONG).show();
String bucketPath = uploadObserver.getBucket() +"/" +uploadObserver.getKey();
Log.i(TAG, "onStateChanged: " + bucketPath + "*************************************************************************");
String imgUrl = MainActivity.photoBucketPath + uploadObserver.getKey();
Log.i(TAG, "onStateChanged: " + imgUrl + "*************************************************************************");
updatePlayerInput(imgUrl);
}
}
@Override
Expand All @@ -273,6 +292,48 @@ public void onError(int id, Exception ex) {
});
}


private void updatePlayerInput(String imgURL){
Log.i(TAG, "created a player"+ getIntent().getStringExtra("playerId"));
UpdatePlayerInput updatePlayerInput = UpdatePlayerInput.builder()
.id(getIntent().getStringExtra("playerId"))
.photo(imgURL)
.build();

UpdatePlayerMutation updatePlayerMutation = UpdatePlayerMutation.builder()
.input(updatePlayerInput).build();
mAWSAppSyncClient.mutate(updatePlayerMutation)
.enqueue(new GraphQLCall.Callback<UpdatePlayerMutation.Data>() {
@Override
public void onResponse(@Nonnull Response<UpdatePlayerMutation.Data> response) {
Log.i(TAG, "update success");

}

@Override
public void onFailure(@Nonnull ApolloException e) {
Log.e(TAG, "update not successful");
}
});
}
// private void queryForPlayerObject(String playerId) {
// GetPlayerQuery query = GetPlayerQuery.builder().id(playerId).build();
// mAWSAppSyncClient.query(query)
// .responseFetcher(AppSyncResponseFetchers.NETWORK_ONLY)
// .enqueue(new GraphQLCall.Callback<GetPlayerQuery.Data>() {
// @Override
// public void onResponse(@Nonnull Response<GetPlayerQuery.Data> response) {
// Log.i(TAG, "made it to making a query for player object");
// userPhoto = response.data().getPlayer().Photo(profile pic);
// }
//
// @Override
// public void onFailure(@Nonnull ApolloException e) {
//
// }
// });
// }

}
//// **************** Checks to see if flash is present on the current camera and *********************
// try {
Expand Down
71 changes: 68 additions & 3 deletions app/src/main/java/com/javaawesome/tag/UserProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,85 @@

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

public class UserProfile extends AppCompatActivity {
import com.amazonaws.amplify.generated.graphql.GetPlayerQuery;
import com.amazonaws.mobile.client.AWSMobileClient;
import com.amazonaws.mobile.config.AWSConfiguration;
import com.amazonaws.mobileconnectors.appsync.AWSAppSyncClient;
import com.amazonaws.mobileconnectors.appsync.fetcher.AppSyncResponseFetchers;
import com.apollographql.apollo.GraphQLCall;
import com.apollographql.apollo.api.Response;
import com.apollographql.apollo.exception.ApolloException;
import com.squareup.picasso.Picasso;

import javax.annotation.Nonnull;

public class UserProfile extends AppCompatActivity {
AWSAppSyncClient awsAppSyncClient;
String userPhoto;
String TAG = "ahren:UserProfile";
ImageView profPic;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_profile);
}

// establish connection to AWS
awsAppSyncClient = AWSAppSyncClient.builder()
.context(getApplicationContext())
.awsConfiguration(new AWSConfiguration(getApplicationContext()))
.build();

queryForPlayerObject(getIntent().getStringExtra("playerId"));


profPic = findViewById(R.id.profilePicture);
Log.i(TAG, "onCreate: "+userPhoto);




TextView username = findViewById(R.id.UserName);
username.setText(AWSMobileClient.getInstance().getUsername());
}
///////////// Turn on Camera ///////////////////
public void goToCameraClass(View view){
Intent goToCamera = new Intent(this, ShowMeYourFace.class);
this.startActivity(goToCamera);
this.startActivity(goToCamera.putExtra("playerId",getIntent().getStringExtra("playerId")));
}
private void queryForPlayerObject(String playerId) {
GetPlayerQuery query = GetPlayerQuery.builder().id(playerId).build();
awsAppSyncClient.query(query)
.responseFetcher(AppSyncResponseFetchers.NETWORK_ONLY)
.enqueue(new GraphQLCall.Callback<GetPlayerQuery.Data>() {
@Override
public void onResponse(@Nonnull Response<GetPlayerQuery.Data> response) {
Log.i(TAG, "made it to making a query for player object");
userPhoto = response.data().getPlayer().Photo();

Handler h = new Handler(Looper.getMainLooper()){
@Override
public void handleMessage (Message inputMessage) {
Log.i(TAG, "handleMessage: getting photo***********************************************************************");
Picasso.get().load(userPhoto).into(profPic);
Log.i(TAG, "handleMessage: "+userPhoto);
}
};
h.obtainMessage().sendToTarget();
}

@Override
public void onFailure(@Nonnull ApolloException e) {

}
});
}
}

1 change: 0 additions & 1 deletion app/src/main/java/com/javaawesome/tag/picturePreview.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ protected void onCreate(Bundle savedInstanceState) {
String TAG = "ahren:picturePreview";
ImageView profilePicPreview;
Log.i(TAG, "onCreate: hello");
//TODO look at passing in the file and uploading here rather than
ImageView pic = findViewById(R.id.profilePicPreview);
String picPath = getIntent().getStringExtra("picpath");
pic.setImageURI(Uri.parse(picPath));
Expand Down
Binary file added app/src/main/res/drawable/avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 2 additions & 6 deletions app/src/main/res/layout/activity_user_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".UserProfile">

<TextView
android:id="@+id/UserName"
android:layout_width="wrap_content"
Expand All @@ -15,26 +14,23 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/cameraButton"
android:layout_width="75dp"
android:layout_height="75dp"
android:background="@drawable/photo_camera"
android:onClick="goToCameraClass"
app:layout_constraintBottom_toTopOf="@+id/imageView"
app:layout_constraintBottom_toTopOf="@+id/profilePicture"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/UserName" />

<ImageView
android:id="@+id/imageView"
android:id="@+id/profilePicture"
android:layout_width="195dp"
android:layout_height="259dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cameraButton"
tools:srcCompat="@tools:sample/avatars" />

</androidx.constraintlayout.widget.ConstraintLayout>