make dialog modal (#6015)

Signed-off-by: parneet-guraya <gurayaparneet@gmail.com>
This commit is contained in:
Parneet Singh 2024-12-11 11:38:39 +05:30 committed by GitHub
parent c175a4ee03
commit 9a876fa5e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 53 additions and 62 deletions

View file

@ -180,8 +180,8 @@ public class AboutActivity extends BaseActivity {
getString(R.string.about_translate_cancel), getString(R.string.about_translate_cancel),
positiveButtonRunnable, positiveButtonRunnable,
() -> {}, () -> {},
spinner, spinner
true); );
} }
} }

View file

@ -50,6 +50,7 @@ public class WelcomeActivity extends BaseActivity {
copyrightBinding = PopupForCopyrightBinding.inflate(getLayoutInflater()); copyrightBinding = PopupForCopyrightBinding.inflate(getLayoutInflater());
final View contactPopupView = copyrightBinding.getRoot(); final View contactPopupView = copyrightBinding.getRoot();
dialogBuilder.setView(contactPopupView); dialogBuilder.setView(contactPopupView);
dialogBuilder.setCancelable(false);
dialog = dialogBuilder.create(); dialog = dialogBuilder.create();
dialog.show(); dialog.show();

View file

@ -319,7 +319,7 @@ class LoginActivity : AccountAuthenticatorActivity() {
isIndeterminate = true isIndeterminate = true
setTitle(getString(R.string.logging_in_title)) setTitle(getString(R.string.logging_in_title))
setMessage(getString(R.string.logging_in_message)) setMessage(getString(R.string.logging_in_message))
setCanceledOnTouchOutside(false) setCancelable(false)
} }
progressDialog!!.show() progressDialog!!.show()
} }

View file

@ -170,8 +170,8 @@ public class ContributionController {
}, },
() -> locationPermissionCallback.onLocationPermissionDenied( () -> locationPermissionCallback.onLocationPermissionDenied(
activity.getString(R.string.in_app_camera_location_permission_denied)), activity.getString(R.string.in_app_camera_location_permission_denied)),
null, null
false); );
} }
/** /**
@ -203,8 +203,8 @@ public class ContributionController {
defaultKvStore.putBoolean("inAppCameraLocationPref", false); defaultKvStore.putBoolean("inAppCameraLocationPref", false);
initiateCameraUpload(activity, resultLauncher); initiateCameraUpload(activity, resultLauncher);
}, },
null, null
true); );
} }
/** /**

View file

@ -566,8 +566,8 @@ public class ContributionsFragment
getString(R.string.nearby_card_permission_explanation), getString(R.string.nearby_card_permission_explanation),
this::requestLocationPermission, this::requestLocationPermission,
this::displayYouWontSeeNearbyMessage, this::displayYouWontSeeNearbyMessage,
checkBoxView, checkBoxView
false); );
} }
private void displayYouWontSeeNearbyMessage() { private void displayYouWontSeeNearbyMessage() {

View file

@ -205,6 +205,7 @@ class DeleteHelper @Inject constructor(
reviewCallback: ReviewController.ReviewCallback reviewCallback: ReviewController.ReviewCallback
) { ) {
val alert = AlertDialog.Builder(context) val alert = AlertDialog.Builder(context)
alert.setCancelable(false)
alert.setTitle(question) alert.setTitle(question)
val checkedItems = booleanArrayOf(false, false, false, false) val checkedItems = booleanArrayOf(false, false, false, false)

View file

@ -149,8 +149,7 @@ class DescriptionEditActivity :
getString(titleStringID), getString(titleStringID),
getString(messageStringId), getString(messageStringId),
getString(android.R.string.ok), getString(android.R.string.ok),
null, null
true,
) )
} }
@ -304,7 +303,7 @@ class DescriptionEditActivity :
progressDialog!!.isIndeterminate = true progressDialog!!.isIndeterminate = true
progressDialog!!.setTitle(getString(R.string.updating_caption_title)) progressDialog!!.setTitle(getString(R.string.updating_caption_title))
progressDialog!!.setMessage(getString(R.string.updating_caption_message)) progressDialog!!.setMessage(getString(R.string.updating_caption_message))
progressDialog!!.setCanceledOnTouchOutside(false) progressDialog!!.setCancelable(false)
progressDialog!!.show() progressDialog!!.show()
} }

View file

@ -133,8 +133,8 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
askForLocationPermission(); askForLocationPermission();
}, },
null, null,
null, null
false); );
} else { } else {
if (isPermissionDenied) { if (isPermissionDenied) {
locationPermissionsHelper.showAppSettingsDialog(getActivity(), locationPermissionsHelper.showAppSettingsDialog(getActivity(),

View file

@ -78,8 +78,7 @@ class LocationPermissionsHelper(
activity.getString(R.string.upload_map_location_access) activity.getString(R.string.upload_map_location_access)
) )
}, },
null, null
false
) )
} else { } else {
ActivityCompat.requestPermissions( ActivityCompat.requestPermissions(

View file

@ -1596,8 +1596,7 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
getString(R.string.about_translate_cancel), getString(R.string.about_translate_cancel),
{ onDeleteClicked(spinner) }, { onDeleteClicked(spinner) },
{}, {},
spinner, spinner
true
) )
if (isDeleted) { if (isDeleted) {
dialog!!.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = false dialog!!.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = false
@ -1616,8 +1615,7 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
onDeleteClickeddialogtext(reason) onDeleteClickeddialogtext(reason)
}, },
{}, {},
input, input
true
) )
input.addTextChangedListener(object : TextWatcher { input.addTextChangedListener(object : TextWatcher {
fun handleText() { fun handleText() {

View file

@ -283,6 +283,7 @@ public class MediaDetailPagerFragment extends CommonsDaggerSupportFragment imple
builder.setItems(R.array.report_violation_options, (dialog, which) -> { builder.setItems(R.array.report_violation_options, (dialog, which) -> {
sendReportEmail(media, values[which]); sendReportEmail(media, values[which]);
}); });
builder.setCancelable(false);
builder.show(); builder.show();
} }

View file

@ -196,6 +196,7 @@ class ZoomableActivity : BaseActivity() {
val dialog = Dialog(this) val dialog = Dialog(this)
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE) dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
dialog.setContentView(R.layout.full_screen_mode_info_dialog) dialog.setContentView(R.layout.full_screen_mode_info_dialog)
dialog.setCancelable(false)
(dialog.findViewById(R.id.btn_ok) as Button).setOnClickListener { dialog.dismiss() } (dialog.findViewById(R.id.btn_ok) as Button).setOnClickListener { dialog.dismiss() }
dialog.show() dialog.show()
} }

View file

@ -291,8 +291,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
askForLocationPermission(); askForLocationPermission();
}, },
null, null,
null, null
false); );
} else { } else {
if (isPermissionDenied) { if (isPermissionDenied) {
locationPermissionsHelper.showAppSettingsDialog(getActivity(), locationPermissionsHelper.showAppSettingsDialog(getActivity(),

View file

@ -206,8 +206,8 @@ public class ProfileActivity extends BaseActivity {
getString(R.string.cancel), getString(R.string.cancel),
() -> shareScreen(screenshot), () -> shareScreen(screenshot),
() -> {}, () -> {},
view, view
true); );
} }
/** /**

View file

@ -323,8 +323,7 @@ class AchievementsFragment : CommonsDaggerSupportFragment(){
null, null,
message, message,
getString(R.string.ok), getString(R.string.ok),
{}, {}
true
) )
// binding.imagesUploadedProgressbar.setVisibility(View.INVISIBLE); // binding.imagesUploadedProgressbar.setVisibility(View.INVISIBLE);
@ -510,8 +509,7 @@ class AchievementsFragment : CommonsDaggerSupportFragment(){
title, title,
message, message,
getString(R.string.ok), getString(R.string.ok),
{}, {}
true
) )
} }
@ -527,8 +525,7 @@ class AchievementsFragment : CommonsDaggerSupportFragment(){
getString(R.string.read_help_link), getString(R.string.read_help_link),
{}, {},
{ Utils.handleWebUrl(requireContext(), Uri.parse(helpLinkUrl)) }, { Utils.handleWebUrl(requireContext(), Uri.parse(helpLinkUrl)) },
null, null
true
) )
} }
/** /**

View file

@ -66,6 +66,7 @@ class QuizActivity : AppCompatActivity() {
AlertDialog.Builder(this) AlertDialog.Builder(this)
.setTitle(getString(R.string.warning)) .setTitle(getString(R.string.warning))
.setMessage(getString(R.string.quiz_back_button)) .setMessage(getString(R.string.quiz_back_button))
.setCancelable(false)
.setPositiveButton(R.string.continue_message) { dialog, _ -> .setPositiveButton(R.string.continue_message) { dialog, _ ->
val intent = Intent(this, QuizResultActivity::class.java) val intent = Intent(this, QuizResultActivity::class.java)
dialog.dismiss() dialog.dismiss()
@ -137,6 +138,7 @@ class QuizActivity : AppCompatActivity() {
AlertDialog.Builder(this) AlertDialog.Builder(this)
.setTitle(title) .setTitle(title)
.setMessage(message) .setMessage(message)
.setCancelable(false)
.setPositiveButton(R.string.continue_message) { dialog, _ -> .setPositiveButton(R.string.continue_message) { dialog, _ ->
questionIndex++ questionIndex++
if (questionIndex == quiz.size) { if (questionIndex == quiz.size) {

View file

@ -181,6 +181,7 @@ class QuizResultActivity : AppCompatActivity() {
val shareMessage = view.findViewById<TextView>(R.id.alert_text) val shareMessage = view.findViewById<TextView>(R.id.alert_text)
shareMessage.setText(R.string.quiz_result_share_message) shareMessage.setText(R.string.quiz_result_share_message)
alertadd.setView(view) alertadd.setView(view)
alertadd.setCancelable(false)
alertadd.setPositiveButton(R.string.about_translate_proceed) { dialog, _ -> alertadd.setPositiveButton(R.string.about_translate_proceed) { dialog, _ ->
shareScreen(screenshot) shareScreen(screenshot)
} }

View file

@ -273,8 +273,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
getString(R.string.read_help_link), getString(R.string.read_help_link),
{ }, { },
{ Utils.handleWebUrl(requireContext(), Uri.parse(GET_CONTENT_PICKER_HELP_URL)) }, { Utils.handleWebUrl(requireContext(), Uri.parse(GET_CONTENT_PICKER_HELP_URL)) },
null, null
true
) )
} }
@ -333,7 +332,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
val dialog = Dialog(requireActivity()) val dialog = Dialog(requireActivity())
dialog.setContentView(R.layout.dialog_select_language) dialog.setContentView(R.layout.dialog_select_language)
dialog.setCanceledOnTouchOutside(true) dialog.setCancelable(false)
dialog.window?.setLayout( dialog.window?.setLayout(
(resources.displayMetrics.widthPixels * 0.90).toInt(), (resources.displayMetrics.widthPixels * 0.90).toInt(),
(resources.displayMetrics.heightPixels * 0.90).toInt() (resources.displayMetrics.heightPixels * 0.90).toInt()

View file

@ -270,8 +270,7 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
getString(R.string.block_notification_title), getString(R.string.block_notification_title),
getString(R.string.block_notification), getString(R.string.block_notification),
getString(R.string.ok), getString(R.string.ok),
this::finish, this::finish)));
true)));
} }
public void checkStoragePermissions() { public void checkStoragePermissions() {
@ -418,16 +417,14 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
getString(R.string.storage_permissions_denied), getString(R.string.storage_permissions_denied),
getString(R.string.unable_to_share_upload_item), getString(R.string.unable_to_share_upload_item),
getString(android.R.string.ok), getString(android.R.string.ok),
this::finish, this::finish);
false);
} else { } else {
DialogUtil.showAlertDialog(this, DialogUtil.showAlertDialog(this,
getString(R.string.storage_permission_title), getString(R.string.storage_permission_title),
getString( getString(
R.string.write_storage_permission_rationale_for_image_share), R.string.write_storage_permission_rationale_for_image_share),
getString(android.R.string.ok), getString(android.R.string.ok),
this::checkStoragePermissions, this::checkStoragePermissions);
false);
} }
} }
} }
@ -754,8 +751,7 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
"", "",
getString(messageResourceId), getString(messageResourceId),
getString(R.string.ok), getString(R.string.ok),
onPositiveClick, onPositiveClick);
false);
} }
@Override @Override

View file

@ -346,7 +346,7 @@ public class UploadMediaDetailAdapter extends
public void onClick(View view) { public void onClick(View view) {
Dialog dialog = new Dialog(view.getContext()); Dialog dialog = new Dialog(view.getContext());
dialog.setContentView(R.layout.dialog_select_language); dialog.setContentView(R.layout.dialog_select_language);
dialog.setCanceledOnTouchOutside(true); dialog.setCancelable(false);
dialog.getWindow().setLayout( dialog.getWindow().setLayout(
(int) (view.getContext().getResources().getDisplayMetrics().widthPixels (int) (view.getContext().getResources().getDisplayMetrics().widthPixels
* 0.90), * 0.90),

View file

@ -105,7 +105,7 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate
binding.tooltip.setOnClickListener(new OnClickListener() { binding.tooltip.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { 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) { if (media == null) {

View file

@ -114,7 +114,7 @@ public class DepictsFragment extends UploadBaseFragment implements DepictsContra
setDepictsSubTitle(); setDepictsSubTitle();
binding.tooltip.setOnClickListener(v -> DialogUtil binding.tooltip.setOnClickListener(v -> DialogUtil
.showAlertDialog(getActivity(), getString(R.string.depicts_step_title), .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) { if (media == null) {
presenter.onAttachView(this); presenter.onAttachView(this);
} else { } else {

View file

@ -69,7 +69,7 @@ public class MediaLicenseFragment extends UploadBaseFragment implements MediaLic
getString(R.string.license_step_title), getString(R.string.license_step_title),
getString(R.string.license_tooltip), getString(R.string.license_tooltip),
getString(android.R.string.ok), getString(android.R.string.ok),
null, true) null)
); );
initPresenter(); initPresenter();

View file

@ -309,7 +309,7 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
*/ */
private void showInfoAlert(int titleStringID, int messageStringId) { private void showInfoAlert(int titleStringID, int messageStringId) {
DialogUtil.showAlertDialog(getActivity(), getString(titleStringID), DialogUtil.showAlertDialog(getActivity(), getString(titleStringID),
getString(messageStringId), getString(android.R.string.ok), null, true); getString(messageStringId), getString(android.R.string.ok), null);
} }
@ -336,6 +336,7 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
BasicKvStore basicKvStore = new BasicKvStore(getActivity(), "IsAnyImageCancelled"); BasicKvStore basicKvStore = new BasicKvStore(getActivity(), "IsAnyImageCancelled");
if (!basicKvStore.getBoolean("IsAnyImageCancelled", false)) { if (!basicKvStore.getBoolean("IsAnyImageCancelled", false)) {
SimilarImageDialogFragment newFragment = new SimilarImageDialogFragment(); SimilarImageDialogFragment newFragment = new SimilarImageDialogFragment();
newFragment.setCancelable(false);
newFragment.setCallback(new SimilarImageDialogFragment.Callback() { newFragment.setCallback(new SimilarImageDialogFragment.Callback() {
@Override @Override
public void onPositiveResponse() { public void onPositiveResponse() {
@ -450,7 +451,8 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
// Execute when user cancels the upload of the specified place // Execute when user cancels the upload of the specified place
UploadActivity.nearbyPopupAnswers.put(place, false); UploadActivity.nearbyPopupAnswers.put(place, false);
}, },
customLayout, true); customLayout
);
} }
} }
@ -526,8 +528,7 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
uploadItem.setImageQuality(ImageUtils.IMAGE_KEEP); uploadItem.setImageQuality(ImageUtils.IMAGE_KEEP);
onImageValidationSuccess(); onImageValidationSuccess();
}, null, }, null,
checkBoxView, checkBoxView);
false);
} else { } else {
uploadItem.setImageQuality(ImageUtils.IMAGE_KEEP); uploadItem.setImageQuality(ImageUtils.IMAGE_KEEP);
onImageValidationSuccess(); onImageValidationSuccess();
@ -588,8 +589,7 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
basicKvStore.putBoolean(keyForShowingAlertDialog, false); basicKvStore.putBoolean(keyForShowingAlertDialog, false);
activity.finish(); activity.finish();
}, },
null, null
false
); );
} }
} catch (Exception e) { } catch (Exception e) {

View file

@ -79,7 +79,6 @@ object DialogUtil {
onPositiveBtnClick: Runnable?, onPositiveBtnClick: Runnable?,
onNegativeBtnClick: Runnable?, onNegativeBtnClick: Runnable?,
customView: View?, customView: View?,
cancelable: Boolean,
): AlertDialog? = ): AlertDialog? =
createAndShowDialogSafely( createAndShowDialogSafely(
activity = activity, activity = activity,
@ -90,7 +89,6 @@ object DialogUtil {
onPositiveBtnClick = onPositiveBtnClick, onPositiveBtnClick = onPositiveBtnClick,
onNegativeBtnClick = onNegativeBtnClick, onNegativeBtnClick = onNegativeBtnClick,
customView = customView, customView = customView,
cancelable = cancelable,
) )
@JvmStatic @JvmStatic
@ -103,7 +101,6 @@ object DialogUtil {
onPositiveBtnClick: Runnable?, onPositiveBtnClick: Runnable?,
onNegativeBtnClick: Runnable?, onNegativeBtnClick: Runnable?,
customView: View?, customView: View?,
cancelable: Boolean,
): AlertDialog? = ): AlertDialog? =
createAndShowDialogSafely( createAndShowDialogSafely(
activity = activity, activity = activity,
@ -114,7 +111,6 @@ object DialogUtil {
onPositiveBtnClick = onPositiveBtnClick, onPositiveBtnClick = onPositiveBtnClick,
onNegativeBtnClick = onNegativeBtnClick, onNegativeBtnClick = onNegativeBtnClick,
customView = customView, customView = customView,
cancelable = cancelable,
) )
@JvmStatic @JvmStatic
@ -124,7 +120,6 @@ object DialogUtil {
message: String?, message: String?,
positiveButtonText: String?, positiveButtonText: String?,
onPositiveBtnClick: Runnable?, onPositiveBtnClick: Runnable?,
cancelable: Boolean,
): AlertDialog? = ): AlertDialog? =
createAndShowDialogSafely( createAndShowDialogSafely(
activity = activity, activity = activity,
@ -132,7 +127,6 @@ object DialogUtil {
message = message, message = message,
positiveButtonText = positiveButtonText, positiveButtonText = positiveButtonText,
onPositiveBtnClick = onPositiveBtnClick, onPositiveBtnClick = onPositiveBtnClick,
cancelable = cancelable,
) )
/** /**
@ -156,7 +150,7 @@ object DialogUtil {
onPositiveBtnClick: Runnable? = null, onPositiveBtnClick: Runnable? = null,
onNegativeBtnClick: Runnable? = null, onNegativeBtnClick: Runnable? = null,
customView: View? = null, customView: View? = null,
cancelable: Boolean = true, cancelable: Boolean = false,
): AlertDialog? { ): AlertDialog? {
/* If the custom view already has a parent, there is already a dialog showing with the view /* If the custom view already has a parent, there is already a dialog showing with the view
* This happens for on resume - return to avoid creating a second dialog - the first one * This happens for on resume - return to avoid creating a second dialog - the first one

View file

@ -283,7 +283,8 @@ object ImageUtils {
context, context,
context.getString(R.string.setting_wallpaper_dialog_title), context.getString(R.string.setting_wallpaper_dialog_title),
context.getString(R.string.setting_wallpaper_dialog_message), context.getString(R.string.setting_wallpaper_dialog_message),
true true,
false
) )
} }
@ -293,7 +294,8 @@ object ImageUtils {
context, context,
context.getString(R.string.setting_avatar_dialog_title), context.getString(R.string.setting_avatar_dialog_title),
context.getString(R.string.setting_avatar_dialog_message), context.getString(R.string.setting_avatar_dialog_message),
true true,
false
) )
} }

View file

@ -186,7 +186,7 @@ object PermissionUtils {
activity.isShowPermissionsDialog = true activity.isShowPermissionsDialog = true
} }
}, },
null, null, activity !is UploadActivity null, null
) )
} }
else -> Thread(onPermissionDenied).start() else -> Thread(onPermissionDenied).start()
@ -223,7 +223,7 @@ object PermissionUtils {
activity.finish() activity.finish()
} }
}, },
null, false null
) )
} }
}).onSameThread().check() }).onSameThread().check()