Skip to content

Commit

Permalink
fix: Release Orientation lock when a Dialog is canceled on touch from…
Browse files Browse the repository at this point in the history
… outside
  • Loading branch information
kaushiknsanji committed Nov 9, 2019
1 parent 0333f83 commit 530d4e8
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,23 @@ public void onClick(DialogInterface dialog, int which) {
}
};

/**
* The {@link AlertDialog} Cancel Listener for the Product Delete and Unsaved changes dialog
*/
private DialogInterface.OnCancelListener mDialogOnCancelListener = new DialogInterface.OnCancelListener() {
/**
* This method will be invoked when the dialog is canceled.
*
* @param dialog the dialog that was canceled will be passed into the
* method
*/
@Override
public void onCancel(DialogInterface dialog) {
//Unlock orientation
OrientationUtility.unlockScreenOrientation(requireActivity());
}
};

/**
* Mandatory Empty Constructor of {@link SalesConfigActivityFragment}
* This is required by the {@link android.support.v4.app.FragmentManager} to instantiate
Expand Down Expand Up @@ -823,6 +840,8 @@ public void showDiscardDialog() {
builder.setNegativeButton(R.string.sales_config_unsaved_changes_dialog_negative_text, mUnsavedDialogOnClickListener);
//Set the Neutral Button and its listener
builder.setNeutralButton(R.string.sales_config_unsaved_changes_dialog_neutral_text, mUnsavedDialogOnClickListener);
//Set the Dialog Cancel listener to release orientation lock on cancel
builder.setOnCancelListener(mDialogOnCancelListener);
//Lock the Orientation
OrientationUtility.lockCurrentScreenOrientation(requireActivity());
//Create and display the AlertDialog
Expand All @@ -844,6 +863,8 @@ public void showDeleteProductDialog() {
builder.setPositiveButton(android.R.string.yes, mProductDeleteDialogOnClickListener);
//Set the Negative Button and its listener
builder.setNegativeButton(android.R.string.no, mProductDeleteDialogOnClickListener);
//Set the Dialog Cancel listener to release orientation lock on cancel
builder.setOnCancelListener(mDialogOnCancelListener);
//Lock the Orientation
OrientationUtility.lockCurrentScreenOrientation(requireActivity());
//Create and display the AlertDialog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,23 @@ public void onClick(DialogInterface dialog, int which) {
}
};

/**
* The {@link AlertDialog} Cancel Listener for the Product Delete and Unsaved changes dialog
*/
private DialogInterface.OnCancelListener mDialogOnCancelListener = new DialogInterface.OnCancelListener() {
/**
* This method will be invoked when the dialog is canceled.
*
* @param dialog the dialog that was canceled will be passed into the
* method
*/
@Override
public void onCancel(DialogInterface dialog) {
//Unlock orientation
OrientationUtility.unlockScreenOrientation(requireActivity());
}
};

/**
* Mandatory Empty Constructor of {@link ProductConfigActivityFragment}.
* This is required by the {@link android.support.v4.app.FragmentManager} to instantiate
Expand Down Expand Up @@ -730,6 +747,8 @@ public void showDiscardDialog() {
builder.setNegativeButton(R.string.product_config_unsaved_changes_dialog_negative_text, mUnsavedDialogOnClickListener);
//Set the Neutral Button and its listener
builder.setNeutralButton(R.string.product_config_unsaved_changes_dialog_neutral_text, mUnsavedDialogOnClickListener);
//Set the Dialog Cancel listener to release orientation lock on cancel
builder.setOnCancelListener(mDialogOnCancelListener);
//Lock the Orientation
OrientationUtility.lockCurrentScreenOrientation(requireActivity());
//Create and display the AlertDialog
Expand All @@ -751,6 +770,8 @@ public void showDeleteProductDialog() {
builder.setPositiveButton(android.R.string.yes, mProductDeleteDialogOnClickListener);
//Set the Negative Button and its listener
builder.setNegativeButton(android.R.string.no, mProductDeleteDialogOnClickListener);
//Set the Dialog Cancel listener to release orientation lock on cancel
builder.setOnCancelListener(mDialogOnCancelListener);
//Lock the Orientation
OrientationUtility.lockCurrentScreenOrientation(requireActivity());
//Create and display the AlertDialog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,23 @@ public void onClick(DialogInterface dialog, int which) {
}
};

/**
* The {@link AlertDialog} Cancel Listener for the Unsaved changes dialog
*/
private DialogInterface.OnCancelListener mDialogOnCancelListener = new DialogInterface.OnCancelListener() {
/**
* This method will be invoked when the dialog is canceled.
*
* @param dialog the dialog that was canceled will be passed into the
* method
*/
@Override
public void onCancel(DialogInterface dialog) {
//Unlock orientation
OrientationUtility.unlockScreenOrientation(requireActivity());
}
};

/**
* Mandatory Empty Constructor of {@link ProductImageActivityFragment}
* This is required by the {@link android.support.v4.app.FragmentManager} to instantiate
Expand Down Expand Up @@ -526,6 +543,8 @@ public void showDiscardDialog() {
builder.setPositiveButton(R.string.product_image_unsaved_changes_dialog_positive_text, mUnsavedDialogOnClickListener);
//Set the Negative Button and its listener
builder.setNegativeButton(R.string.product_image_unsaved_changes_dialog_negative_text, mUnsavedDialogOnClickListener);
//Set the Dialog Cancel listener to release orientation lock on cancel
builder.setOnCancelListener(mDialogOnCancelListener);
//Lock the Orientation
OrientationUtility.lockCurrentScreenOrientation(requireActivity());
//Create and display the AlertDialog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,23 @@ public void onClick(DialogInterface dialog, int which) {
}
};

/**
* The {@link AlertDialog} Cancel Listener for the Supplier Delete and Unsaved changes dialog
*/
private DialogInterface.OnCancelListener mDialogOnCancelListener = new DialogInterface.OnCancelListener() {
/**
* This method will be invoked when the dialog is canceled.
*
* @param dialog the dialog that was canceled will be passed into the
* method
*/
@Override
public void onCancel(DialogInterface dialog) {
//Unlock orientation
OrientationUtility.unlockScreenOrientation(requireActivity());
}
};

/**
* Mandatory Empty Constructor of {@link SupplierConfigActivityFragment}.
* This is required by the {@link android.support.v4.app.FragmentManager} to instantiate
Expand Down Expand Up @@ -831,6 +848,8 @@ public void showDiscardDialog() {
builder.setNegativeButton(R.string.supplier_config_unsaved_changes_dialog_negative_text, mUnsavedDialogOnClickListener);
//Set the Neutral Button and its listener
builder.setNeutralButton(R.string.supplier_config_unsaved_changes_dialog_neutral_text, mUnsavedDialogOnClickListener);
//Set the Dialog Cancel listener to release orientation lock on cancel
builder.setOnCancelListener(mDialogOnCancelListener);
//Lock the Orientation
OrientationUtility.lockCurrentScreenOrientation(requireActivity());
//Create and display the AlertDialog
Expand All @@ -852,6 +871,8 @@ public void showDeleteSupplierDialog() {
builder.setPositiveButton(android.R.string.yes, mSupplierDeleteDialogOnClickListener);
//Set the Negative Button and its listener
builder.setNegativeButton(android.R.string.no, mSupplierDeleteDialogOnClickListener);
//Set the Dialog Cancel listener to release orientation lock on cancel
builder.setOnCancelListener(mDialogOnCancelListener);
//Lock the Orientation
OrientationUtility.lockCurrentScreenOrientation(requireActivity());
//Create and display the AlertDialog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@ public void onClick(DialogInterface dialog, int which) {
}
};

/**
* The {@link AlertDialog} Cancel Listener for the Unsaved changes dialog
*/
private DialogInterface.OnCancelListener mDialogOnCancelListener = new DialogInterface.OnCancelListener() {
/**
* This method will be invoked when the dialog is canceled.
*
* @param dialog the dialog that was canceled will be passed into the
* method
*/
@Override
public void onCancel(DialogInterface dialog) {
//Unlock orientation
OrientationUtility.unlockScreenOrientation(requireActivity());
}
};

/**
* Mandatory Empty Constructor of {@link SupplierProductPickerActivityFragment}
* This is required by the {@link android.support.v4.app.FragmentManager} to instantiate
Expand Down Expand Up @@ -529,6 +546,8 @@ public void showDiscardDialog() {
builder.setNegativeButton(R.string.supplier_product_picker_unsaved_changes_dialog_negative_text, mUnsavedDialogOnClickListener);
//Set the Neutral Button and its listener
builder.setNeutralButton(R.string.supplier_product_picker_unsaved_changes_dialog_neutral_text, mUnsavedDialogOnClickListener);
//Set the Dialog Cancel listener to release orientation lock on cancel
builder.setOnCancelListener(mDialogOnCancelListener);
//Lock the Orientation
OrientationUtility.lockCurrentScreenOrientation(requireActivity());
//Create and display the AlertDialog
Expand Down

0 comments on commit 530d4e8

Please sign in to comment.