mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-13 09:48:47 +00:00
Share confirm base layout
This commit is contained in:
parent
167b369749
commit
722a5828ff
@ -0,0 +1,103 @@
|
||||
package com.example.listify;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.PersistableBundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import com.example.listify.data.ListShare;
|
||||
import com.example.listify.data.Picture;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Properties;
|
||||
|
||||
import static com.example.listify.MainActivity.am;
|
||||
|
||||
public class ConfirmShareView extends AppCompatActivity {
|
||||
@Override
|
||||
public void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState, @Nullable @org.jetbrains.annotations.Nullable PersistableBundle persistentState) {
|
||||
super.onCreate(savedInstanceState, persistentState);
|
||||
setContentView(R.layout.share_confirmation);
|
||||
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);
|
||||
Properties configs = new Properties();
|
||||
try {
|
||||
configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
||||
} catch (IOException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
SynchronousReceiver<Picture> profilePictureReceiver = new SynchronousReceiver<>();
|
||||
ImageView profilePictureView = findViewById(R.id.otherProfilePicture);
|
||||
try {
|
||||
requestor.getObject("profile", Picture.class, profilePictureReceiver);
|
||||
profilePictureView.setImageURI(Uri.fromFile(saveImage(profilePictureReceiver.await().getBase64EncodedImage(), "shareeProfilePicture")));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Button confirmShare = (Button) findViewById(R.id.confirmShare);
|
||||
Button cancelShare = (Button) findViewById(R.id.cancelShare);
|
||||
|
||||
confirmShare.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
ListShare listShare = new ListShare(listID, shareeEmail, "Read, Write, Delete, Share", null);
|
||||
try {
|
||||
requestor.putObject(listShare);
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cancelShare.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//TODO: return to prior view
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//From: https://stackoverflow.com/questions/30005815/convert-encoded-base64-image-to-file-object-in-android
|
||||
public File saveImage(final String imageData, String prefix) throws IOException {
|
||||
final byte[] imgBytesData = android.util.Base64.decode(imageData,
|
||||
android.util.Base64.DEFAULT);
|
||||
|
||||
final File file = File.createTempFile(prefix, null, this.getCacheDir());
|
||||
final FileOutputStream fileOutputStream;
|
||||
try {
|
||||
fileOutputStream = new FileOutputStream(file);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
final BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(
|
||||
fileOutputStream);
|
||||
try {
|
||||
bufferedOutputStream.write(imgBytesData);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} finally {
|
||||
try {
|
||||
bufferedOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
}
|
||||
@ -72,6 +72,7 @@ public class ListSharees extends AppCompatActivity implements Requestor.Receiver
|
||||
ListShare sharee = (ListShare) delivered;
|
||||
|
||||
if(sharee != null) {
|
||||
//should have lShareeEntries line here
|
||||
lShareeEmails.add(sharee.getShareWithEmail());
|
||||
|
||||
if(sharee.getEntries() != null) {
|
||||
|
||||
@ -184,7 +184,7 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
ImageView profilePictureView = navigationView.getHeaderView(0).findViewById(R.id.imageViewProfilePicture);
|
||||
try {
|
||||
requestor.getObject("profile", Picture.class, profilePictureReceiver);
|
||||
profilePictureView.setImageURI(Uri.fromFile(saveImage(profilePictureReceiver.await().getBase64EncodedImage())));
|
||||
profilePictureView.setImageURI(Uri.fromFile(saveImage(profilePictureReceiver.await().getBase64EncodedImage(), "profilePicture")));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -241,11 +241,11 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
}
|
||||
|
||||
//From: https://stackoverflow.com/questions/30005815/convert-encoded-base64-image-to-file-object-in-android
|
||||
private File saveImage(final String imageData) throws IOException {
|
||||
public File saveImage(final String imageData, String prefix) throws IOException {
|
||||
final byte[] imgBytesData = android.util.Base64.decode(imageData,
|
||||
android.util.Base64.DEFAULT);
|
||||
|
||||
final File file = File.createTempFile("profilePicture", null, this.getCacheDir());
|
||||
final File file = File.createTempFile(prefix, null, this.getCacheDir());
|
||||
final FileOutputStream fileOutputStream;
|
||||
try {
|
||||
fileOutputStream = new FileOutputStream(file);
|
||||
|
||||
@ -1,28 +1,18 @@
|
||||
package com.example.listify.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.chauthai.swipereveallayout.SwipeRevealLayout;
|
||||
import com.chauthai.swipereveallayout.ViewBinderHelper;
|
||||
import com.example.listify.AuthManager;
|
||||
import com.example.listify.ListPage;
|
||||
import com.example.listify.ListSharees;
|
||||
import com.example.listify.R;
|
||||
import com.example.listify.Requestor;
|
||||
import com.example.listify.*;
|
||||
import com.example.listify.data.List;
|
||||
import com.example.listify.data.ListShare;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
71
Listify/app/src/main/res/layout/share_confirmation.xml
Normal file
71
Listify/app/src/main/res/layout/share_confirmation.xml
Normal file
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="700dp"
|
||||
android:gravity="bottom"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="40dp"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark">
|
||||
|
||||
<TextView android:layout_width="match_parent"
|
||||
android:layout_height="120dp"
|
||||
android:text="Please confirm sharing with the below user:"
|
||||
android:textSize="30dp"
|
||||
android:textColor="#80000000"
|
||||
/>
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="96dp"
|
||||
android:layout_height="96dp"
|
||||
android:elevation="400dp"
|
||||
android:id="@+id/otherProfilePictureWrapper"
|
||||
app:cardCornerRadius="48dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:background="#80000000">
|
||||
<ImageView
|
||||
android:layout_height="96dp"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/otherProfilePicture"
|
||||
android:src="@raw/ic_launcher_round"
|
||||
android:scaleType="centerCrop"
|
||||
android:background="#80000000"/>
|
||||
</androidx.cardview.widget.CardView>
|
||||
<TextView android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:id="@+id/shareeEmailView"
|
||||
android:text="user@email.com"
|
||||
android:textSize="25dp"
|
||||
android:textColor="#80000000"
|
||||
android:textAlignment="center"
|
||||
android:layout_gravity="center_horizontal"
|
||||
|
||||
/>
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_height="250dp"
|
||||
android:layout_width="match_parent" />
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_height="50dp"
|
||||
android:layout_width="match_parent" >
|
||||
<Button android:layout_width="150dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="left"
|
||||
android:text="Cancel"
|
||||
android:textSize="25dp"
|
||||
android:background="#80800000"
|
||||
android:id="@+id/cancelShare"
|
||||
|
||||
/>
|
||||
<Button android:layout_width="150dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right"
|
||||
android:text="Confirm"
|
||||
android:textSize="25dp"
|
||||
android:background="#80008000"
|
||||
android:id="@+id/confirmShare"
|
||||
/>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
</LinearLayout>
|
||||
Loading…
Reference in New Issue
Block a user