Updated the Groups module dialogs with DialogFactory methods
This commit is contained in:
parent
72548b90a4
commit
e5b347dada
|
@ -550,7 +550,7 @@ public class Preferences extends PreferenceActivity implements OnPreferenceChang
|
|||
}
|
||||
};
|
||||
|
||||
AlertDialog errorDialog = DialogFactory.errorDialog(this, TAG, message, ex, sendException,
|
||||
AlertDialog errorDialog = DialogFactory.createErrorDialog(this, TAG, message, ex, sendException,
|
||||
isDebuggable, onClickListener);
|
||||
|
||||
errorDialog.show();
|
||||
|
|
|
@ -142,7 +142,7 @@ public class SWADMain extends MenuExpandableListActivity {
|
|||
}
|
||||
};
|
||||
|
||||
AlertDialog alertDialog = DialogFactory.positiveNegativeDialog(this,
|
||||
AlertDialog alertDialog = DialogFactory.createPositiveNegativeDialog(this,
|
||||
-1,
|
||||
R.string.initialDialogTitle,
|
||||
R.string.firstRunMsg,
|
||||
|
|
|
@ -9,6 +9,8 @@ import com.bugsense.trace.BugSenseHandler;
|
|||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnCancelListener;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.res.Resources;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -40,12 +42,12 @@ public class DialogFactory {
|
|||
/**
|
||||
* Creates a Webview dialog with HTML content.
|
||||
*/
|
||||
public static AlertDialog createWebViewDialog(Context context, int title, int contentResourceId) {
|
||||
public static AlertDialog createWebViewDialog(Context context, int titleId, int contentResourceId) {
|
||||
LayoutInflater li = LayoutInflater.from(context);
|
||||
View promptsView = li.inflate(R.layout.dialog_webview, null);
|
||||
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
|
||||
alertDialogBuilder.setTitle(context.getString(title));
|
||||
alertDialogBuilder.setTitle(context.getString(titleId));
|
||||
alertDialogBuilder.setCancelable(false);
|
||||
alertDialogBuilder.setNeutralButton(R.string.close_dialog, null);
|
||||
|
||||
|
@ -71,20 +73,21 @@ public class DialogFactory {
|
|||
return alertDialogBuilder.create();
|
||||
}
|
||||
|
||||
public static AlertDialog neutralDialog(Context context, int title, int message) {
|
||||
public static AlertDialog createNeutralDialog(Context context, int titleId, int messageId, int buttonLabelId,
|
||||
OnClickListener clickListener) {
|
||||
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context)
|
||||
.setTitle(title)
|
||||
.setMessage(message)
|
||||
.setTitle(titleId)
|
||||
.setMessage(messageId)
|
||||
.setCancelable(false)
|
||||
.setNeutralButton(R.string.close_dialog, null);
|
||||
.setNeutralButton(buttonLabelId, clickListener);
|
||||
|
||||
return alertDialogBuilder.create();
|
||||
}
|
||||
|
||||
public static AlertDialog positiveNegativeDialog(Context context, int layoutId, int titleId, int messageId,
|
||||
int acceptLabel, int cancelLabel,
|
||||
DialogInterface.OnClickListener positiveListener, DialogInterface.OnClickListener negativeListener,
|
||||
DialogInterface.OnCancelListener cancelListener) {
|
||||
public static AlertDialog createPositiveNegativeDialog(Context context, int layoutId, int titleId,
|
||||
int messageId, int acceptLabel, int cancelLabel, OnClickListener positiveListener,
|
||||
OnClickListener negativeListener, OnCancelListener cancelListener) {
|
||||
|
||||
AlertDialog alertDialog;
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context)
|
||||
|
@ -116,7 +119,7 @@ public class DialogFactory {
|
|||
return alertDialog;
|
||||
}
|
||||
|
||||
public static AlertDialog errorDialog(Context context, String tag, String message, Exception ex,
|
||||
public static AlertDialog createErrorDialog(Context context, String tag, String message, Exception ex,
|
||||
boolean sendException, boolean isDebuggable, DialogInterface.OnClickListener onClickListener) {
|
||||
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context)
|
||||
|
|
|
@ -124,7 +124,7 @@ public class MenuActivity extends Activity {
|
|||
}
|
||||
};
|
||||
|
||||
AlertDialog errorDialog = DialogFactory.errorDialog(this, TAG, message, ex, sendException,
|
||||
AlertDialog errorDialog = DialogFactory.createErrorDialog(this, TAG, message, ex, sendException,
|
||||
isDebuggable, onClickListener);
|
||||
|
||||
errorDialog.show();
|
||||
|
@ -134,7 +134,7 @@ public class MenuActivity extends Activity {
|
|||
* Shows a dialog.
|
||||
*/
|
||||
public void showDialog(int title, int message) {
|
||||
AlertDialog dialog = DialogFactory.neutralDialog(this, title, message);
|
||||
AlertDialog dialog = DialogFactory.createNeutralDialog(this, title, message, R.string.close_dialog, null);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ public class MenuExpandableListActivity extends ExpandableListActivity {
|
|||
}
|
||||
};
|
||||
|
||||
AlertDialog errorDialog = DialogFactory.errorDialog(this, TAG, message, ex, sendException,
|
||||
AlertDialog errorDialog = DialogFactory.createErrorDialog(this, TAG, message, ex, sendException,
|
||||
isDebuggable, onClickListener);
|
||||
|
||||
errorDialog.show();
|
||||
|
@ -138,7 +138,7 @@ public class MenuExpandableListActivity extends ExpandableListActivity {
|
|||
* Shows a dialog.
|
||||
*/
|
||||
public void showDialog(int title, int message) {
|
||||
AlertDialog dialog = DialogFactory.neutralDialog(this, title, message);
|
||||
AlertDialog dialog = DialogFactory.createNeutralDialog(this, title, message, R.string.close_dialog, null);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ public class Messages extends Module {
|
|||
|
||||
notificationCode = getIntent().getLongExtra("notificationCode", 0);
|
||||
|
||||
messageDialog = DialogFactory.positiveNegativeDialog(this,
|
||||
messageDialog = DialogFactory.createPositiveNegativeDialog(this,
|
||||
R.layout.dialog_messages,
|
||||
R.string.messagesModuleLabel,
|
||||
-1,
|
||||
|
|
|
@ -132,7 +132,7 @@ public class Notices extends Module {
|
|||
};
|
||||
|
||||
private void launchNoticeDialog() {
|
||||
noticeDialog = DialogFactory.positiveNegativeDialog(this,
|
||||
noticeDialog = DialogFactory.createPositiveNegativeDialog(this,
|
||||
R.layout.dialog_notice,
|
||||
R.string.noticesModuleLabel,
|
||||
-1,
|
||||
|
|
|
@ -21,12 +21,14 @@ package es.ugr.swad.swadroid.modules.groups;
|
|||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.*;
|
||||
import es.ugr.swad.swadroid.Constants;
|
||||
import es.ugr.swad.swadroid.R;
|
||||
import es.ugr.swad.swadroid.gui.DialogFactory;
|
||||
import es.ugr.swad.swadroid.gui.MenuExpandableListActivity;
|
||||
import es.ugr.swad.swadroid.model.Group;
|
||||
import es.ugr.swad.swadroid.model.Model;
|
||||
|
@ -67,6 +69,11 @@ public class MyGroupsManager extends MenuExpandableListActivity {
|
|||
|
||||
private ImageButton updateButton;
|
||||
private ProgressBar progressbar;
|
||||
private OnClickListener cancelClickListener = new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
|
@ -180,33 +187,27 @@ public class MyGroupsManager extends MenuExpandableListActivity {
|
|||
/**
|
||||
* Shows informative dialog on successful enrollment
|
||||
*/
|
||||
void showSuccessfulEnrollmentDialog() {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.resultEnrollment)
|
||||
.setMessage(R.string.successfullEnrollment)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
void showSuccessfulEnrollmentDialog() {
|
||||
AlertDialog dialog = DialogFactory.createNeutralDialog(this,
|
||||
R.string.resultEnrollment,
|
||||
R.string.successfullEnrollment,
|
||||
R.string.ok,
|
||||
cancelClickListener);
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows informative dialog on failed enrollment
|
||||
*/
|
||||
void showFailedEnrollmentDialog() {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.resultEnrollment)
|
||||
.setMessage(R.string.failedEnrollment)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
AlertDialog dialog = DialogFactory.createNeutralDialog(this,
|
||||
R.string.resultEnrollment,
|
||||
R.string.failedEnrollment,
|
||||
R.string.ok,
|
||||
cancelClickListener);
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
|
||||
|
@ -214,27 +215,28 @@ public class MyGroupsManager extends MenuExpandableListActivity {
|
|||
* Shows dialog to ask for confirmation in group enrollments
|
||||
*/
|
||||
private void showConfirmEnrollmentDialog() {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.confirmEnrollments)
|
||||
.setMessage(R.string.areYouSure)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.yesMsg, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
String myGroups = ((EnrollmentExpandableListAdapter) getExpandableListView().getExpandableListAdapter()).getChosenGroupCodesAsString();
|
||||
Intent activity = new Intent(getBaseContext(), SendMyGroups.class);
|
||||
activity.putExtra("courseCode", courseCode);
|
||||
activity.putExtra("myGroups", myGroups);
|
||||
startActivityForResult(activity, Constants.SENDMYGROUPS_REQUEST_CODE);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.noMsg, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
OnClickListener positiveClickListener = new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
String myGroups = ((EnrollmentExpandableListAdapter) getExpandableListView().getExpandableListAdapter()).getChosenGroupCodesAsString();
|
||||
Intent activity = new Intent(getBaseContext(), SendMyGroups.class);
|
||||
activity.putExtra("courseCode", courseCode);
|
||||
activity.putExtra("myGroups", myGroups);
|
||||
startActivityForResult(activity, Constants.SENDMYGROUPS_REQUEST_CODE);
|
||||
}
|
||||
};
|
||||
|
||||
AlertDialog dialog = DialogFactory.createPositiveNegativeDialog(this,
|
||||
-1,
|
||||
R.string.confirmEnrollments,
|
||||
R.string.areYouSure,
|
||||
R.string.yesMsg,
|
||||
R.string.noMsg,
|
||||
positiveClickListener,
|
||||
cancelClickListener,
|
||||
null);
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
/* private String getRequestedGroups(){
|
||||
|
|
Loading…
Reference in New Issue
Block a user