Skip to content

Commit

Permalink
make dialog modal (commons-app#6015)
Browse files Browse the repository at this point in the history
Signed-off-by: parneet-guraya <[email protected]>
  • Loading branch information
parneet-guraya authored Dec 11, 2024
1 parent c175a4e commit 9a876fa
Show file tree
Hide file tree
Showing 27 changed files with 53 additions and 62 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/fr/free/nrw/commons/AboutActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ public void launchTranslate(View view) {
getString(R.string.about_translate_cancel),
positiveButtonRunnable,
() -> {},
spinner,
true);
spinner
);
}

}
1 change: 1 addition & 0 deletions app/src/main/java/fr/free/nrw/commons/WelcomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public void onCreate(final Bundle savedInstanceState) {
copyrightBinding = PopupForCopyrightBinding.inflate(getLayoutInflater());
final View contactPopupView = copyrightBinding.getRoot();
dialogBuilder.setView(contactPopupView);
dialogBuilder.setCancelable(false);
dialog = dialogBuilder.create();
dialog.show();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class LoginActivity : AccountAuthenticatorActivity() {
isIndeterminate = true
setTitle(getString(R.string.logging_in_title))
setMessage(getString(R.string.logging_in_message))
setCanceledOnTouchOutside(false)
setCancelable(false)
}
progressDialog!!.show()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ public void handleShowRationaleFlowCameraLocation(Activity activity,
},
() -> locationPermissionCallback.onLocationPermissionDenied(
activity.getString(R.string.in_app_camera_location_permission_denied)),
null,
false);
null
);
}

/**
Expand Down Expand Up @@ -203,8 +203,8 @@ private void askUserToAllowLocationAccess(Activity activity,
defaultKvStore.putBoolean("inAppCameraLocationPref", false);
initiateCameraUpload(activity, resultLauncher);
},
null,
true);
null
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,8 @@ private void showNearbyCardPermissionRationale() {
getString(R.string.nearby_card_permission_explanation),
this::requestLocationPermission,
this::displayYouWontSeeNearbyMessage,
checkBoxView,
false);
checkBoxView
);
}

private void displayYouWontSeeNearbyMessage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ class DeleteHelper @Inject constructor(
reviewCallback: ReviewController.ReviewCallback
) {
val alert = AlertDialog.Builder(context)
alert.setCancelable(false)
alert.setTitle(question)

val checkedItems = booleanArrayOf(false, false, false, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ class DescriptionEditActivity :
getString(titleStringID),
getString(messageStringId),
getString(android.R.string.ok),
null,
true,
null
)
}

Expand Down Expand Up @@ -304,7 +303,7 @@ class DescriptionEditActivity :
progressDialog!!.isIndeterminate = true
progressDialog!!.setTitle(getString(R.string.updating_caption_title))
progressDialog!!.setMessage(getString(R.string.updating_caption_message))
progressDialog!!.setCanceledOnTouchOutside(false)
progressDialog!!.setCancelable(false)
progressDialog!!.show()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
askForLocationPermission();
},
null,
null,
false);
null
);
} else {
if (isPermissionDenied) {
locationPermissionsHelper.showAppSettingsDialog(getActivity(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ class LocationPermissionsHelper(
activity.getString(R.string.upload_map_location_access)
)
},
null,
false
null
)
} else {
ActivityCompat.requestPermissions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1596,8 +1596,7 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
getString(R.string.about_translate_cancel),
{ onDeleteClicked(spinner) },
{},
spinner,
true
spinner
)
if (isDeleted) {
dialog!!.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = false
Expand All @@ -1616,8 +1615,7 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
onDeleteClickeddialogtext(reason)
},
{},
input,
true
input
)
input.addTextChangedListener(object : TextWatcher {
fun handleText() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ private void showReportDialog(final Media media) {
builder.setItems(R.array.report_violation_options, (dialog, which) -> {
sendReportEmail(media, values[which]);
});
builder.setCancelable(false);
builder.show();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ class ZoomableActivity : BaseActivity() {
val dialog = Dialog(this)
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
dialog.setContentView(R.layout.full_screen_mode_info_dialog)
dialog.setCancelable(false)
(dialog.findViewById(R.id.btn_ok) as Button).setOnClickListener { dialog.dismiss() }
dialog.show()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ public void onActivityResult(Map<String, Boolean> result) {
askForLocationPermission();
},
null,
null,
false);
null
);
} else {
if (isPermissionDenied) {
locationPermissionsHelper.showAppSettingsDialog(getActivity(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ public void showAlert(final Bitmap screenshot) {
getString(R.string.cancel),
() -> shareScreen(screenshot),
() -> {},
view,
true);
view
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,7 @@ class AchievementsFragment : CommonsDaggerSupportFragment(){
null,
message,
getString(R.string.ok),
{},
true
{}
)

// binding.imagesUploadedProgressbar.setVisibility(View.INVISIBLE);
Expand Down Expand Up @@ -510,8 +509,7 @@ class AchievementsFragment : CommonsDaggerSupportFragment(){
title,
message,
getString(R.string.ok),
{},
true
{}
)
}

Expand All @@ -527,8 +525,7 @@ class AchievementsFragment : CommonsDaggerSupportFragment(){
getString(R.string.read_help_link),
{},
{ Utils.handleWebUrl(requireContext(), Uri.parse(helpLinkUrl)) },
null,
true
null
)
}
/**
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/fr/free/nrw/commons/quiz/QuizActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class QuizActivity : AppCompatActivity() {
AlertDialog.Builder(this)
.setTitle(getString(R.string.warning))
.setMessage(getString(R.string.quiz_back_button))
.setCancelable(false)
.setPositiveButton(R.string.continue_message) { dialog, _ ->
val intent = Intent(this, QuizResultActivity::class.java)
dialog.dismiss()
Expand Down Expand Up @@ -137,6 +138,7 @@ class QuizActivity : AppCompatActivity() {
AlertDialog.Builder(this)
.setTitle(title)
.setMessage(message)
.setCancelable(false)
.setPositiveButton(R.string.continue_message) { dialog, _ ->
questionIndex++
if (questionIndex == quiz.size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class QuizResultActivity : AppCompatActivity() {
val shareMessage = view.findViewById<TextView>(R.id.alert_text)
shareMessage.setText(R.string.quiz_result_share_message)
alertadd.setView(view)
alertadd.setCancelable(false)
alertadd.setPositiveButton(R.string.about_translate_proceed) { dialog, _ ->
shareScreen(screenshot)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
getString(R.string.read_help_link),
{ },
{ Utils.handleWebUrl(requireContext(), Uri.parse(GET_CONTENT_PICKER_HELP_URL)) },
null,
true
null
)
}

Expand Down Expand Up @@ -333,7 +332,7 @@ class SettingsFragment : PreferenceFragmentCompat() {

val dialog = Dialog(requireActivity())
dialog.setContentView(R.layout.dialog_select_language)
dialog.setCanceledOnTouchOutside(true)
dialog.setCancelable(false)
dialog.window?.setLayout(
(resources.displayMetrics.widthPixels * 0.90).toInt(),
(resources.displayMetrics.heightPixels * 0.90).toInt()
Expand Down
12 changes: 4 additions & 8 deletions app/src/main/java/fr/free/nrw/commons/upload/UploadActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,7 @@ protected void checkBlockStatus() {
getString(R.string.block_notification_title),
getString(R.string.block_notification),
getString(R.string.ok),
this::finish,
true)));
this::finish)));
}

public void checkStoragePermissions() {
Expand Down Expand Up @@ -418,16 +417,14 @@ public void onRequestPermissionsResult(final int requestCode,
getString(R.string.storage_permissions_denied),
getString(R.string.unable_to_share_upload_item),
getString(android.R.string.ok),
this::finish,
false);
this::finish);
} else {
DialogUtil.showAlertDialog(this,
getString(R.string.storage_permission_title),
getString(
R.string.write_storage_permission_rationale_for_image_share),
getString(android.R.string.ok),
this::checkStoragePermissions,
false);
this::checkStoragePermissions);
}
}
}
Expand Down Expand Up @@ -754,8 +751,7 @@ public void showAlertDialog(int messageResourceId, Runnable onPositiveClick) {
"",
getString(messageResourceId),
getString(R.string.ok),
onPositiveClick,
false);
onPositiveClick);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ private void initLanguage(int position, UploadMediaDetail description) {
public void onClick(View view) {
Dialog dialog = new Dialog(view.getContext());
dialog.setContentView(R.layout.dialog_select_language);
dialog.setCanceledOnTouchOutside(true);
dialog.setCancelable(false);
dialog.getWindow().setLayout(
(int) (view.getContext().getResources().getDisplayMetrics().widthPixels
* 0.90),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private void init() {
binding.tooltip.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
DialogUtil.showAlertDialog(getActivity(), getString(R.string.categories_activity_title), getString(R.string.categories_tooltip), getString(android.R.string.ok), null, true);
DialogUtil.showAlertDialog(getActivity(), getString(R.string.categories_activity_title), getString(R.string.categories_tooltip), getString(android.R.string.ok), null);
}
});
if (media == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private void init() {
setDepictsSubTitle();
binding.tooltip.setOnClickListener(v -> DialogUtil
.showAlertDialog(getActivity(), getString(R.string.depicts_step_title),
getString(R.string.depicts_tooltip), getString(android.R.string.ok), null, true));
getString(R.string.depicts_tooltip), getString(android.R.string.ok), null));
if (media == null) {
presenter.onAttachView(this);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
getString(R.string.license_step_title),
getString(R.string.license_tooltip),
getString(android.R.string.ok),
null, true)
null)
);

initPresenter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ private void initRecyclerView() {
*/
private void showInfoAlert(int titleStringID, int messageStringId) {
DialogUtil.showAlertDialog(getActivity(), getString(titleStringID),
getString(messageStringId), getString(android.R.string.ok), null, true);
getString(messageStringId), getString(android.R.string.ok), null);
}


Expand All @@ -336,6 +336,7 @@ public void showSimilarImageFragment(String originalFilePath, String possibleFil
BasicKvStore basicKvStore = new BasicKvStore(getActivity(), "IsAnyImageCancelled");
if (!basicKvStore.getBoolean("IsAnyImageCancelled", false)) {
SimilarImageDialogFragment newFragment = new SimilarImageDialogFragment();
newFragment.setCancelable(false);
newFragment.setCallback(new SimilarImageDialogFragment.Callback() {
@Override
public void onPositiveResponse() {
Expand Down Expand Up @@ -450,7 +451,8 @@ private void showNearbyPlaceFound(Place place) {
// Execute when user cancels the upload of the specified place
UploadActivity.nearbyPopupAnswers.put(place, false);
},
customLayout, true);
customLayout
);
}
}

Expand Down Expand Up @@ -526,8 +528,7 @@ public void showDuplicatePicturePopup(UploadItem uploadItem) {
uploadItem.setImageQuality(ImageUtils.IMAGE_KEEP);
onImageValidationSuccess();
}, null,
checkBoxView,
false);
checkBoxView);
} else {
uploadItem.setImageQuality(ImageUtils.IMAGE_KEEP);
onImageValidationSuccess();
Expand Down Expand Up @@ -588,8 +589,7 @@ public void showConnectionErrorPopup() {
basicKvStore.putBoolean(keyForShowingAlertDialog, false);
activity.finish();
},
null,
false
null
);
}
} catch (Exception e) {
Expand Down
Loading

0 comments on commit 9a876fa

Please sign in to comment.