Compare commits

..

1 Commits

Author SHA1 Message Date
Jean-Baptiste
39630381c4 [android] Use Material 3 alert dialogs
Signed-off-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr>
2026-01-01 09:07:21 +01:00
24 changed files with 46 additions and 44 deletions

View File

@@ -446,7 +446,7 @@ public class DownloadResourcesLegacyActivity extends BaseMwmFragmentActivity
default -> throw new AssertionError("Unexpected result code = " + result);
};
mAlertDialog = new MaterialAlertDialogBuilder(this, R.style.MwmTheme_AlertDialog)
mAlertDialog = new MaterialAlertDialogBuilder(this)
.setTitle(titleId)
.setMessage(messageId)
.setCancelable(true)

View File

@@ -432,7 +432,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
}
dismissLocationErrorDialog();
mLocationErrorDialog = new MaterialAlertDialogBuilder(MwmActivity.this, R.style.MwmTheme_AlertDialog)
mLocationErrorDialog = new MaterialAlertDialogBuilder(MwmActivity.this)
.setMessage(R.string.unknown_current_position)
.setCancelable(true)
.setPositiveButton(R.string.ok, null)
@@ -655,7 +655,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
else
{
dismissAlertDialog();
mAlertDialog = new MaterialAlertDialogBuilder(this, R.style.MwmTheme_AlertDialog)
mAlertDialog = new MaterialAlertDialogBuilder(this)
.setTitle(R.string.message_invalid_feature_position)
.setPositiveButton(R.string.ok, null)
.setOnDismissListener(dialog -> mAlertDialog = null)
@@ -1155,7 +1155,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
if (type == IsolinesState.EXPIREDDATA)
{
mAlertDialog = new MaterialAlertDialogBuilder(this, R.style.MwmTheme_AlertDialog)
mAlertDialog = new MaterialAlertDialogBuilder(this)
.setTitle(R.string.downloader_update_maps)
.setMessage(R.string.isolines_activation_error_dialog)
.setPositiveButton(
@@ -1774,7 +1774,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
{
dismissAlertDialog();
mAlertDialog =
new MaterialAlertDialogBuilder(this, R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(this)
.setTitle(R.string.unable_to_calc_alert_title)
.setMessage(R.string.unable_to_calc_alert_subtitle)
.setPositiveButton(R.string.settings,
@@ -1797,7 +1797,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
builder.append(getString(resId)).append("\n\n");
dismissAlertDialog();
mAlertDialog = new MaterialAlertDialogBuilder(this, R.style.MwmTheme_AlertDialog)
mAlertDialog = new MaterialAlertDialogBuilder(this)
.setTitle(R.string.dialog_routing_disclaimer_title)
.setMessage(builder.toString())
.setCancelable(false)
@@ -1846,7 +1846,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
return true;
final MapObject endPoint = Objects.requireNonNull(controller.getEndPoint());
final MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this, R.style.MwmTheme_AlertDialog)
final MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this)
.setTitle(R.string.p2p_only_from_current)
.setMessage(R.string.p2p_reroute_from_current)
.setCancelable(false)
@@ -2040,7 +2040,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
{
mPreciseLocationDialogShown = true;
final MaterialAlertDialogBuilder builder =
new MaterialAlertDialogBuilder(this, R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(this)
.setTitle("" + getString(R.string.limited_accuracy))
.setMessage(R.string.precise_location_is_disabled_long_text)
.setNegativeButton(R.string.close, (dialog, which) -> dialog.dismiss())
@@ -2074,7 +2074,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
return;
}
mLocationErrorDialog = new MaterialAlertDialogBuilder(this, R.style.MwmTheme_AlertDialog)
mLocationErrorDialog = new MaterialAlertDialogBuilder(this)
.setTitle(R.string.enable_location_services)
.setMessage(R.string.location_is_disabled_long_text)
.setOnDismissListener(dialog -> mLocationErrorDialog = null)
@@ -2167,7 +2167,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
return;
}
final MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this, R.style.MwmTheme_AlertDialog)
final MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this)
.setTitle(R.string.enable_location_services)
.setMessage(R.string.location_is_disabled_long_text)
.setOnDismissListener(dialog -> mLocationErrorDialog = null)
@@ -2253,7 +2253,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
dismissAlertDialog();
final MaterialAlertDialogBuilder builder =
new MaterialAlertDialogBuilder(this, R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(this)
.setTitle(R.string.current_location_unknown_error_title)
.setCancelable(true)
.setMessage(R.string.power_save_dialog_summary)
@@ -2278,7 +2278,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
{
dismissAlertDialog();
mAlertDialog =
new MaterialAlertDialogBuilder(this, R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(this)
.setTitle(R.string.load_kmz_title)
.setMessage(getString(R.string.unknown_file_type, uri))
.setPositiveButton(R.string.ok, null)
@@ -2295,7 +2295,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
{
dismissAlertDialog();
mAlertDialog =
new MaterialAlertDialogBuilder(this, R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(this)
.setTitle(R.string.load_kmz_title)
.setMessage(getString(R.string.failed_to_open_file, uri, error))
.setPositiveButton(R.string.ok, null)
@@ -2317,7 +2317,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
public void onBookmarksFileImportFailed()
{
dismissAlertDialog();
mAlertDialog = new MaterialAlertDialogBuilder(this, R.style.MwmTheme_AlertDialog)
mAlertDialog = new MaterialAlertDialogBuilder(this)
.setTitle(R.string.load_kmz_title)
.setMessage(R.string.load_kmz_failed)
.setPositiveButton(R.string.ok, null)
@@ -2578,7 +2578,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
private void reportUnsupported()
{
new MaterialAlertDialogBuilder(this, R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(this)
.setMessage(R.string.unsupported_phone)
.setCancelable(false)
.setPositiveButton(R.string.close, (dlg, which) -> this.moveTaskToBack(true))

View File

@@ -120,7 +120,7 @@ public class SplashActivity extends AppCompatActivity
private void showFatalErrorDialog(@StringRes int titleId, @StringRes int messageId, Exception error)
{
mCanceled = true;
new MaterialAlertDialogBuilder(this, R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(this)
.setTitle(titleId)
.setMessage(messageId)
.setPositiveButton(

View File

@@ -60,14 +60,14 @@ public enum BookmarksSharingHelper
case BookmarkSharingResult.SUCCESS ->
SharingUtils.shareBookmarkFile(context, launcher, result.getSharingPath(), result.getMimeType());
case BookmarkSharingResult.EMPTY_CATEGORY ->
new MaterialAlertDialogBuilder(context, R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(context)
.setTitle(R.string.bookmarks_error_title_share_empty)
.setMessage(R.string.bookmarks_error_message_share_empty)
.setPositiveButton(R.string.ok, null)
.show();
case BookmarkSharingResult.ARCHIVE_ERROR, BookmarkSharingResult.FILE_ERROR ->
{
new MaterialAlertDialogBuilder(context, R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(context)
.setTitle(R.string.dialog_routing_system_error)
.setMessage(R.string.bookmarks_error_message_share_general)
.setPositiveButton(R.string.ok, null)

View File

@@ -42,7 +42,7 @@ public final class CustomMapServerDialog
edit.setText(current);
MaterialAlertDialogBuilder builder =
new MaterialAlertDialogBuilder(context, R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(context)
.setTitle(R.string.download_resources_custom_url_title)
.setMessage(R.string.download_resources_custom_url_message)
.setView(dialogView)

View File

@@ -113,7 +113,7 @@ public class EditTextDialogFragment extends BaseMwmDialogFragment
negativeButtonText = args.getString(ARG_NEGATIVE_BUTTON);
}
AlertDialog editTextDialog = new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog)
AlertDialog editTextDialog = new MaterialAlertDialogBuilder(requireActivity())
.setView(buildView())
.setNegativeButton(negativeButtonText, null)
.setPositiveButton(positiveButtonText, null)

View File

@@ -119,7 +119,7 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
{
if (RoutingController.get().isNavigating())
{
new MaterialAlertDialogBuilder(adapter.mActivity, R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(adapter.mActivity)
.setTitle(R.string.downloader_delete_map)
.setMessage(R.string.downloader_delete_map_while_routing_dialog)
.setPositiveButton(R.string.ok, null)
@@ -133,7 +133,7 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
return;
}
new MaterialAlertDialogBuilder(adapter.mActivity, R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(adapter.mActivity)
.setTitle(R.string.downloader_delete_map)
.setMessage(R.string.downloader_delete_map_dialog)
.setNegativeButton(R.string.cancel, null)

View File

@@ -49,7 +49,7 @@ public class MapManagerHelper
return;
}
final AlertDialog dlg = new MaterialAlertDialogBuilder(activity, R.style.MwmTheme_AlertDialog)
final AlertDialog dlg = new MaterialAlertDialogBuilder(activity)
.setTitle(R.string.country_status_download_failed)
.setMessage(getErrorCodeStrRes(errorData.errorCode))
.setNegativeButton(R.string.cancel,
@@ -72,7 +72,7 @@ public class MapManagerHelper
private static void notifyNoSpaceInternal(Activity activity)
{
new MaterialAlertDialogBuilder(activity, R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(activity)
.setTitle(R.string.downloader_no_space_title)
.setMessage(R.string.downloader_no_space_message)
.setPositiveButton(android.R.string.ok, null)
@@ -123,7 +123,7 @@ public class MapManagerHelper
return false;
}
new MaterialAlertDialogBuilder(activity, R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(activity)
.setTitle(R.string.download_over_mobile_header)
.setMessage(R.string.download_over_mobile_message)
.setNegativeButton(R.string.cancel, null)

View File

@@ -493,7 +493,7 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
}
});
return new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog)
return new MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.editor_socket)
.setView(dialogView)
.setPositiveButton(R.string.save,
@@ -997,7 +997,7 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
message = R.string.editor_reset_edits_message;
}
new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(requireActivity())
.setTitle(message)
.setPositiveButton(title,
(dialog, which) -> {
@@ -1020,7 +1020,7 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
private void placeDisused()
{
new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.editor_mark_business_vacant_title)
.setMessage(R.string.editor_mark_business_vacant_description)
.setPositiveButton(R.string.editor_submit, (dlg, which) -> {

View File

@@ -352,7 +352,7 @@ public class EditorHostFragment
private void processNoFeatures()
{
new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.downloader_no_space_title)
.setPositiveButton(R.string.ok, null)
.show();
@@ -386,7 +386,7 @@ public class EditorHostFragment
private void showNoobDialog()
{
new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.editor_share_to_all_dialog_title)
.setMessage(getString(R.string.editor_share_to_all_dialog_message_1) + " "
+ getString(R.string.editor_share_to_all_dialog_message_2))

View File

@@ -155,7 +155,7 @@ public class FeatureCategoryFragment
// Duplicate of showNoobDialog()
private void showNoteConfirmationDialog(double lat, double lon, String noteText)
{
new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.editor_share_to_all_dialog_title)
.setMessage(getString(R.string.editor_share_to_all_dialog_message_1) + " "
+ getString(R.string.editor_share_to_all_dialog_message_2))

View File

@@ -79,7 +79,7 @@ public class OsmLoginFragment extends BaseMwmToolbarFragment
private void onAuthFail()
{
new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.editor_login_error_dialog)
.setPositiveButton(R.string.ok, null)
.show();

View File

@@ -66,7 +66,7 @@ public class FaqFragment extends BaseMwmFragment
FloatingActionButton feedbackFab = root.findViewById(R.id.feedback_fab);
feedbackFab.setOnClickListener(
v
-> new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog)
-> new MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.feedback)
.setNegativeButton(R.string.cancel, null)
.setItems(new CharSequence[] {getString(R.string.feedback_general), getString(R.string.report_a_bug)},

View File

@@ -107,7 +107,7 @@ public class TrafficButtonController implements TrafficManager.TrafficCallback
if (mDialog != null && mDialog.isShowing())
return;
mDialog = new MaterialAlertDialogBuilder(mActivity, R.style.MwmTheme_AlertDialog)
mDialog = new MaterialAlertDialogBuilder(mActivity)
.setMessage(R.string.common_check_internet_connection_dialog)
.setPositiveButton(R.string.ok, (dialog, which) -> TrafficManager.INSTANCE.setEnabled(false))
.setCancelable(true)

View File

@@ -56,7 +56,7 @@ abstract class BaseRoutingErrorDialogFragment extends BaseMwmDialogFragment
public Dialog onCreateDialog(Bundle savedInstanceState)
{
parseArguments();
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog)
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireActivity())
.setCancelable(true)
.setNegativeButton(android.R.string.cancel, null);
beforeDialogCreated(builder);

View File

@@ -494,7 +494,7 @@ public class SettingsPrefsFragment extends BaseXmlSettingsFragment implements La
pref.setOnPreferenceClickListener(preference -> {
if (MapManager.nativeIsDownloading())
{
new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.downloading_is_active)
.setMessage(R.string.cant_change_this_setting)
.setPositiveButton(R.string.ok, null)

View File

@@ -97,7 +97,7 @@ public class StoragePathFragment extends BaseSettingsFragment
final String oldPath = storages.get(currentIndex).mPath;
final String newPath = storages.get(newIndex).mPath;
new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(requireActivity())
.setCancelable(false)
.setTitle(R.string.move_maps)
.setPositiveButton(R.string.ok, (dlg, which) -> moveStorage(newPath, oldPath))
@@ -133,7 +133,7 @@ public class StoragePathFragment extends BaseSettingsFragment
if (!result)
{
new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog)
new MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.move_maps_error)
.setPositiveButton(
R.string.report_a_bug,

View File

@@ -47,7 +47,7 @@ public class BookmarkColorDialogFragment extends BaseMwmDialogFragment
mIconResId = getArguments().getInt(ICON_RES);
}
return new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog)
return new MaterialAlertDialogBuilder(requireActivity())
.setView(buildView())
.setTitle(R.string.choose_color)
.setNegativeButton(R.string.cancel, null)

View File

@@ -464,7 +464,7 @@ public class PlacePageController
mAlertDialog.show();
return;
}
mAlertDialog = new MaterialAlertDialogBuilder(requireContext(), R.style.MwmTheme_AlertDialog)
mAlertDialog = new MaterialAlertDialogBuilder(requireContext())
.setTitle(requireContext().getString(R.string.delete_track_dialog_title, mMapObject.getTitle()))
.setCancelable(true)
.setNegativeButton(R.string.cancel, null)

View File

@@ -924,6 +924,6 @@
<string name="advanced">Avancé</string>
<string name="download_resources_custom_url_summary_none">Non défini</string>
<string name="download_resources_custom_url_title">Serveur de cartes personnalisé</string>
<string name="download_resources_custom_url_error_scheme">Veuillez saisir une URL complète commençant par http:// ou https://</string>
<string name="download_resources_custom_url_error_scheme">Veuillez saisir une URL complète débutant par https:// et se terminant par /</string>
<string name="download_resources_custom_url_message">Serveur pour télécharger les cartes. Laissez vide pour utiliser le serveur par défaut CoMaps.</string>
</resources>

View File

@@ -21,7 +21,7 @@
<item name="android:statusBarColor">?colorPrimary</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="alertDialogTheme">@style/MwmTheme.AlertDialog</item>
<item name="alertDialogTheme">@style/MaterialAlertDialog.Material3</item>
<item name="windowBackgroundForced">@color/bg_window</item>
<item name="cardBackground">@color/bg_cards</item>
<item name="titleDialogTheme">@color/white_primary</item>

View File

@@ -972,5 +972,5 @@
<string name="download_resources_custom_url_title">Custom Map Server</string>
<string name="download_resources_custom_url_message">Override the default map download server used for map downloads. Leave empty to use CoMaps default server.</string>
<string name="download_resources_custom_url_summary_none">Not set</string>
<string name="download_resources_custom_url_error_scheme">Please enter a URL starting with http:// or https://</string>
<string name="download_resources_custom_url_error_scheme">Please enter a full URL starting with https:// and ending with /</string>
</resources>

View File

@@ -2,6 +2,8 @@
<resources>
<style name="MwmTextAppearance" parent="android:TextAppearance.Material">
<item name="android:fontFamily">@string/robotoRegular</item>
<!-- Force normal textStyle. Some devices (eg Lenovo P70), uses non-normal textStyle by default. -->
<item name="android:textStyle">normal</item>
</style>
<style name="MwmTextAppearance.Title">

View File

@@ -20,7 +20,7 @@
<item name="android:windowActionBarOverlay">true</item>
<item name="clickableBackground">?selectableItemBackground</item>
<item name="android:statusBarColor">?colorPrimary</item>
<item name="alertDialogTheme">@style/MwmTheme.AlertDialog</item>
<item name="alertDialogTheme">@style/MaterialAlertDialog.Material3</item>
<item name="windowBackgroundForced">@color/bg_window</item>
<item name="cardBackground">@color/bg_cards</item>
<item name="titleDialogTheme">@color/black_primary</item>