|
@@ -5,6 +5,7 @@ import android.app.Activity;
|
|
|
import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.Message;
|
|
|
import android.text.TextUtils;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.MenuItem;
|
|
@@ -20,6 +21,9 @@ import androidx.annotation.Nullable;
|
|
|
import androidx.appcompat.app.AlertDialog;
|
|
|
import androidx.fragment.app.DialogFragment;
|
|
|
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
+
|
|
|
public class messageCreateFragment extends DialogFragment implements PopupMenu.OnMenuItemClickListener {
|
|
|
|
|
|
public static final String EXTRA_TO = "com.example.android.namelistsql.NAME";
|
|
@@ -28,21 +32,25 @@ public class messageCreateFragment extends DialogFragment implements PopupMenu.O
|
|
|
public static final String EXTRA_MESSAGE = "com.example.android.namelistsql.MESSAGE";
|
|
|
public static final String EXTRA_DATE = "com.example.android.namelistsql.DATE";
|
|
|
|
|
|
- private EditText sendingAddressObject;
|
|
|
- private EditText receivingAddressObject;
|
|
|
- private EditText subjectObject;
|
|
|
- private EditText messageBodyObject;
|
|
|
+ public EditText sendingAddressObject;
|
|
|
+ public EditText receivingAddressObject;
|
|
|
+ public EditText subjectObject;
|
|
|
+ public EditText messageBodyObject;
|
|
|
|
|
|
public static final int RESULT_CANCELED = 0;
|
|
|
public static final int RESULT_OK = -1;
|
|
|
|
|
|
- Activity activity = new Activity();
|
|
|
+ public Activity activity = new Activity();
|
|
|
+ public static Intent replyIntent = new Intent();
|
|
|
|
|
|
static messageCreateFragment newInstance() {
|
|
|
return new messageCreateFragment();
|
|
|
}
|
|
|
private AlertDialog dialog;
|
|
|
|
|
|
+ private static final int NUMBER_OF_THREADS = 4;
|
|
|
+ static final ExecutorService databaseWriteExecutor =
|
|
|
+ Executors.newFixedThreadPool(NUMBER_OF_THREADS);
|
|
|
|
|
|
|
|
|
// set theming style
|
|
@@ -79,23 +87,11 @@ public class messageCreateFragment extends DialogFragment implements PopupMenu.O
|
|
|
|
|
|
|
|
|
/* dosen't wotk cause Activity is not extendet and used as variable */
|
|
|
- sendButton.setOnClickListener(View -> {
|
|
|
- Intent replyIntent = new Intent();
|
|
|
- if (TextUtils.isEmpty(sendingAddressObject.getText())) {
|
|
|
- activity.setResult(RESULT_CANCELED, replyIntent);
|
|
|
- } else {
|
|
|
- String from = sendingAddressObject.getText().toString();
|
|
|
- String to = receivingAddressObject.getText().toString();
|
|
|
- String subject = subjectObject.getText().toString();
|
|
|
- String message = messageBodyObject.getText().toString();
|
|
|
- replyIntent.putExtra(EXTRA_FROM, from);
|
|
|
- replyIntent.putExtra(EXTRA_TO, to);
|
|
|
- replyIntent.putExtra(EXTRA_SUBJECT, subject);
|
|
|
- replyIntent.putExtra(EXTRA_MESSAGE, message);
|
|
|
- activity.setResult(RESULT_OK, replyIntent);
|
|
|
- }
|
|
|
- activity.finish();
|
|
|
- });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
// TODO: add cc + bcc functionality
|
|
|
|
|
@@ -117,18 +113,41 @@ public class messageCreateFragment extends DialogFragment implements PopupMenu.O
|
|
|
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
|
|
|
alertDialogBuilder.setTitle("Warning");
|
|
|
alertDialogBuilder
|
|
|
- .setMessage("Do you really want to cancel?")
|
|
|
+ .setMessage("Do you want to save your Draft?")
|
|
|
.setCancelable(false)
|
|
|
.setPositiveButton("Yes",new DialogInterface.OnClickListener() {
|
|
|
public void onClick(DialogInterface dialog, int id) {
|
|
|
+
|
|
|
+ activity.setResult(RESULT_CANCELED, replyIntent);
|
|
|
+
|
|
|
+ String from = sendingAddressObject.getText().toString();
|
|
|
+ String to = receivingAddressObject.getText().toString();
|
|
|
+ String subject = subjectObject.getText().toString();
|
|
|
+ String message = messageBodyObject.getText().toString();
|
|
|
+
|
|
|
+
|
|
|
+ replyIntent.putExtra(EXTRA_FROM, from);
|
|
|
+ replyIntent.putExtra(EXTRA_TO, to);
|
|
|
+ replyIntent.putExtra(EXTRA_SUBJECT, subject);
|
|
|
+ replyIntent.putExtra(EXTRA_MESSAGE, message);
|
|
|
+ activity.setResult(RESULT_OK, replyIntent);
|
|
|
+
|
|
|
+ activity.finish();
|
|
|
+
|
|
|
+ Toast.makeText(getContext(), "messageCreateFragmentReadIn", Toast.LENGTH_SHORT).show();
|
|
|
+ Toast.makeText(getContext(), replyIntent.getStringExtra(EXTRA_FROM), Toast.LENGTH_SHORT).show();
|
|
|
+
|
|
|
+ Intent intent = new Intent(getContext(), NewDraftMessageActivity.class);
|
|
|
+ startActivityForResult(intent, MainActivity.NEW_WORD_ACTIVITY_REQUEST_CODE);
|
|
|
+
|
|
|
// if this button is clicked, close the whole fragment
|
|
|
dismiss();
|
|
|
}
|
|
|
})
|
|
|
.setNegativeButton("No",new DialogInterface.OnClickListener() {
|
|
|
public void onClick(DialogInterface dialog,int id) {
|
|
|
- // if this button is clicked, just close the dialog box
|
|
|
- dialog.cancel();
|
|
|
+ // if this button is clicked, close the hole fragment
|
|
|
+ dismiss();
|
|
|
}
|
|
|
});
|
|
|
|