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),
positiveButtonRunnable,
() -> {},
spinner,
true);
spinner
);
}
}

View file

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

View file

@ -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()
}

View file

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

View file

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

View file

@ -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)

View file

@ -149,8 +149,7 @@ class DescriptionEditActivity :
getString(titleStringID),
getString(messageStringId),
getString(android.R.string.ok),
null,
true,
null
)
}
@ -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()
}

View file

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

View file

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

View file

@ -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
@ -1616,8 +1615,7 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
onDeleteClickeddialogtext(reason)
},
{},
input,
true
input
)
input.addTextChangedListener(object : TextWatcher {
fun handleText() {

View file

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

View file

@ -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()
}

View file

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

View file

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

View file

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

View file

@ -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()
@ -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) {

View file

@ -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)
}

View file

@ -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
)
}
@ -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()

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),
getString(R.string.ok),
this::finish,
true)));
this::finish)));
}
public void checkStoragePermissions() {
@ -418,16 +417,14 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
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);
}
}
}
@ -754,8 +751,7 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
"",
getString(messageResourceId),
getString(R.string.ok),
onPositiveClick,
false);
onPositiveClick);
}
@Override

View file

@ -346,7 +346,7 @@ public class UploadMediaDetailAdapter extends
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),

View file

@ -105,7 +105,7 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate
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) {

View file

@ -114,7 +114,7 @@ public class DepictsFragment extends UploadBaseFragment implements DepictsContra
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 {

View file

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

View file

@ -309,7 +309,7 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
*/
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);
}
@ -336,6 +336,7 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
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() {
@ -450,7 +451,8 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
// Execute when user cancels the upload of the specified place
UploadActivity.nearbyPopupAnswers.put(place, false);
},
customLayout, true);
customLayout
);
}
}
@ -526,8 +528,7 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
uploadItem.setImageQuality(ImageUtils.IMAGE_KEEP);
onImageValidationSuccess();
}, null,
checkBoxView,
false);
checkBoxView);
} else {
uploadItem.setImageQuality(ImageUtils.IMAGE_KEEP);
onImageValidationSuccess();
@ -588,8 +589,7 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
basicKvStore.putBoolean(keyForShowingAlertDialog, false);
activity.finish();
},
null,
false
null
);
}
} catch (Exception e) {

View file

@ -79,7 +79,6 @@ object DialogUtil {
onPositiveBtnClick: Runnable?,
onNegativeBtnClick: Runnable?,
customView: View?,
cancelable: Boolean,
): AlertDialog? =
createAndShowDialogSafely(
activity = activity,
@ -90,7 +89,6 @@ object DialogUtil {
onPositiveBtnClick = onPositiveBtnClick,
onNegativeBtnClick = onNegativeBtnClick,
customView = customView,
cancelable = cancelable,
)
@JvmStatic
@ -103,7 +101,6 @@ object DialogUtil {
onPositiveBtnClick: Runnable?,
onNegativeBtnClick: Runnable?,
customView: View?,
cancelable: Boolean,
): AlertDialog? =
createAndShowDialogSafely(
activity = activity,
@ -114,7 +111,6 @@ object DialogUtil {
onPositiveBtnClick = onPositiveBtnClick,
onNegativeBtnClick = onNegativeBtnClick,
customView = customView,
cancelable = cancelable,
)
@JvmStatic
@ -124,7 +120,6 @@ object DialogUtil {
message: String?,
positiveButtonText: String?,
onPositiveBtnClick: Runnable?,
cancelable: Boolean,
): AlertDialog? =
createAndShowDialogSafely(
activity = activity,
@ -132,7 +127,6 @@ object DialogUtil {
message = message,
positiveButtonText = positiveButtonText,
onPositiveBtnClick = onPositiveBtnClick,
cancelable = cancelable,
)
/**
@ -156,7 +150,7 @@ object DialogUtil {
onPositiveBtnClick: Runnable? = null,
onNegativeBtnClick: Runnable? = null,
customView: View? = null,
cancelable: Boolean = true,
cancelable: Boolean = false,
): AlertDialog? {
/* 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

View file

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

View file

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