forked from organicmaps/organicmaps
[android] Switch to use the stock AlertDialog everywhere
Remove our own implementation of AlertDialog, all useless wrappers and abstract factories. Swtch to `androidx.appcompat.app.AlertDialog`. This patch also sets `MwmTheme.AlertDialog` theme to all AlertDialogs and replaces old-style Java callbacks with lambdas. Signed-off-by: Roman Tsisyk <roman@tsisyk.com>
This commit is contained in:
parent
7a3a555437
commit
03910b3a43
32 changed files with 246 additions and 1075 deletions
|
@ -16,11 +16,10 @@ import androidx.annotation.CallSuper;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.mapswithme.maps.api.ParsedMwmRequest;
|
||||
import com.mapswithme.maps.base.BaseMwmFragmentActivity;
|
||||
import com.mapswithme.maps.dialog.AlertDialog;
|
||||
import com.mapswithme.maps.dialog.AlertDialogCallback;
|
||||
import com.mapswithme.maps.downloader.CountryItem;
|
||||
import com.mapswithme.maps.downloader.MapManager;
|
||||
import com.mapswithme.maps.intent.Factory;
|
||||
|
@ -38,13 +37,10 @@ import com.mapswithme.util.log.Logger;
|
|||
import java.util.List;
|
||||
|
||||
@SuppressLint("StringFormatMatches")
|
||||
public class DownloadResourcesLegacyActivity extends BaseMwmFragmentActivity implements AlertDialogCallback
|
||||
public class DownloadResourcesLegacyActivity extends BaseMwmFragmentActivity
|
||||
{
|
||||
private static final String TAG = DownloadResourcesLegacyActivity.class.getSimpleName();
|
||||
|
||||
private static final String ERROR_LOADING_DIALOG_TAG = "error_loading_dialog";
|
||||
private static final int ERROR_LOADING_DIALOG_REQ_CODE = 234;
|
||||
|
||||
private static final int REQ_CODE_API_RESULT = 10;
|
||||
|
||||
public static final String EXTRA_COUNTRY = "country";
|
||||
|
@ -342,40 +338,6 @@ public class DownloadResourcesLegacyActivity extends BaseMwmFragmentActivity imp
|
|||
showMap();
|
||||
}
|
||||
|
||||
private static @StringRes int getErrorMessage(int res)
|
||||
{
|
||||
switch (res)
|
||||
{
|
||||
case ERR_NOT_ENOUGH_FREE_SPACE:
|
||||
return R.string.not_enough_free_space_on_sdcard;
|
||||
case ERR_STORAGE_DISCONNECTED:
|
||||
return R.string.disconnect_usb_cable;
|
||||
case ERR_DOWNLOAD_ERROR:
|
||||
return (ConnectionState.INSTANCE.isConnected() ? R.string.download_has_failed
|
||||
: R.string.common_check_internet_connection_dialog);
|
||||
default:
|
||||
assert(res == ERR_DISK_ERROR);
|
||||
return R.string.disk_error;
|
||||
}
|
||||
}
|
||||
|
||||
@StringRes
|
||||
private static int getErrorTitle(int res)
|
||||
{
|
||||
switch (res)
|
||||
{
|
||||
case ERR_NOT_ENOUGH_FREE_SPACE:
|
||||
return R.string.routing_not_enough_space;
|
||||
case ERR_STORAGE_DISCONNECTED:
|
||||
return R.string.disconnect_usb_cable_title;
|
||||
case ERR_DOWNLOAD_ERROR:
|
||||
return R.string.connection_failure;
|
||||
default:
|
||||
assert(res == ERR_DISK_ERROR);
|
||||
return R.string.disk_error_title;
|
||||
}
|
||||
}
|
||||
|
||||
public void showMap()
|
||||
{
|
||||
if (!mAreResourcesDownloaded)
|
||||
|
@ -470,33 +432,42 @@ public class DownloadResourcesLegacyActivity extends BaseMwmFragmentActivity imp
|
|||
|
||||
private void showErrorDialog(int result)
|
||||
{
|
||||
AlertDialog dialog = new AlertDialog.Builder()
|
||||
.setTitleId(getErrorTitle(result))
|
||||
.setMessageId(getErrorMessage(result))
|
||||
.setPositiveBtnId(R.string.try_again)
|
||||
.setReqCode(ERROR_LOADING_DIALOG_REQ_CODE)
|
||||
.setFragManagerStrategyType(AlertDialog.FragManagerStrategyType.ACTIVITY_FRAGMENT_MANAGER)
|
||||
.build();
|
||||
dialog.show(this, ERROR_LOADING_DIALOG_TAG);
|
||||
}
|
||||
@StringRes final int titleId;
|
||||
@StringRes final int messageId;
|
||||
|
||||
@Override
|
||||
public void onAlertDialogPositiveClick(int requestCode, int which)
|
||||
{
|
||||
setAction(TRY_AGAIN);
|
||||
onTryAgainClicked();
|
||||
}
|
||||
switch (result)
|
||||
{
|
||||
case ERR_NOT_ENOUGH_FREE_SPACE:
|
||||
titleId = R.string.routing_not_enough_space;
|
||||
messageId = R.string.not_enough_free_space_on_sdcard;
|
||||
break;
|
||||
case ERR_STORAGE_DISCONNECTED:
|
||||
titleId = R.string.disconnect_usb_cable_title;
|
||||
messageId = R.string.disconnect_usb_cable;
|
||||
break;
|
||||
case ERR_DOWNLOAD_ERROR:
|
||||
titleId = R.string.connection_failure;
|
||||
messageId = (ConnectionState.INSTANCE.isConnected() ? R.string.download_has_failed
|
||||
: R.string.common_check_internet_connection_dialog);
|
||||
break;
|
||||
case ERR_DISK_ERROR:
|
||||
titleId = R.string.disk_error_title;
|
||||
messageId = R.string.disk_error;
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError("Unexpected result code = " + result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAlertDialogNegativeClick(int requestCode, int which)
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAlertDialogCancel(int requestCode)
|
||||
{
|
||||
setAction(PAUSE);
|
||||
new AlertDialog.Builder(this, R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(titleId)
|
||||
.setMessage(messageId)
|
||||
.setCancelable(true)
|
||||
.setOnCancelListener((dialog) -> setAction(PAUSE))
|
||||
.setPositiveButton(R.string.try_again, (dialog, which) -> {
|
||||
setAction(TRY_AGAIN);
|
||||
onTryAgainClicked();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private static native int nativeGetBytesToDownload();
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.mapswithme.maps;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
|
@ -16,6 +15,7 @@ import android.view.ViewGroup;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.mapswithme.maps.base.BaseMwmFragment;
|
||||
import com.mapswithme.maps.location.LocationHelper;
|
||||
import com.mapswithme.util.Config;
|
||||
|
@ -160,17 +160,11 @@ public class MapFragment extends BaseMwmFragment
|
|||
|
||||
private void reportUnsupported()
|
||||
{
|
||||
new AlertDialog.Builder(requireActivity())
|
||||
.setMessage(getString(R.string.unsupported_phone))
|
||||
new AlertDialog.Builder(requireActivity(), R.style.MwmTheme_AlertDialog)
|
||||
.setMessage(R.string.unsupported_phone)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.close), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
requireActivity().moveTaskToBack(true);
|
||||
}
|
||||
}).show();
|
||||
.setPositiveButton(R.string.close, (dlg, which) -> requireActivity().moveTaskToBack(true))
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,7 +5,6 @@ import static com.mapswithme.maps.widget.placepage.PlacePageButtons.PLACEPAGE_MO
|
|||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.location.Location;
|
||||
import android.net.Uri;
|
||||
|
@ -27,7 +26,6 @@ import androidx.appcompat.app.AlertDialog;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentFactory;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
@ -45,8 +43,6 @@ import com.mapswithme.maps.bookmarks.data.BookmarkInfo;
|
|||
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
||||
import com.mapswithme.maps.bookmarks.data.MapObject;
|
||||
import com.mapswithme.maps.bookmarks.data.Track;
|
||||
import com.mapswithme.maps.dialog.AlertDialogCallback;
|
||||
import com.mapswithme.maps.dialog.DialogUtils;
|
||||
import com.mapswithme.maps.downloader.DownloaderActivity;
|
||||
import com.mapswithme.maps.downloader.DownloaderFragment;
|
||||
import com.mapswithme.maps.downloader.MapManager;
|
||||
|
@ -117,7 +113,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
BookmarkManager.BookmarksLoadingListener,
|
||||
FloatingSearchToolbarController.SearchToolbarListener,
|
||||
PlacePageController.SlideListener,
|
||||
AlertDialogCallback, RoutingModeListener,
|
||||
RoutingModeListener,
|
||||
AppBackgroundTracker.OnTransitionListener,
|
||||
NoConnectionListener,
|
||||
MenuBottomSheetFragment.MenuBottomSheetInterfaceWithHeader,
|
||||
|
@ -323,10 +319,10 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
return;
|
||||
}
|
||||
|
||||
new AlertDialog.Builder(MwmActivity.this)
|
||||
new AlertDialog.Builder(MwmActivity.this, R.style.MwmTheme_AlertDialog)
|
||||
.setMessage(R.string.unknown_current_position)
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
|
@ -445,11 +441,11 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
@Override
|
||||
public void onNoConnectionError()
|
||||
{
|
||||
DialogInterface.OnClickListener listener = (dialog, which) -> {
|
||||
};
|
||||
DialogUtils.showAlertDialog(this, R.string.common_check_internet_connection_dialog_title,
|
||||
R.string.common_check_internet_connection_dialog,
|
||||
R.string.ok, listener);
|
||||
new AlertDialog.Builder(this, R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.common_check_internet_connection_dialog_title)
|
||||
.setMessage(R.string.common_check_internet_connection_dialog)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void initViews(boolean isLaunchByDeeplink)
|
||||
|
@ -503,7 +499,12 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
if (Framework.nativeIsDownloadedMapAtScreenCenter())
|
||||
startActivity(new Intent(MwmActivity.this, FeatureCategoryActivity.class));
|
||||
else
|
||||
DialogUtils.showAlertDialog(MwmActivity.this, R.string.message_invalid_feature_position);
|
||||
{
|
||||
new AlertDialog.Builder(this, R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.message_invalid_feature_position)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show();
|
||||
}
|
||||
break;
|
||||
case NONE:
|
||||
throw new IllegalStateException("Unexpected mPositionChooserMode");
|
||||
|
@ -920,15 +921,12 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
return;
|
||||
}
|
||||
|
||||
com.mapswithme.maps.dialog.AlertDialog dialog = new com.mapswithme.maps.dialog.AlertDialog.Builder()
|
||||
.setTitleId(R.string.downloader_update_maps)
|
||||
.setMessageId(R.string.isolines_activation_error_dialog)
|
||||
.setPositiveBtnId(R.string.ok)
|
||||
.setNegativeBtnId(R.string.cancel)
|
||||
.setFragManagerStrategyType(com.mapswithme.maps.dialog.AlertDialog.FragManagerStrategyType.ACTIVITY_FRAGMENT_MANAGER)
|
||||
.setReqCode(REQ_CODE_ISOLINES_ERROR)
|
||||
.build();
|
||||
dialog.show(this, ISOLINES_ERROR_DIALOG_TAG);
|
||||
new AlertDialog.Builder(this, R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.downloader_update_maps)
|
||||
.setMessage(R.string.isolines_activation_error_dialog)
|
||||
.setPositiveButton(R.string.ok, (dialog, which) -> startActivity(new Intent(this, DownloaderActivity.class)))
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1589,17 +1587,12 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
@Override
|
||||
public void onDrivingOptionsBuildError()
|
||||
{
|
||||
com.mapswithme.maps.dialog.AlertDialog dialog =
|
||||
new com.mapswithme.maps.dialog.AlertDialog.Builder()
|
||||
.setTitleId(R.string.unable_to_calc_alert_title)
|
||||
.setMessageId(R.string.unable_to_calc_alert_subtitle)
|
||||
.setPositiveBtnId(R.string.settings)
|
||||
.setNegativeBtnId(R.string.cancel)
|
||||
.setReqCode(REQ_CODE_ERROR_DRIVING_OPTIONS_DIALOG)
|
||||
.setFragManagerStrategyType(com.mapswithme.maps.dialog.AlertDialog
|
||||
.FragManagerStrategyType.ACTIVITY_FRAGMENT_MANAGER)
|
||||
.build();
|
||||
dialog.show(this, ERROR_DRIVING_OPTIONS_DIALOG_TAG);
|
||||
new AlertDialog.Builder(this, R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.unable_to_calc_alert_title)
|
||||
.setMessage(R.string.unable_to_calc_alert_subtitle)
|
||||
.setPositiveButton(R.string.settings, (dialog, which) -> DrivingOptionsActivity.start(this))
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1681,27 +1674,6 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAlertDialogPositiveClick(int requestCode, int which)
|
||||
{
|
||||
if (requestCode == REQ_CODE_ERROR_DRIVING_OPTIONS_DIALOG)
|
||||
DrivingOptionsActivity.start(this);
|
||||
else if (requestCode == REQ_CODE_ISOLINES_ERROR)
|
||||
startActivity(new Intent(this, DownloaderActivity.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAlertDialogNegativeClick(int requestCode, int which)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAlertDialogCancel(int requestCode)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBookmarksFileLoaded(boolean success)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,6 @@ import static android.Manifest.permission.ACCESS_FINE_LOCATION;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
|
@ -133,20 +132,12 @@ public class SplashActivity extends AppCompatActivity implements BaseActivity
|
|||
private void showFatalErrorDialog(@StringRes int titleId, @StringRes int messageId)
|
||||
{
|
||||
mCanceled = true;
|
||||
AlertDialog dialog = new AlertDialog.Builder(this)
|
||||
new AlertDialog.Builder(this, R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(titleId)
|
||||
.setMessage(messageId)
|
||||
.setNegativeButton(R.string.ok, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
SplashActivity.this.finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.ok, (dialog, which) -> SplashActivity.this.finish())
|
||||
.setCancelable(false)
|
||||
.create();
|
||||
dialog.show();
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,7 +25,6 @@ import com.mapswithme.maps.base.DataChangedListener;
|
|||
import com.mapswithme.maps.bookmarks.data.BookmarkCategory;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkSharingResult;
|
||||
import com.mapswithme.maps.dialog.DialogUtils;
|
||||
import com.mapswithme.maps.dialog.EditTextDialogFragment;
|
||||
import com.mapswithme.maps.widget.PlaceholderView;
|
||||
import com.mapswithme.maps.widget.recycler.DividerItemDecorationWithPadding;
|
||||
|
@ -296,7 +295,11 @@ public class BookmarkCategoriesFragment extends BaseMwmRecyclerFragment<Bookmark
|
|||
|
||||
final Context context = requireActivity();
|
||||
final Uri rootUri = data.getData();
|
||||
final ProgressDialog dialog = DialogUtils.createModalProgressDialog(context, R.string.wait_several_minutes);
|
||||
final ProgressDialog dialog = new ProgressDialog(context, R.style.MwmTheme_AlertDialog);
|
||||
dialog.setMessage(getString(R.string.wait_several_minutes));
|
||||
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||
dialog.setIndeterminate(true);
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
Logger.d(TAG, "Importing bookmarks from " + rootUri);
|
||||
MwmApplication app = MwmApplication.from(context);
|
||||
|
|
|
@ -13,12 +13,12 @@ import android.widget.EditText;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmToolbarFragment;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkCategory;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
||||
import com.mapswithme.maps.dialog.DialogUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -114,15 +114,21 @@ public class BookmarkCategorySettingsFragment extends BaseMwmToolbarFragment
|
|||
{
|
||||
if (TextUtils.isEmpty(name))
|
||||
{
|
||||
DialogUtils.showAlertDialog(requireContext(), R.string.bookmarks_error_title_empty_list_name,
|
||||
R.string.bookmarks_error_message_empty_list_name);
|
||||
new AlertDialog.Builder(requireActivity(), R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.bookmarks_error_title_empty_list_name)
|
||||
.setMessage(R.string.bookmarks_error_message_empty_list_name)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (BookmarkManager.INSTANCE.isUsedCategoryName(name) && !TextUtils.equals(name, mCategory.getName()))
|
||||
{
|
||||
DialogUtils.showAlertDialog(requireContext(), R.string.bookmarks_error_title_list_name_already_taken,
|
||||
R.string.bookmarks_error_message_list_name_already_taken);
|
||||
new AlertDialog.Builder(requireActivity(), R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.bookmarks_error_title_list_name_already_taken)
|
||||
.setMessage(R.string.bookmarks_error_message_list_name_already_taken)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -5,10 +5,12 @@ import android.app.ProgressDialog;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkSharingResult;
|
||||
import com.mapswithme.maps.dialog.DialogUtils;
|
||||
import com.mapswithme.util.SharingUtils;
|
||||
import com.mapswithme.util.log.Logger;
|
||||
|
||||
|
@ -23,12 +25,16 @@ public enum BookmarksSharingHelper
|
|||
|
||||
public void prepareBookmarkCategoryForSharing(@NonNull Activity context, long catId)
|
||||
{
|
||||
mProgressDialog = DialogUtils.createModalProgressDialog(context, R.string.please_wait);
|
||||
mProgressDialog = new ProgressDialog(context, R.style.MwmTheme_AlertDialog);
|
||||
mProgressDialog.setMessage(context.getString(R.string.please_wait));
|
||||
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||
mProgressDialog.setIndeterminate(true);
|
||||
mProgressDialog.setCancelable(false);
|
||||
mProgressDialog.show();
|
||||
BookmarkManager.INSTANCE.prepareCategoryForSharing(catId);
|
||||
}
|
||||
|
||||
public void onPreparedFileForSharing(@NonNull Activity context,
|
||||
public void onPreparedFileForSharing(@NonNull FragmentActivity context,
|
||||
@NonNull BookmarkSharingResult result)
|
||||
{
|
||||
if (mProgressDialog != null && mProgressDialog.isShowing())
|
||||
|
@ -40,13 +46,19 @@ public enum BookmarksSharingHelper
|
|||
SharingUtils.shareBookmarkFile(context, result.getSharingPath());
|
||||
break;
|
||||
case BookmarkSharingResult.EMPTY_CATEGORY:
|
||||
DialogUtils.showAlertDialog(context, R.string.bookmarks_error_title_share_empty,
|
||||
R.string.bookmarks_error_message_share_empty);
|
||||
new AlertDialog.Builder(context, R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.bookmarks_error_title_share_empty)
|
||||
.setMessage(R.string.bookmarks_error_message_share_empty)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show();
|
||||
break;
|
||||
case BookmarkSharingResult.ARCHIVE_ERROR:
|
||||
case BookmarkSharingResult.FILE_ERROR:
|
||||
DialogUtils.showAlertDialog(context, R.string.dialog_routing_system_error,
|
||||
R.string.bookmarks_error_message_share_general);
|
||||
new AlertDialog.Builder(context, R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.dialog_routing_system_error)
|
||||
.setMessage(R.string.bookmarks_error_message_share_general)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show();
|
||||
String catName = BookmarkManager.INSTANCE.getCategoryById(result.getCategoryId()).getName();
|
||||
Logger.e(TAG, "Failed to share bookmark category '" + catName + "', error code: " + result.getCode());
|
||||
break;
|
||||
|
|
|
@ -8,7 +8,6 @@ import androidx.annotation.Nullable;
|
|||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
||||
import com.mapswithme.maps.dialog.DialogUtils;
|
||||
import com.mapswithme.maps.dialog.EditTextDialogFragment;
|
||||
import com.mapswithme.util.Option;
|
||||
|
||||
|
|
|
@ -1,510 +0,0 @@
|
|||
package com.mapswithme.maps.dialog;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.app.AppCompatDialog;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmDialogFragment;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.log.Logger;
|
||||
|
||||
public class AlertDialog extends BaseMwmDialogFragment
|
||||
{
|
||||
private static final String TAG = AlertDialog.class.getSimpleName();
|
||||
|
||||
private static final String ARG_TITLE_ID = "arg_title_id";
|
||||
private static final String ARG_MESSAGE_ID = "arg_message_id";
|
||||
private static final String ARG_POSITIVE_BUTTON_ID = "arg_positive_button_id";
|
||||
private static final String ARG_NEGATIVE_BUTTON_ID = "arg_negative_button_id";
|
||||
private static final String ARG_IMAGE_RES_ID = "arg_image_res_id";
|
||||
private static final String ARG_NEGATIVE_BTN_TEXT_COLOR_RES_ID = "arg_neg_btn_text_color_res_id";
|
||||
private static final String ARG_REQ_CODE = "arg_req_code";
|
||||
private static final String ARG_FRAGMENT_MANAGER_STRATEGY_INDEX = "arg_fragment_manager_strategy_index";
|
||||
private static final String ARG_DIALOG_VIEW_STRATEGY_INDEX = "arg_dialog_view_strategy_index";
|
||||
|
||||
private static final int INVALID_ID = -1;
|
||||
|
||||
@Nullable
|
||||
private AlertDialogCallback mTargetCallback;
|
||||
|
||||
@NonNull
|
||||
private ResolveFragmentManagerStrategy mFragmentManagerStrategy = new ChildFragmentManagerStrategy();
|
||||
|
||||
@NonNull
|
||||
private ResolveDialogViewStrategy mDialogViewStrategy = new AlertDialogStrategy();
|
||||
|
||||
public void show(@NonNull Fragment parent, @Nullable String tag)
|
||||
{
|
||||
FragmentManager fm = mFragmentManagerStrategy.resolve(parent);
|
||||
if (fm.findFragmentByTag(tag) != null)
|
||||
return;
|
||||
|
||||
showInternal(tag, fm);
|
||||
}
|
||||
|
||||
public void show(@NonNull FragmentActivity activity, @Nullable String tag)
|
||||
{
|
||||
FragmentManager fm = mFragmentManagerStrategy.resolve(activity);
|
||||
if (fm.findFragmentByTag(tag) != null)
|
||||
return;
|
||||
|
||||
showInternal(tag, fm);
|
||||
}
|
||||
|
||||
private void showInternal(@Nullable String tag, @NonNull FragmentManager fm)
|
||||
{
|
||||
FragmentTransaction transaction = fm.beginTransaction();
|
||||
transaction.add(this, tag);
|
||||
transaction.commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
@LayoutRes
|
||||
protected int getLayoutId()
|
||||
{
|
||||
throw new UnsupportedOperationException("By default, you " +
|
||||
"shouldn't implement this method." +
|
||||
" AlertDialog.Builder will do everything by itself. " +
|
||||
"But if you want to use this method, " +
|
||||
"you'll have to implement it");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context)
|
||||
{
|
||||
super.onAttach(context);
|
||||
try
|
||||
{
|
||||
onAttachInternal();
|
||||
}
|
||||
catch (ClassCastException e)
|
||||
{
|
||||
Logger.w(TAG, "Caller doesn't implement AlertDialogCallback interface.");
|
||||
}
|
||||
}
|
||||
|
||||
private void onAttachInternal()
|
||||
{
|
||||
mTargetCallback = (AlertDialogCallback) (getParentFragment() == null ? getTargetFragment()
|
||||
: getParentFragment());
|
||||
if (mTargetCallback != null)
|
||||
return;
|
||||
|
||||
if (!(requireActivity() instanceof AlertDialogCallback))
|
||||
return;
|
||||
|
||||
mTargetCallback = (AlertDialogCallback) requireActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach()
|
||||
{
|
||||
super.onDetach();
|
||||
mTargetCallback = null;
|
||||
}
|
||||
|
||||
protected void setTargetCallback(@Nullable AlertDialogCallback targetCallback)
|
||||
{
|
||||
mTargetCallback = targetCallback;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState)
|
||||
{
|
||||
Bundle args = getArguments();
|
||||
if (args == null)
|
||||
throw new IllegalArgumentException("Arguments must be non null!");
|
||||
|
||||
initStrategies(args);
|
||||
return mDialogViewStrategy.createView(this, args);
|
||||
}
|
||||
|
||||
private void initStrategies(@NonNull Bundle args)
|
||||
{
|
||||
int fragManagerStrategyIndex = args.getInt(ARG_DIALOG_VIEW_STRATEGY_INDEX, INVALID_ID);
|
||||
mFragmentManagerStrategy = FragManagerStrategyType.values()[fragManagerStrategyIndex].getValue();
|
||||
|
||||
int dialogViewStrategyIndex = args.getInt(ARG_DIALOG_VIEW_STRATEGY_INDEX, INVALID_ID);
|
||||
mDialogViewStrategy = DialogViewStrategyType.values()[dialogViewStrategyIndex].getValue();
|
||||
}
|
||||
|
||||
private void onPositiveClicked(int which)
|
||||
{
|
||||
if (mTargetCallback != null)
|
||||
mTargetCallback.onAlertDialogPositiveClick(getArguments().getInt(ARG_REQ_CODE), which);
|
||||
dismissAllowingStateLoss();
|
||||
}
|
||||
|
||||
private void onNegativeClicked(int which)
|
||||
{
|
||||
if (mTargetCallback != null)
|
||||
mTargetCallback.onAlertDialogNegativeClick(getArguments().getInt(ARG_REQ_CODE), which);
|
||||
dismissAllowingStateLoss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
super.onCancel(dialog);
|
||||
if (mTargetCallback != null)
|
||||
mTargetCallback.onAlertDialogCancel(getArguments().getInt(ARG_REQ_CODE));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private static AlertDialog createDialog(@NonNull Builder builder)
|
||||
{
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ARG_TITLE_ID, builder.getTitleId());
|
||||
args.putInt(ARG_MESSAGE_ID, builder.getMessageId());
|
||||
args.putInt(ARG_POSITIVE_BUTTON_ID, builder.getPositiveBtnId());
|
||||
args.putInt(ARG_NEGATIVE_BUTTON_ID, builder.getNegativeBtnId());
|
||||
args.putInt(ARG_REQ_CODE, builder.getReqCode());
|
||||
args.putInt(ARG_IMAGE_RES_ID, builder.getImageResId());
|
||||
args.putInt(ARG_NEGATIVE_BTN_TEXT_COLOR_RES_ID, builder.getNegativeBtnTextColor());
|
||||
|
||||
FragManagerStrategyType fragManagerStrategyType = builder.getFragManagerStrategyType();
|
||||
args.putInt(ARG_FRAGMENT_MANAGER_STRATEGY_INDEX, fragManagerStrategyType.ordinal());
|
||||
|
||||
DialogViewStrategyType dialogViewStrategyType = builder.getDialogViewStrategyType();
|
||||
args.putInt(ARG_DIALOG_VIEW_STRATEGY_INDEX, dialogViewStrategyType.ordinal());
|
||||
|
||||
AlertDialog dialog = builder.getDialogFactory().createDialog();
|
||||
dialog.setArguments(args);
|
||||
dialog.setFragmentManagerStrategy(fragManagerStrategyType.getValue());
|
||||
dialog.setDialogViewStrategy(dialogViewStrategyType.getValue());
|
||||
return dialog;
|
||||
}
|
||||
|
||||
private void setFragmentManagerStrategy(@NonNull ResolveFragmentManagerStrategy strategy)
|
||||
{
|
||||
mFragmentManagerStrategy = strategy;
|
||||
}
|
||||
|
||||
private void setDialogViewStrategy(@NonNull ResolveDialogViewStrategy strategy)
|
||||
{
|
||||
mDialogViewStrategy = strategy;
|
||||
}
|
||||
|
||||
public static class Builder
|
||||
{
|
||||
private int mReqCode;
|
||||
@StringRes
|
||||
private int mTitleId;
|
||||
@StringRes
|
||||
private int mMessageId;
|
||||
@StringRes
|
||||
private int mPositiveBtn;
|
||||
@StringRes
|
||||
private int mNegativeBtn = INVALID_ID;
|
||||
@DrawableRes
|
||||
private int mImageResId = INVALID_ID;
|
||||
@NonNull
|
||||
private FragManagerStrategyType mFragManagerStrategyType = FragManagerStrategyType.DEFAULT;
|
||||
@NonNull
|
||||
private DialogViewStrategyType mDialogViewStrategyType = DialogViewStrategyType.DEFAULT;
|
||||
|
||||
@NonNull
|
||||
private DialogFactory mDialogFactory = new DefaultDialogFactory();
|
||||
|
||||
private int mNegativeBtnTextColor = INVALID_ID;
|
||||
|
||||
@NonNull
|
||||
public Builder setReqCode(int reqCode)
|
||||
{
|
||||
mReqCode = reqCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder setNegativeBtnTextColor(int negativeBtnTextColor)
|
||||
{
|
||||
mNegativeBtnTextColor = negativeBtnTextColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
int getReqCode()
|
||||
{
|
||||
return mReqCode;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder setTitleId(@StringRes int titleId)
|
||||
{
|
||||
mTitleId = titleId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@StringRes
|
||||
int getTitleId()
|
||||
{
|
||||
return mTitleId;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder setMessageId(@StringRes int messageId)
|
||||
{
|
||||
mMessageId = messageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@StringRes
|
||||
int getMessageId()
|
||||
{
|
||||
return mMessageId;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder setPositiveBtnId(@StringRes int btnId)
|
||||
{
|
||||
mPositiveBtn = btnId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder setNegativeBtnId(@StringRes int btnId)
|
||||
{
|
||||
mNegativeBtn = btnId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@StringRes
|
||||
int getPositiveBtnId()
|
||||
{
|
||||
return mPositiveBtn;
|
||||
}
|
||||
|
||||
@StringRes
|
||||
int getNegativeBtnId()
|
||||
{
|
||||
return mNegativeBtn;
|
||||
}
|
||||
|
||||
int getNegativeBtnTextColor()
|
||||
{
|
||||
return mNegativeBtnTextColor;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder setImageResId(@DrawableRes int imageResId)
|
||||
{
|
||||
mImageResId = imageResId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
int getImageResId()
|
||||
{
|
||||
return mImageResId;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder setFragManagerStrategyType(@NonNull FragManagerStrategyType strategyType)
|
||||
{
|
||||
mFragManagerStrategyType = strategyType;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder setDialogViewStrategyType(@NonNull DialogViewStrategyType strategyType)
|
||||
{
|
||||
mDialogViewStrategyType = strategyType;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
DialogViewStrategyType getDialogViewStrategyType()
|
||||
{
|
||||
return mDialogViewStrategyType;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
FragManagerStrategyType getFragManagerStrategyType()
|
||||
{
|
||||
return mFragManagerStrategyType;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public AlertDialog build()
|
||||
{
|
||||
return createDialog(this);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder setDialogFactory(@NonNull DialogFactory dialogFactory)
|
||||
{
|
||||
mDialogFactory = dialogFactory;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
DialogFactory getDialogFactory()
|
||||
{
|
||||
return mDialogFactory;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ChildFragmentManagerStrategy implements ResolveFragmentManagerStrategy
|
||||
{
|
||||
@NonNull
|
||||
@Override
|
||||
public FragmentManager resolve(@NonNull Fragment baseFragment)
|
||||
{
|
||||
return baseFragment.getChildFragmentManager();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public FragmentManager resolve(@NonNull FragmentActivity activity)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported here!");
|
||||
}
|
||||
}
|
||||
|
||||
private static class ActivityFragmentManagerStrategy implements ResolveFragmentManagerStrategy
|
||||
{
|
||||
@NonNull
|
||||
@Override
|
||||
public FragmentManager resolve(@NonNull Fragment baseFragment)
|
||||
{
|
||||
return baseFragment.requireActivity().getSupportFragmentManager();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public FragmentManager resolve(@NonNull FragmentActivity activity)
|
||||
{
|
||||
return activity.getSupportFragmentManager();
|
||||
}
|
||||
}
|
||||
|
||||
private static class AlertDialogStrategy implements ResolveDialogViewStrategy
|
||||
{
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog createView(@NonNull AlertDialog instance, @NonNull Bundle args)
|
||||
{
|
||||
int titleId = args.getInt(ARG_TITLE_ID);
|
||||
int messageId = args.getInt(ARG_MESSAGE_ID);
|
||||
int positiveButtonId = args.getInt(ARG_POSITIVE_BUTTON_ID);
|
||||
int negativeButtonId = args.getInt(ARG_NEGATIVE_BUTTON_ID);
|
||||
androidx.appcompat.app.AlertDialog.Builder builder =
|
||||
DialogUtils.buildAlertDialog(instance.requireContext(), titleId, messageId);
|
||||
builder.setPositiveButton(positiveButtonId,
|
||||
(dialog, which) -> instance.onPositiveClicked(which));
|
||||
if (negativeButtonId != INVALID_ID)
|
||||
builder.setNegativeButton(negativeButtonId,
|
||||
(dialog, which) -> instance.onNegativeClicked(which));
|
||||
|
||||
return builder.show();
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConfirmationDialogStrategy implements ResolveDialogViewStrategy
|
||||
{
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog createView(@NonNull AlertDialog fragment, @NonNull Bundle args)
|
||||
{
|
||||
AppCompatDialog appCompatDialog = new AppCompatDialog(fragment.requireContext());
|
||||
LayoutInflater inflater = LayoutInflater.from(fragment.requireContext());
|
||||
View root = inflater.inflate(fragment.getLayoutId(), null, false);
|
||||
|
||||
TextView declineBtn = root.findViewById(R.id.decline_btn);
|
||||
int declineBtnTextId = args.getInt(ARG_NEGATIVE_BUTTON_ID);
|
||||
if (declineBtnTextId != INVALID_ID)
|
||||
{
|
||||
declineBtn.setText(args.getInt(ARG_NEGATIVE_BUTTON_ID));
|
||||
declineBtn.setOnClickListener(
|
||||
v -> fragment.onNegativeClicked(DialogInterface.BUTTON_NEGATIVE));
|
||||
}
|
||||
else
|
||||
{
|
||||
UiUtils.hide(declineBtn);
|
||||
}
|
||||
|
||||
TextView acceptBtn = root.findViewById(R.id.accept_btn);
|
||||
acceptBtn.setText(args.getInt(ARG_POSITIVE_BUTTON_ID));
|
||||
acceptBtn.setOnClickListener(
|
||||
v -> fragment.onPositiveClicked(DialogInterface.BUTTON_POSITIVE));
|
||||
|
||||
TextView descriptionView = root.findViewById(R.id.description);
|
||||
descriptionView.setText(args.getInt(ARG_MESSAGE_ID));
|
||||
|
||||
TextView titleView = root.findViewById(R.id.title);
|
||||
titleView.setText(args.getInt(ARG_TITLE_ID));
|
||||
|
||||
ImageView imageView = root.findViewById(R.id.image);
|
||||
int imageResId = args.getInt(ARG_IMAGE_RES_ID);
|
||||
boolean hasImage = imageResId != INVALID_ID;
|
||||
|
||||
imageView.setImageDrawable(hasImage ? fragment.getResources().getDrawable(imageResId)
|
||||
: null);
|
||||
|
||||
int negativeBtnTextColor = args.getInt(ARG_NEGATIVE_BTN_TEXT_COLOR_RES_ID);
|
||||
boolean hasNegativeBtnCustomColor = negativeBtnTextColor != INVALID_ID;
|
||||
|
||||
if (hasNegativeBtnCustomColor)
|
||||
declineBtn.setTextColor(fragment.getResources().getColor(negativeBtnTextColor));
|
||||
|
||||
UiUtils.showIf(hasImage, imageView);
|
||||
appCompatDialog.setContentView(root);
|
||||
return appCompatDialog;
|
||||
}
|
||||
}
|
||||
|
||||
public enum FragManagerStrategyType
|
||||
{
|
||||
DEFAULT(new ChildFragmentManagerStrategy()),
|
||||
ACTIVITY_FRAGMENT_MANAGER(new ActivityFragmentManagerStrategy());
|
||||
|
||||
@NonNull
|
||||
private final ResolveFragmentManagerStrategy mStrategy;
|
||||
|
||||
FragManagerStrategyType(@NonNull ResolveFragmentManagerStrategy strategy)
|
||||
{
|
||||
mStrategy = strategy;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public ResolveFragmentManagerStrategy getValue()
|
||||
{
|
||||
return mStrategy;
|
||||
}
|
||||
}
|
||||
|
||||
public enum DialogViewStrategyType
|
||||
{
|
||||
DEFAULT(new AlertDialogStrategy()),
|
||||
CONFIRMATION_DIALOG(new ConfirmationDialogStrategy());
|
||||
|
||||
@NonNull
|
||||
private final ResolveDialogViewStrategy mStrategy;
|
||||
|
||||
DialogViewStrategyType(@NonNull ResolveDialogViewStrategy strategy)
|
||||
{
|
||||
mStrategy = strategy;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private ResolveDialogViewStrategy getValue()
|
||||
{
|
||||
return mStrategy;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package com.mapswithme.maps.dialog;
|
||||
|
||||
public interface AlertDialogCallback
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @param requestCode the code that the dialog was launched with.
|
||||
* @param which indicates which button was pressed, for details see
|
||||
* {@link android.content.DialogInterface}
|
||||
*
|
||||
* @see android.content.DialogInterface.OnClickListener
|
||||
*/
|
||||
void onAlertDialogPositiveClick(int requestCode, int which);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param requestCode the code that the dialog was launched with.
|
||||
* @param which indicates which button was pressed, for details see
|
||||
* {@link android.content.DialogInterface}
|
||||
*
|
||||
* @see android.content.DialogInterface.OnClickListener
|
||||
*/
|
||||
void onAlertDialogNegativeClick(int requestCode, int which);
|
||||
|
||||
/**
|
||||
* Called when the dialog is cancelled.
|
||||
*
|
||||
* @param requestCode the code that the dialog was launched with.
|
||||
*/
|
||||
void onAlertDialogCancel(int requestCode);
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.mapswithme.maps.dialog;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
class DefaultDialogFactory implements DialogFactory
|
||||
{
|
||||
@NonNull
|
||||
@Override
|
||||
public AlertDialog createDialog()
|
||||
{
|
||||
return new AlertDialog();
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package com.mapswithme.maps.dialog;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public interface DialogFactory
|
||||
{
|
||||
@NonNull
|
||||
AlertDialog createDialog();
|
||||
}
|
|
@ -1,138 +0,0 @@
|
|||
package com.mapswithme.maps.dialog;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
|
||||
public class DialogUtils
|
||||
{
|
||||
private DialogUtils()
|
||||
{
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private static AlertDialog.Builder buildAlertDialog(@NonNull Context context, @StringRes int titleId)
|
||||
{
|
||||
return new AlertDialog.Builder(context)
|
||||
.setCancelable(false)
|
||||
.setTitle(titleId)
|
||||
.setPositiveButton(R.string.ok, (dlg, which) -> dlg.dismiss());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
static AlertDialog.Builder buildAlertDialog(@NonNull Context context, @StringRes int titleId,
|
||||
@StringRes int msgId)
|
||||
{
|
||||
return buildAlertDialog(context, titleId)
|
||||
.setMessage(msgId);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private static AlertDialog.Builder buildAlertDialog(@NonNull Context context, @StringRes int titleId,
|
||||
@NonNull CharSequence msg, @StringRes int posBtn,
|
||||
@NonNull DialogInterface.OnClickListener
|
||||
posClickListener,
|
||||
@StringRes int negBtn,
|
||||
@Nullable DialogInterface.OnClickListener
|
||||
negClickListener)
|
||||
{
|
||||
return buildAlertDialog(context, titleId, msg, posBtn, posClickListener)
|
||||
.setNegativeButton(negBtn, negClickListener);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private static AlertDialog.Builder buildAlertDialog(@NonNull Context context, @StringRes int titleId,
|
||||
@NonNull CharSequence msg, @StringRes int posBtn,
|
||||
@NonNull DialogInterface.OnClickListener
|
||||
posClickListener)
|
||||
{
|
||||
return buildAlertDialog(context, titleId)
|
||||
.setMessage(msg)
|
||||
.setPositiveButton(posBtn, posClickListener);
|
||||
}
|
||||
|
||||
public static void showAlertDialog(@NonNull Context context, @StringRes int titleId,
|
||||
@StringRes int msgId)
|
||||
{
|
||||
buildAlertDialog(context, titleId, msgId).show();
|
||||
}
|
||||
|
||||
public static void showAlertDialog(@NonNull Context context, @StringRes int titleId)
|
||||
{
|
||||
buildAlertDialog(context, titleId).show();
|
||||
}
|
||||
|
||||
public static void showAlertDialog(@NonNull Context context, @StringRes int titleId,
|
||||
@StringRes int msgId, @StringRes int posBtn,
|
||||
@NonNull DialogInterface.OnClickListener posClickListener,
|
||||
@StringRes int negBtn)
|
||||
{
|
||||
buildAlertDialog(context, titleId, context.getString(msgId), posBtn, posClickListener, negBtn,
|
||||
null).show();
|
||||
}
|
||||
|
||||
|
||||
public static void showAlertDialog(@NonNull Context context, @StringRes int titleId,
|
||||
@NonNull CharSequence msg, @StringRes int posBtn,
|
||||
@NonNull DialogInterface.OnClickListener posClickListener,
|
||||
@StringRes int negBtn)
|
||||
{
|
||||
buildAlertDialog(context, titleId, msg, posBtn, posClickListener, negBtn, null).show();
|
||||
}
|
||||
|
||||
public static void showAlertDialog(@NonNull Context context, @StringRes int titleId,
|
||||
@NonNull CharSequence msg, @StringRes int posBtn,
|
||||
@NonNull DialogInterface.OnClickListener posClickListener,
|
||||
@StringRes int negBtn,
|
||||
@Nullable DialogInterface.OnClickListener negClickListener)
|
||||
{
|
||||
buildAlertDialog(context, titleId, msg, posBtn, posClickListener, negBtn, negClickListener).show();
|
||||
}
|
||||
|
||||
public static void showAlertDialog(@NonNull Context context, @StringRes int titleId,
|
||||
@StringRes int msgId, @StringRes int posBtn,
|
||||
@NonNull DialogInterface.OnClickListener posClickListener,
|
||||
@StringRes int negBtn,
|
||||
@Nullable DialogInterface.OnClickListener negClickListener)
|
||||
{
|
||||
buildAlertDialog(context, titleId, context.getString(msgId), posBtn, posClickListener, negBtn,
|
||||
negClickListener).show();
|
||||
}
|
||||
|
||||
public static void showAlertDialog(@NonNull Context context, @StringRes int titleId,
|
||||
@StringRes int msgId, @StringRes int posBtn,
|
||||
@NonNull DialogInterface.OnClickListener posClickListener)
|
||||
{
|
||||
buildAlertDialog(context, titleId, context.getString(msgId), posBtn, posClickListener).show();
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
public static ProgressDialog createModalProgressDialog(@NonNull Context context, @StringRes int msg)
|
||||
{
|
||||
ProgressDialog progress = new ProgressDialog(context, R.style.MwmTheme_AlertDialog);
|
||||
progress.setMessage(context.getString(msg));
|
||||
progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||
progress.setIndeterminate(true);
|
||||
progress.setCancelable(false);
|
||||
return progress;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static ProgressDialog createModalProgressDialog(@NonNull Context context, @StringRes int msg,
|
||||
int whichButton, @StringRes int buttonText,
|
||||
@Nullable DialogInterface.OnClickListener
|
||||
clickListener)
|
||||
{
|
||||
ProgressDialog progress = createModalProgressDialog(context, msg);
|
||||
progress.setButton(whichButton, context.getString(buttonText), clickListener);
|
||||
return progress;
|
||||
}
|
||||
}
|
|
@ -119,7 +119,7 @@ public class EditTextDialogFragment extends BaseMwmDialogFragment
|
|||
negativeButtonText = args.getString(ARG_NEGATIVE_BUTTON);
|
||||
}
|
||||
|
||||
AlertDialog editTextDialog = new AlertDialog.Builder(requireActivity())
|
||||
AlertDialog editTextDialog = new AlertDialog.Builder(requireActivity(), R.style.MwmTheme_AlertDialog)
|
||||
.setView(buildView())
|
||||
.setNegativeButton(negativeButtonText, null)
|
||||
.setPositiveButton(positiveButtonText, (dialog, which) -> {
|
||||
|
@ -134,7 +134,6 @@ public class EditTextDialogFragment extends BaseMwmDialogFragment
|
|||
this.validateInput(requireActivity(), mInitialText);
|
||||
});
|
||||
|
||||
|
||||
// Setup validation on input edit.
|
||||
mEtInput.addTextChangedListener(new StringUtils.SimpleTextWatcher()
|
||||
{
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
package com.mapswithme.maps.dialog;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public interface ResolveDialogViewStrategy
|
||||
{
|
||||
@NonNull
|
||||
Dialog createView(@NonNull AlertDialog dialog, @NonNull Bundle args);
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package com.mapswithme.maps.dialog;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
public interface ResolveFragmentManagerStrategy
|
||||
{
|
||||
@NonNull
|
||||
FragmentManager resolve(@NonNull Fragment baseFragment);
|
||||
|
||||
@NonNull
|
||||
FragmentManager resolve(@NonNull FragmentActivity activity);
|
||||
}
|
|
@ -100,10 +100,10 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
|
|||
{
|
||||
if (RoutingController.get().isNavigating())
|
||||
{
|
||||
new AlertDialog.Builder(adapter.mActivity)
|
||||
new AlertDialog.Builder(adapter.mActivity, R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.downloader_delete_map)
|
||||
.setMessage(R.string.downloader_delete_map_while_routing_dialog)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show();
|
||||
return;
|
||||
}
|
||||
|
@ -114,11 +114,12 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
|
|||
return;
|
||||
}
|
||||
|
||||
new AlertDialog.Builder(adapter.mActivity)
|
||||
new AlertDialog.Builder(adapter.mActivity, R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.downloader_delete_map)
|
||||
.setMessage(R.string.downloader_delete_map_dialog)
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> deleteNode(item, adapter)).show();
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(R.string.ok, (dialog, which) -> deleteNode(item, adapter))
|
||||
.show();
|
||||
}
|
||||
|
||||
private void onCancelActionSelected(CountryItem item, DownloaderAdapter adapter)
|
||||
|
|
|
@ -89,30 +89,20 @@ public final class MapManager
|
|||
throw new IllegalArgumentException("Given error can not be displayed: " + errorData.errorCode);
|
||||
}
|
||||
|
||||
AlertDialog dlg = new AlertDialog.Builder(activity)
|
||||
.setTitle(R.string.country_status_download_failed)
|
||||
.setMessage(text)
|
||||
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
sCurrentErrorDialog = null;
|
||||
if (dialogClickListener != null)
|
||||
dialogClickListener.invoke(false);
|
||||
}
|
||||
})
|
||||
.setPositiveButton(R.string.downloader_retry, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
Application app = activity.getApplication();
|
||||
RetryFailedDownloadConfirmationListener listener
|
||||
= new ExpandRetryConfirmationListener(app, dialogClickListener);
|
||||
warn3gAndRetry(activity, errorData.countryId, listener);
|
||||
}
|
||||
}).create();
|
||||
final AlertDialog dlg = new AlertDialog.Builder(activity, R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.country_status_download_failed)
|
||||
.setMessage(text)
|
||||
.setNegativeButton(R.string.cancel, (dialog, which) -> {
|
||||
sCurrentErrorDialog = null;
|
||||
if (dialogClickListener != null)
|
||||
dialogClickListener.invoke(false);
|
||||
})
|
||||
.setPositiveButton(R.string.downloader_retry, (dialog, which) -> {
|
||||
Application app = activity.getApplication();
|
||||
RetryFailedDownloadConfirmationListener listener
|
||||
= new ExpandRetryConfirmationListener(app, dialogClickListener);
|
||||
warn3gAndRetry(activity, errorData.countryId, listener);
|
||||
}).create();
|
||||
dlg.setCanceledOnTouchOutside(false);
|
||||
dlg.show();
|
||||
sCurrentErrorDialog = new WeakReference<>(dlg);
|
||||
|
@ -120,7 +110,7 @@ public final class MapManager
|
|||
|
||||
private static void notifyNoSpaceInternal(Activity activity)
|
||||
{
|
||||
new AlertDialog.Builder(activity)
|
||||
new AlertDialog.Builder(activity, R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.downloader_no_space_title)
|
||||
.setMessage(R.string.downloader_no_space_message)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
|
@ -171,18 +161,13 @@ public final class MapManager
|
|||
return false;
|
||||
}
|
||||
|
||||
new AlertDialog.Builder(activity)
|
||||
.setMessage(String.format("%1$s\n\n%2$s", activity.getString(R.string.download_over_mobile_header),
|
||||
activity.getString(R.string.download_over_mobile_message)))
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
nativeEnableDownloadOn3g();
|
||||
onAcceptListener.run();
|
||||
}
|
||||
new AlertDialog.Builder(activity, R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.download_over_mobile_header)
|
||||
.setMessage(R.string.download_over_mobile_message)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(R.string.ok, (dlg, which) -> {
|
||||
nativeEnableDownloadOn3g();
|
||||
onAcceptListener.run();
|
||||
}).show();
|
||||
|
||||
return true;
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.net.Uri;
|
|||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.util.SparseArray;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -636,8 +635,8 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
|
|||
|
||||
private void rollback(@Editor.FeatureStatus int status)
|
||||
{
|
||||
int title;
|
||||
int message;
|
||||
@StringRes final int title;
|
||||
@StringRes final int message;
|
||||
if (status == Editor.CREATED)
|
||||
{
|
||||
title = R.string.editor_remove_place_button;
|
||||
|
@ -649,19 +648,15 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
|
|||
message = R.string.editor_reset_edits_message;
|
||||
}
|
||||
|
||||
new AlertDialog.Builder(requireActivity()).setTitle(message)
|
||||
.setPositiveButton(getString(title).toUpperCase(), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
Editor.nativeRollbackMapObject();
|
||||
Framework.nativePokeSearchInViewport();
|
||||
mParent.onBackPressed();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.cancel).toUpperCase(), null)
|
||||
.show();
|
||||
new AlertDialog.Builder(requireActivity(), R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(message)
|
||||
.setPositiveButton(title, (dialog, which) -> {
|
||||
Editor.nativeRollbackMapObject();
|
||||
Framework.nativePokeSearchInViewport();
|
||||
mParent.onBackPressed();
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void placeDoesntExist()
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.mapswithme.maps.editor;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
|
@ -21,7 +20,6 @@ import com.mapswithme.maps.MwmApplication;
|
|||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmToolbarFragment;
|
||||
import com.mapswithme.maps.base.OnBackPressListener;
|
||||
import com.mapswithme.maps.dialog.DialogUtils;
|
||||
import com.mapswithme.maps.editor.data.Language;
|
||||
import com.mapswithme.maps.editor.data.LocalizedName;
|
||||
import com.mapswithme.maps.editor.data.LocalizedStreet;
|
||||
|
@ -356,7 +354,10 @@ public class EditorHostFragment extends BaseMwmToolbarFragment
|
|||
|
||||
private void processNoFeatures()
|
||||
{
|
||||
DialogUtils.showAlertDialog(requireActivity(), R.string.downloader_no_space_title);
|
||||
new AlertDialog.Builder(requireActivity(), R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.downloader_no_space_title)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void processEditedFeatures()
|
||||
|
@ -388,32 +389,27 @@ public class EditorHostFragment extends BaseMwmToolbarFragment
|
|||
|
||||
private void showMistakeDialog(@StringRes int resId)
|
||||
{
|
||||
new AlertDialog.Builder(requireActivity())
|
||||
new AlertDialog.Builder(requireActivity(), R.style.MwmTheme_AlertDialog)
|
||||
.setMessage(resId)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void showNoobDialog()
|
||||
{
|
||||
new AlertDialog.Builder(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))
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
new AlertDialog.Builder(requireActivity(), R.style.MwmTheme_AlertDialog)
|
||||
.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))
|
||||
.setPositiveButton(android.R.string.ok, (dlg, which) -> {
|
||||
MwmApplication.prefs(requireContext()).edit()
|
||||
.putBoolean(NOOB_ALERT_SHOWN, true)
|
||||
.apply();
|
||||
.putBoolean(NOOB_ALERT_SHOWN, true)
|
||||
.apply();
|
||||
saveNote();
|
||||
saveMapObjectEdits();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show();
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
public void setStreet(LocalizedStreet street)
|
||||
|
|
|
@ -75,36 +75,30 @@ public class HoursMinutesPickerFragment extends BaseMwmDialogFragment
|
|||
//noinspection ConstantConditions
|
||||
mTabs.getTabAt(mSelectedTab).select();
|
||||
|
||||
@StyleRes
|
||||
final int theme = ThemeUtils.isNightTheme(requireContext()) ?
|
||||
R.style.MwmMain_DialogFragment_TimePicker_Night :
|
||||
R.style.MwmMain_DialogFragment_TimePicker;
|
||||
@StyleRes final int theme = ThemeUtils.isNightTheme(requireContext()) ?
|
||||
R.style.MwmMain_DialogFragment_TimePicker_Night :
|
||||
R.style.MwmMain_DialogFragment_TimePicker;
|
||||
final AlertDialog dialog = new AlertDialog.Builder(requireActivity(), theme)
|
||||
.setView(root)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.setCancelable(true)
|
||||
.create();
|
||||
.setView(root)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setCancelable(true)
|
||||
.create();
|
||||
|
||||
dialog.setOnShowListener(dialogInterface -> {
|
||||
mOkButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||
mOkButton.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
mOkButton.setOnClickListener(v -> {
|
||||
if (mSelectedTab == TAB_FROM)
|
||||
{
|
||||
if (mSelectedTab == TAB_FROM)
|
||||
{
|
||||
//noinspection ConstantConditions
|
||||
mTabs.getTabAt(TAB_TO).select();
|
||||
return;
|
||||
}
|
||||
|
||||
saveHoursMinutes();
|
||||
dismiss();
|
||||
if (getParentFragment() instanceof OnPickListener)
|
||||
((OnPickListener) getParentFragment()).onHoursMinutesPicked(mFrom, mTo, mId);
|
||||
//noinspection ConstantConditions
|
||||
mTabs.getTabAt(TAB_TO).select();
|
||||
return;
|
||||
}
|
||||
|
||||
saveHoursMinutes();
|
||||
dismiss();
|
||||
if (getParentFragment() instanceof OnPickListener)
|
||||
((OnPickListener) getParentFragment()).onHoursMinutesPicked(mFrom, mTo, mId);
|
||||
});
|
||||
refreshPicker();
|
||||
});
|
||||
|
|
|
@ -14,6 +14,7 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.Size;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmToolbarFragment;
|
||||
import com.mapswithme.util.Constants;
|
||||
|
@ -98,9 +99,10 @@ public class OsmLoginFragment extends BaseMwmToolbarFragment
|
|||
|
||||
private void onAuthFail()
|
||||
{
|
||||
new AlertDialog.Builder(requireActivity()).setTitle(R.string.editor_login_error_dialog)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show();
|
||||
new AlertDialog.Builder(requireActivity(), R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.editor_login_error_dialog)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void onAuthSuccess(@Size(2) String[] auth, String username)
|
||||
|
|
|
@ -12,6 +12,7 @@ import android.widget.TextView;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmToolbarFragment;
|
||||
import com.mapswithme.util.Constants;
|
||||
|
@ -83,15 +84,14 @@ public class ProfileFragment extends BaseMwmToolbarFragment
|
|||
|
||||
private void logout()
|
||||
{
|
||||
new AlertDialog.Builder(requireContext())
|
||||
new AlertDialog.Builder(requireContext(), R.style.MwmTheme_AlertDialog)
|
||||
.setMessage(R.string.are_you_sure)
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) ->
|
||||
.setPositiveButton(R.string.ok, (dialog, which) ->
|
||||
{
|
||||
OsmOAuth.clearAuthorization(requireContext());
|
||||
refreshViews();
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.create()
|
||||
.setNegativeButton(R.string.no, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
|
|
|
@ -64,12 +64,12 @@ public class FaqFragment extends BaseMwmFragment
|
|||
};
|
||||
|
||||
TextView feedback = root.findViewById(R.id.feedback);
|
||||
feedback.setOnClickListener(v -> new AlertDialog.Builder(requireActivity())
|
||||
feedback.setOnClickListener(v -> new AlertDialog.Builder(requireActivity(), R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.feedback)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setItems(new CharSequence[] { getString(R.string.feedback_general),
|
||||
getString(R.string.report_a_bug) },
|
||||
mDialogClickListener).show());
|
||||
.setItems(new CharSequence[]{getString(R.string.feedback_general), getString(R.string.report_a_bug)},
|
||||
mDialogClickListener)
|
||||
.show());
|
||||
|
||||
return root;
|
||||
}
|
||||
|
|
|
@ -331,7 +331,7 @@ public enum LocationHelper implements Initializable<Context>, AppBackgroundTrack
|
|||
return;
|
||||
|
||||
final AppCompatActivity activity = mUiCallback.requireActivity();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity)
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity, R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.enable_location_services)
|
||||
.setMessage(R.string.location_is_disabled_long_text)
|
||||
.setOnDismissListener(dialog -> mErrorDialog = null)
|
||||
|
@ -361,7 +361,7 @@ public enum LocationHelper implements Initializable<Context>, AppBackgroundTrack
|
|||
return;
|
||||
|
||||
final AppCompatActivity activity = mUiCallback.requireActivity();
|
||||
mErrorDialog = new AlertDialog.Builder(activity)
|
||||
mErrorDialog = new AlertDialog.Builder(activity, R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.current_location_unknown_title)
|
||||
.setMessage(R.string.current_location_unknown_message)
|
||||
.setOnDismissListener(dialog -> mErrorDialog = null)
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.mapswithme.maps.maplayer.traffic.widget;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -111,26 +110,12 @@ public class TrafficButtonController implements TrafficManager.TrafficCallback
|
|||
if (mDialog != null && mDialog.isShowing())
|
||||
return;
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity)
|
||||
mDialog = new AlertDialog.Builder(mActivity, R.style.MwmTheme_AlertDialog)
|
||||
.setMessage(R.string.common_check_internet_connection_dialog)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
TrafficManager.INSTANCE.setEnabled(false);
|
||||
}
|
||||
})
|
||||
.setPositiveButton(R.string.ok, (dialog, which) -> TrafficManager.INSTANCE.setEnabled(false))
|
||||
.setCancelable(true)
|
||||
.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
TrafficManager.INSTANCE.setEnabled(false);
|
||||
}
|
||||
});
|
||||
mDialog = builder.show();
|
||||
.setOnCancelListener(dialog -> TrafficManager.INSTANCE.setEnabled(false))
|
||||
.show();
|
||||
}
|
||||
|
||||
public void destroy()
|
||||
|
|
|
@ -58,9 +58,9 @@ abstract class BaseRoutingErrorDialogFragment extends BaseMwmDialogFragment
|
|||
public Dialog onCreateDialog(Bundle savedInstanceState)
|
||||
{
|
||||
parseArguments();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity())
|
||||
.setCancelable(true)
|
||||
.setNegativeButton(android.R.string.cancel, null);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity(), R.style.MwmTheme_AlertDialog)
|
||||
.setCancelable(true)
|
||||
.setNegativeButton(android.R.string.cancel, null);
|
||||
beforeDialogCreated(builder);
|
||||
return createDialog(builder);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import androidx.annotation.Nullable;
|
|||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.util.Pair;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
|
@ -342,20 +343,16 @@ public class RoutingController implements Initializable<Void>
|
|||
R.string.dialog_routing_disclaimer_beware })
|
||||
builder.append(MwmApplication.from(activity.getApplicationContext()).getString(resId)).append("\n\n");
|
||||
|
||||
new AlertDialog.Builder(activity)
|
||||
new AlertDialog.Builder(activity, R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.dialog_routing_disclaimer_title)
|
||||
.setMessage(builder.toString())
|
||||
.setCancelable(false)
|
||||
.setNegativeButton(R.string.decline, null)
|
||||
.setPositiveButton(R.string.accept, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
Config.acceptRoutingDisclaimer();
|
||||
prepare(startPoint, endPoint, fromApi);
|
||||
}
|
||||
}).show();
|
||||
.setPositiveButton(R.string.accept, (dlg, which) -> {
|
||||
Config.acceptRoutingDisclaimer();
|
||||
prepare(startPoint, endPoint, fromApi);
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
public void restoreRoute()
|
||||
|
@ -542,9 +539,9 @@ public class RoutingController implements Initializable<Void>
|
|||
return;
|
||||
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(mContainer.requireActivity())
|
||||
.setMessage(R.string.p2p_reroute_from_current)
|
||||
.setCancelable(false)
|
||||
.setNegativeButton(R.string.cancel, null);
|
||||
.setMessage(R.string.p2p_reroute_from_current)
|
||||
.setCancelable(false)
|
||||
.setNegativeButton(R.string.cancel, null);
|
||||
|
||||
TextView titleView = (TextView)View.inflate(mContainer.requireActivity(), R.layout.dialog_suggest_reroute_title, null);
|
||||
titleView.setText(R.string.p2p_only_from_current);
|
||||
|
|
|
@ -693,15 +693,17 @@ public class SettingsPrefsFragment extends BaseXmlSettingsFragment
|
|||
public boolean onPreferenceClick(Preference preference)
|
||||
{
|
||||
if (MapManager.nativeIsDownloading())
|
||||
new AlertDialog.Builder(requireActivity())
|
||||
.setTitle(getString(R.string.downloading_is_active))
|
||||
.setMessage(getString(R.string.cant_change_this_setting))
|
||||
.setPositiveButton(getString(R.string.ok), null)
|
||||
{
|
||||
new AlertDialog.Builder(requireActivity(), R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.downloading_is_active)
|
||||
.setMessage(R.string.cant_change_this_setting)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show();
|
||||
}
|
||||
else
|
||||
// getSettingsActivity().switchToFragment(StoragePathFragment.class, R.string.maps_storage);
|
||||
getSettingsActivity().stackFragment(StoragePathFragment.class,
|
||||
getString(R.string.maps_storage), null);
|
||||
{
|
||||
getSettingsActivity().stackFragment(StoragePathFragment.class, getString(R.string.maps_storage), null);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ import android.widget.TextView;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.OnBackPressListener;
|
||||
import com.mapswithme.maps.dialog.DialogUtils;
|
||||
import com.mapswithme.util.Config;
|
||||
import com.mapswithme.util.StorageUtils;
|
||||
import com.mapswithme.util.Utils;
|
||||
|
@ -93,7 +93,7 @@ public class StoragePathFragment extends BaseSettingsFragment
|
|||
final String oldPath = storages.get(currentIndex).mPath;
|
||||
final String newPath = storages.get(newIndex).mPath;
|
||||
|
||||
new AlertDialog.Builder(requireActivity())
|
||||
new AlertDialog.Builder(requireActivity(), R.style.MwmTheme_AlertDialog)
|
||||
.setCancelable(false)
|
||||
.setTitle(R.string.move_maps)
|
||||
.setPositiveButton(R.string.ok, (dlg, which) -> moveStorage(newPath, oldPath))
|
||||
|
@ -107,7 +107,11 @@ public class StoragePathFragment extends BaseSettingsFragment
|
|||
*/
|
||||
private void moveStorage(@NonNull final String newPath, @NonNull final String oldPath)
|
||||
{
|
||||
final ProgressDialog dialog = DialogUtils.createModalProgressDialog(requireActivity(), R.string.wait_several_minutes);
|
||||
final ProgressDialog dialog = new ProgressDialog(requireActivity(), R.style.MwmTheme_AlertDialog);
|
||||
dialog.setMessage(getString(R.string.wait_several_minutes));
|
||||
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||
dialog.setIndeterminate(true);
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
|
||||
ThreadPool.getStorage().execute(() -> {
|
||||
|
@ -119,10 +123,10 @@ public class StoragePathFragment extends BaseSettingsFragment
|
|||
|
||||
if (!result)
|
||||
{
|
||||
new AlertDialog.Builder(requireActivity())
|
||||
new AlertDialog.Builder(requireActivity(), R.style.MwmTheme_AlertDialog)
|
||||
.setTitle(R.string.move_maps_error)
|
||||
.setPositiveButton(R.string.report_a_bug,
|
||||
(dlg, which) -> Utils.sendBugReport(requireActivity(), "Error moving map files"))
|
||||
(dlg, which) -> Utils.sendBugReport(requireActivity(), "Error moving map files"))
|
||||
.show();
|
||||
}
|
||||
Framework.nativeChangeWritableDir(newPath);
|
||||
|
|
|
@ -40,11 +40,11 @@ public class BookmarkColorDialogFragment extends BaseMwmDialogFragment
|
|||
if (getArguments() != null)
|
||||
mIconColor = getArguments().getInt(ICON_TYPE);
|
||||
|
||||
return new AlertDialog.Builder(requireActivity())
|
||||
.setView(buildView())
|
||||
.setTitle(R.string.bookmark_color)
|
||||
.setNegativeButton(getString(R.string.cancel), null)
|
||||
.create();
|
||||
return new AlertDialog.Builder(requireActivity(), R.style.MwmTheme_AlertDialog)
|
||||
.setView(buildView())
|
||||
.setTitle(R.string.bookmark_color)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create();
|
||||
}
|
||||
|
||||
public void setOnColorSetListener(OnBookmarkColorChangeListener listener)
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.app.Activity;
|
|||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ClipData;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
|
@ -32,6 +31,7 @@ import androidx.appcompat.app.AlertDialog;
|
|||
import androidx.core.app.NavUtils;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.mapswithme.maps.BuildConfig;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
|
@ -389,26 +389,17 @@ public class Utils
|
|||
}
|
||||
|
||||
final Holder holder = new Holder();
|
||||
new AlertDialog.Builder(context)
|
||||
.setMessage(message)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(R.string.downloader_retry, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
holder.accepted = true;
|
||||
checkConnection(context, message, onCheckPassedCallback);
|
||||
}
|
||||
}).setOnDismissListener(new DialogInterface.OnDismissListener()
|
||||
{
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog)
|
||||
{
|
||||
if (!holder.accepted)
|
||||
onCheckPassedCallback.invoke(false);
|
||||
}
|
||||
}).show();
|
||||
new AlertDialog.Builder(context, R.style.MwmTheme_AlertDialog)
|
||||
.setMessage(message)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(R.string.downloader_retry, (dialog, which) -> {
|
||||
holder.accepted = true;
|
||||
checkConnection(context, message, onCheckPassedCallback);
|
||||
}).setOnDismissListener(dialog -> {
|
||||
if (!holder.accepted)
|
||||
onCheckPassedCallback.invoke(false);
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
public static boolean isAppInstalled(@NonNull Context context, @NonNull String packageName)
|
||||
|
|
Loading…
Add table
Reference in a new issue