mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-13 09:48:47 +00:00
Merge pull request #159 from ClaytonWWilson/share-confirm-done
Finish share confirmation page
This commit is contained in:
commit
e40eceb0c2
@ -19,10 +19,14 @@ public class PictureGetter implements CallHandler {
|
||||
@Override
|
||||
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryMap, String cognitoID) throws SQLException {
|
||||
PreparedStatement statement = connection.prepareStatement(GET_ITEM);
|
||||
if (!queryMap.containsKey("id") || !queryMap.get("id").toString().equals("profile")) {
|
||||
throw new IllegalArgumentException("Only profile pictures are currently supported.");
|
||||
if (!queryMap.containsKey("id")) {
|
||||
throw new IllegalArgumentException("Must have id set.");
|
||||
}
|
||||
if (queryMap.get("id").equals("profile")) {
|
||||
statement.setString(1, cognitoID);
|
||||
} else {
|
||||
statement.setString(1, queryMap.get("id"));
|
||||
}
|
||||
statement.setString(1, cognitoID);
|
||||
System.out.println(statement);
|
||||
ResultSet queryResults = statement.executeQuery();
|
||||
queryResults.first();
|
||||
|
||||
@ -28,6 +28,9 @@ public class UserGetter implements CallHandler {
|
||||
System.out.println(userPoolId);
|
||||
ListUsersRequest checkRequest = new ListUsersRequest().withUserPoolId(userPoolId);
|
||||
Object emailObject = bodyMap.get("emailToCheck");
|
||||
if (queryMap.get("id").contains("@")) {
|
||||
emailObject = queryMap.get("id");
|
||||
}
|
||||
String attributeToGet = "sub";
|
||||
if (emailObject != null) {
|
||||
checkRequest.setFilter("email=\"" + emailObject.toString() +"\"");
|
||||
|
||||
@ -57,6 +57,14 @@
|
||||
<activity android:name="com.example.listify.ui.ForgotPasswordPage" />
|
||||
<activity android:name="com.example.listify.ListPage" />
|
||||
<activity android:name="com.example.listify.ListSharees" />
|
||||
<activity android:name="com.example.listify.ConfirmShareView">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.CONFIRM_SHARE" />
|
||||
|
||||
<!-- <category android:name="android.intent.category.DEFAULT" />-->
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@ -1,8 +1,8 @@
|
||||
package com.example.listify;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.PersistableBundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
@ -11,6 +11,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import com.example.listify.data.ListShare;
|
||||
import com.example.listify.data.Picture;
|
||||
import com.example.listify.data.User;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.*;
|
||||
@ -20,12 +21,12 @@ import static com.example.listify.MainActivity.am;
|
||||
|
||||
public class ConfirmShareView extends AppCompatActivity {
|
||||
@Override
|
||||
public void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState, @Nullable @org.jetbrains.annotations.Nullable PersistableBundle persistentState) {
|
||||
super.onCreate(savedInstanceState, persistentState);
|
||||
public void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.share_confirmation);
|
||||
System.out.println("Got to confirm view");
|
||||
TextView shareeEmailView = findViewById(R.id.shareeEmailView);
|
||||
final String shareeEmail = (String) getIntent().getSerializableExtra("shareeEmail");
|
||||
final String shareeID = (String) getIntent().getSerializableExtra("shareeID");
|
||||
final Integer listID = (Integer) getIntent().getSerializableExtra("listID");
|
||||
|
||||
shareeEmailView.setText(shareeEmail);
|
||||
@ -37,9 +38,12 @@ public class ConfirmShareView extends AppCompatActivity {
|
||||
}
|
||||
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
SynchronousReceiver<Picture> profilePictureReceiver = new SynchronousReceiver<>();
|
||||
SynchronousReceiver<User> userReceiver = new SynchronousReceiver<>();
|
||||
ImageView profilePictureView = findViewById(R.id.otherProfilePicture);
|
||||
try {
|
||||
requestor.getObject("profile", Picture.class, profilePictureReceiver);
|
||||
requestor.getObject(shareeEmail, User.class, userReceiver);
|
||||
String shareeID = userReceiver.await().getCognitoID();
|
||||
requestor.getObject(shareeID, Picture.class, profilePictureReceiver);
|
||||
profilePictureView.setImageURI(Uri.fromFile(saveImage(profilePictureReceiver.await().getBase64EncodedImage(), "shareeProfilePicture")));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -58,6 +62,12 @@ public class ConfirmShareView extends AppCompatActivity {
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Intent data = new Intent();
|
||||
data.putExtra("listID", listID);
|
||||
data.putExtra("shareeEmail", shareeEmail);
|
||||
setResult(RESULT_OK,data);
|
||||
finish();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@ -65,7 +75,8 @@ public class ConfirmShareView extends AppCompatActivity {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//TODO: return to prior view
|
||||
}
|
||||
setResult(RESULT_CANCELED,null);
|
||||
finish(); }
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.example.listify;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -29,6 +30,8 @@ public class ListSharees extends AppCompatActivity implements Requestor.Receiver
|
||||
ArrayList<ListShare> lShareeEntries = new ArrayList<>();
|
||||
ArrayList<String> lShareeEmails = new ArrayList<>();
|
||||
|
||||
private final int CONFIRM_REQUEST_CODE = 1;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -55,20 +58,31 @@ public class ListSharees extends AppCompatActivity implements Requestor.Receiver
|
||||
public void onClick(View v) {
|
||||
EditText sharedEmailText = (EditText) findViewById(R.id.editTextShareeEmail);
|
||||
String sharedEmail = sharedEmailText.getText().toString();
|
||||
ListShare listShare = new ListShare(listID, sharedEmail, "Read, Write, Delete, Share", null);
|
||||
try {
|
||||
requestor.putObject(listShare);
|
||||
lShareeEntries.add(listShare);
|
||||
lShareeEmails.add(sharedEmail);
|
||||
myAdapter.notifyDataSetChanged();
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Intent confirmIntent = new Intent(ListSharees.this, ConfirmShareView.class);
|
||||
confirmIntent.putExtra("listID", listID);
|
||||
confirmIntent.putExtra("shareeEmail", sharedEmail);
|
||||
startActivityForResult(confirmIntent, CONFIRM_REQUEST_CODE);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == CONFIRM_REQUEST_CODE) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
Integer listID = data.getIntExtra("listID", -1);
|
||||
String shareeEmail = data.getStringExtra("shareeEmail");
|
||||
ListShare listShare = new ListShare(listID, shareeEmail, "Read, Write, Delete, Share", null);
|
||||
lShareeEntries.add(listShare);
|
||||
lShareeEmails.add(shareeEmail);
|
||||
myAdapter.notifyDataSetChanged();
|
||||
|
||||
} else { //resultCode == RESULT_CANCELED
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptDelivery(Object delivered) {
|
||||
ListShare sharee = (ListShare) delivered;
|
||||
|
||||
@ -13,6 +13,7 @@ import com.chauthai.swipereveallayout.SwipeRevealLayout;
|
||||
import com.chauthai.swipereveallayout.ViewBinderHelper;
|
||||
import com.example.listify.*;
|
||||
import com.example.listify.data.List;
|
||||
import com.example.listify.data.ListShare;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
android:layout_height="120dp"
|
||||
android:text="Please confirm sharing with the below user:"
|
||||
android:textSize="30dp"
|
||||
android:textColor="#80000000"
|
||||
android:textColor="#FF000000"
|
||||
/>
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="96dp"
|
||||
@ -38,7 +38,7 @@
|
||||
android:id="@+id/shareeEmailView"
|
||||
android:text="user@email.com"
|
||||
android:textSize="25dp"
|
||||
android:textColor="#80000000"
|
||||
android:textColor="#FF000000"
|
||||
android:textAlignment="center"
|
||||
android:layout_gravity="center_horizontal"
|
||||
|
||||
@ -54,7 +54,7 @@
|
||||
android:layout_gravity="left"
|
||||
android:text="Cancel"
|
||||
android:textSize="25dp"
|
||||
android:background="#80800000"
|
||||
android:background="#FF800000"
|
||||
android:id="@+id/cancelShare"
|
||||
|
||||
/>
|
||||
@ -63,9 +63,11 @@
|
||||
android:layout_gravity="right"
|
||||
android:text="Confirm"
|
||||
android:textSize="25dp"
|
||||
android:background="#80008000"
|
||||
android:background="#FF008000"
|
||||
android:id="@+id/confirmShare"
|
||||
/>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_height="70dp"
|
||||
android:layout_width="match_parent" />
|
||||
</LinearLayout>
|
||||
Loading…
Reference in New Issue
Block a user