alert dialog when you try remove a receiver
This commit is contained in:
parent
30fb32194b
commit
aea9fece30
|
@ -148,6 +148,7 @@ public class Messages extends Module {
|
||||||
intent.putExtra("receivers", arrayReceivers);
|
intent.putExtra("receivers", arrayReceivers);
|
||||||
intent.putExtra("receiversNames", arrayReceiversNames);
|
intent.putExtra("receiversNames", arrayReceiversNames);
|
||||||
intent.putExtra("receiversPhotos", arrayPhotos);
|
intent.putExtra("receiversPhotos", arrayPhotos);
|
||||||
|
Log.d(TAG, "Receivers of Messages: " + receivers);
|
||||||
startActivityForResult(intent, Constants.SEARCH_USERS_REQUEST_CODE);
|
startActivityForResult(intent, Constants.SEARCH_USERS_REQUEST_CODE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -310,7 +311,7 @@ public class Messages extends Module {
|
||||||
receivers += arrayReceivers.get(i) + ", ";
|
receivers += arrayReceivers.get(i) + ", ";
|
||||||
receiversNames += arrayReceiversNames.get(i) + ",\n";
|
receiversNames += arrayReceiversNames.get(i) + ",\n";
|
||||||
}
|
}
|
||||||
Log.d(TAG, "Nickname Receivers: " + receivers);
|
Log.d(TAG, "Receivers of SearchUsers: " + receivers);
|
||||||
writeData();
|
writeData();
|
||||||
|
|
||||||
layout.removeAllViewsInLayout();
|
layout.removeAllViewsInLayout();
|
||||||
|
@ -321,7 +322,7 @@ public class Messages extends Module {
|
||||||
|
|
||||||
final LinearLayout linearLayout = (LinearLayout) inflater.inflate(id, null, false);
|
final LinearLayout linearLayout = (LinearLayout) inflater.inflate(id, null, false);
|
||||||
|
|
||||||
TextView textName = (TextView) linearLayout.findViewById(R.id.textName);
|
final TextView textName = (TextView) linearLayout.findViewById(R.id.textName);
|
||||||
textName.setText(arrayReceiversNames.get(i).toString());
|
textName.setText(arrayReceiversNames.get(i).toString());
|
||||||
|
|
||||||
final TextView textNickname = (TextView) linearLayout.findViewById(R.id.textNickname);
|
final TextView textNickname = (TextView) linearLayout.findViewById(R.id.textNickname);
|
||||||
|
@ -349,11 +350,7 @@ public class Messages extends Module {
|
||||||
ImageButton button = (ImageButton)linearLayout.findViewById(R.id.buttonDelete);
|
ImageButton button = (ImageButton)linearLayout.findViewById(R.id.buttonDelete);
|
||||||
button.setOnClickListener( new View.OnClickListener() {
|
button.setOnClickListener( new View.OnClickListener() {
|
||||||
public void onClick(View view){
|
public void onClick(View view){
|
||||||
layout.removeView(linearLayout);
|
showDialogDelete(linearLayout, textNickname, textName.getText().toString());
|
||||||
int position = arrayReceivers.indexOf(textNickname.getText().toString());
|
|
||||||
arrayReceivers.remove(position);
|
|
||||||
arrayReceiversNames.remove(position);
|
|
||||||
arrayPhotos.remove(position);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -372,7 +369,7 @@ public class Messages extends Module {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.action_sendMsg:
|
case R.id.action_sendMsg:
|
||||||
try {
|
try {
|
||||||
if((eventCode == 0) && (rcvEditText.getText().length() == 0)) {
|
if((eventCode == 0) && (receivers.length() == 0)) {
|
||||||
Toast.makeText(this, R.string.noReceiversMsg, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, R.string.noReceiversMsg, Toast.LENGTH_LONG).show();
|
||||||
} else if(subjEditText.getText().length() == 0) {
|
} else if(subjEditText.getText().length() == 0) {
|
||||||
Toast.makeText(this, R.string.noSubjectMessageMsg, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, R.string.noSubjectMessageMsg, Toast.LENGTH_LONG).show();
|
||||||
|
@ -418,4 +415,34 @@ public class Messages extends Module {
|
||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showDialogDelete(final LinearLayout linearLayout, final TextView textNickname, String textName){
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(Messages.this);
|
||||||
|
builder.setTitle(R.string.areYouSure);
|
||||||
|
String dialog = getResources().getString(R.string.cancelRemoveReceivers);
|
||||||
|
dialog = dialog.replaceAll("#nameUser#", textName);
|
||||||
|
builder.setMessage(dialog);
|
||||||
|
|
||||||
|
builder.setNegativeButton(getString(R.string.cancelMsg), new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.setPositiveButton(getString(R.string.acceptMsg), new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
layout.removeView(linearLayout);
|
||||||
|
int position = arrayReceivers.indexOf(textNickname.getText().toString());
|
||||||
|
arrayReceivers.remove(position);
|
||||||
|
arrayReceiversNames.remove(position);
|
||||||
|
arrayPhotos.remove(position);
|
||||||
|
receivers = "";
|
||||||
|
for(int i=0; i<arrayReceivers.size(); i++){
|
||||||
|
receivers += arrayReceivers.get(i) + ", ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AlertDialog alert = builder.create();
|
||||||
|
alert.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,5 +326,6 @@
|
||||||
<string name="introduceLongerText">Introduzca un texto más largo</string>
|
<string name="introduceLongerText">Introduzca un texto más largo</string>
|
||||||
<string name="cancelSendMessage">Va a cancelar el envío del mensaje</string>
|
<string name="cancelSendMessage">Va a cancelar el envío del mensaje</string>
|
||||||
<string name="cancelSendReceivers">Va a cancelar los destinatarios seleccionados</string>
|
<string name="cancelSendReceivers">Va a cancelar los destinatarios seleccionados</string>
|
||||||
|
<string name="cancelRemoveReceivers">¿Quiere quitar a #nameUser# de la lista de destinatarios?</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
|
@ -336,5 +336,6 @@
|
||||||
<string name="introduceLongerText">Introduce a longer text</string>
|
<string name="introduceLongerText">Introduce a longer text</string>
|
||||||
<string name="cancelSendMessage">You are going to cancel the sending message</string>
|
<string name="cancelSendMessage">You are going to cancel the sending message</string>
|
||||||
<string name="cancelSendReceivers">You are going to cancel the selected receivers</string>
|
<string name="cancelSendReceivers">You are going to cancel the selected receivers</string>
|
||||||
|
<string name="cancelRemoveReceivers">Do you want to remove #nameUser# from the list of receivers?</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue
Block a user