forked from organicmaps/organicmaps
[android] Toasts are replaced with snackbars.
This commit is contained in:
parent
9535ee5d45
commit
31ba95ad4b
14 changed files with 62 additions and 43 deletions
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
android:id="@+id/layout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
android:layout_height="match_parent"
|
||||
android:background="?cardBackground">
|
||||
<com.mapswithme.maps.widget.HeightLimitedFrameLayout
|
||||
android:id="@+id/layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@id/button_container"
|
||||
|
|
|
@ -12,7 +12,6 @@ import android.widget.Button;
|
|||
import android.widget.CheckBox;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -260,7 +259,8 @@ public class DownloadResourcesLegacyActivity extends BaseMwmFragmentActivity imp
|
|||
Context context = getApplicationContext();
|
||||
if (Utils.isPackageInstalled(context, Constants.Package.MWM_LITE_PACKAGE) ||
|
||||
Utils.isPackageInstalled(context, Constants.Package.MWM_SAMSUNG_PACKAGE))
|
||||
Toast.makeText(this, R.string.suggest_uninstall_lite, Toast.LENGTH_LONG).show();
|
||||
Utils.showSnackbar(context, findViewById(R.id.layout),
|
||||
findViewById(R.id.button_container), R.string.suggest_uninstall_lite);
|
||||
}
|
||||
|
||||
private void setDownloadMessage(int bytesToDownload)
|
||||
|
|
|
@ -19,7 +19,6 @@ import android.view.View.OnClickListener;
|
|||
import android.view.ViewTreeObserver;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -1345,7 +1344,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
if (!successful)
|
||||
return;
|
||||
|
||||
Toast.makeText(this, R.string.guide_downloaded_title, Toast.LENGTH_LONG).show();
|
||||
Utils.showSnackbar(this, findViewById(R.id.coordinator),
|
||||
findViewById(R.id.menu_frame), R.string.guide_downloaded_title);
|
||||
Statistics.INSTANCE.trackEvent(Statistics.EventName.BM_GUIDEDOWNLOADTOAST_SHOWN);
|
||||
}
|
||||
|
||||
|
@ -2675,8 +2675,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
@Override
|
||||
public void onBookmarksFileLoaded(boolean success)
|
||||
{
|
||||
Utils.toastShortcut(MwmActivity.this, success ? R.string.load_kmz_successful :
|
||||
R.string.load_kmz_failed);
|
||||
Utils.showSnackbar(this, findViewById(R.id.coordinator), findViewById(R.id.menu_frame),
|
||||
success ? R.string.load_kmz_successful : R.string.load_kmz_failed);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2862,8 +2862,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
if (PermissionsUtils.isLocationExplanationNeeded(MwmActivity.this))
|
||||
PermissionsUtils.requestLocationPermission(MwmActivity.this, REQ_CODE_LOCATION_PERMISSION);
|
||||
else
|
||||
Toast.makeText(MwmActivity.this, R.string.enable_location_services, Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
Utils.showSnackbar(getActivity(), findViewById(R.id.coordinator), findViewById(R.id.menu_frame),
|
||||
R.string.enable_location_services);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import androidx.annotation.Nullable;
|
|||
import androidx.fragment.app.FragmentActivity;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.R;
|
||||
|
@ -237,7 +236,7 @@ public class BookmarkBackupController implements Authorizer.Callback,
|
|||
}
|
||||
else
|
||||
{
|
||||
Toast.makeText(mContext, R.string.profile_authorization_error, Toast.LENGTH_LONG).show();
|
||||
Utils.showSnackbar(mContext, mBackupView.getRootView(), R.string.profile_authorization_error);
|
||||
Statistics.INSTANCE.trackBmSyncProposalError(Framework.TOKEN_MAPSME, "Unknown error");
|
||||
}
|
||||
updateWidget();
|
||||
|
|
|
@ -21,7 +21,6 @@ import android.webkit.WebResourceRequest;
|
|||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -510,8 +509,8 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment
|
|||
}
|
||||
|
||||
Statistics.INSTANCE.trackDownloadCatalogError(Statistics.ParamValue.NO_INTERNET);
|
||||
Toast.makeText(frag.getContext(), R.string.common_check_internet_connection_dialog_title,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
Utils.showSnackbar(frag.requireContext(), frag.getViewOrThrow(),
|
||||
R.string.common_check_internet_connection_dialog_title);
|
||||
}
|
||||
|
||||
private void retry()
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package com.mapswithme.maps.maplayer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.maplayer.isolines.IsolinesManager;
|
||||
import com.mapswithme.util.Utils;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
||||
import java.util.Collections;
|
||||
|
@ -23,9 +24,10 @@ public abstract class AbstractIsoLinesClickListener extends DefaultClickListener
|
|||
@Override
|
||||
public void onItemClickInternal(@NonNull View v, @NonNull BottomSheetItem item)
|
||||
{
|
||||
if (IsolinesManager.from(v.getContext()).shouldShowNotification())
|
||||
Context context = v.getContext();
|
||||
if (IsolinesManager.from(context).shouldShowNotification())
|
||||
{
|
||||
Toast.makeText(v.getContext(), R.string.isolines_toast_zooms_1_10, Toast.LENGTH_SHORT).show();
|
||||
Utils.showSnackbar(context, v.getRootView(), R.string.isolines_toast_zooms_1_10);
|
||||
Statistics.INSTANCE.trackEvent(Statistics.EventName.MAP_TOAST_SHOW,
|
||||
Collections.singletonMap(Statistics.EventParam.TYPE,
|
||||
Statistics.ParamValue.ISOLINES));
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -154,8 +153,8 @@ public class BookmarkPaymentFragment extends BaseMwmFragment
|
|||
{
|
||||
if (mState == BookmarkPaymentState.VALIDATION)
|
||||
{
|
||||
Toast.makeText(requireContext(), R.string.purchase_please_wait_toast, Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
Utils.showSnackbar(requireContext(), getView(),
|
||||
R.string.purchase_please_wait_toast);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,16 +39,19 @@ public class UGCEditorFragment extends BaseToolbarAuthFragment
|
|||
static final String ARG_ADDRESS = "arg_address";
|
||||
@NonNull
|
||||
private final UGCRatingAdapter mUGCRatingAdapter = new UGCRatingAdapter();
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@SuppressWarnings("NotNullFieldNotInitialized")
|
||||
@NonNull
|
||||
private EditText mReviewEditText;
|
||||
@SuppressWarnings("NotNullFieldNotInitialized")
|
||||
@NonNull
|
||||
private View root;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
View root = inflater.inflate(R.layout.fragment_ugc_editor, container, false);
|
||||
root = inflater.inflate(R.layout.fragment_ugc_editor, container, false);
|
||||
mReviewEditText = root.findViewById(R.id.review);
|
||||
|
||||
RecyclerView rvRatingView = root.findViewById(R.id.ratings);
|
||||
|
@ -120,9 +123,9 @@ public class UGCEditorFragment extends BaseToolbarAuthFragment
|
|||
if (!ConnectionState.INSTANCE.isConnected())
|
||||
{
|
||||
if (isAuthorized())
|
||||
Utils.toastShortcut(getContext(), R.string.ugc_thanks_message_auth);
|
||||
Utils.showSnackbar(requireContext(), root, R.string.ugc_thanks_message_auth);
|
||||
else
|
||||
Utils.toastShortcut(getContext(), R.string.ugc_thanks_message_not_auth);
|
||||
Utils.showSnackbar(requireContext(), root, R.string.ugc_thanks_message_not_auth);
|
||||
|
||||
finishActivity();
|
||||
return;
|
||||
|
@ -146,11 +149,11 @@ public class UGCEditorFragment extends BaseToolbarAuthFragment
|
|||
{
|
||||
final Notifier notifier = Notifier.from(getActivity().getApplication());
|
||||
notifier.cancelNotification(Notifier.ID_IS_NOT_AUTHENTICATED);
|
||||
Utils.toastShortcut(getContext(), R.string.ugc_thanks_message_auth);
|
||||
Utils.showSnackbar(requireContext(), root, R.string.ugc_thanks_message_auth);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.toastShortcut(getContext(), R.string.ugc_thanks_message_not_auth);
|
||||
Utils.showSnackbar(requireContext(), root, R.string.ugc_thanks_message_not_auth);
|
||||
}
|
||||
|
||||
finishActivity();
|
||||
|
@ -172,7 +175,7 @@ public class UGCEditorFragment extends BaseToolbarAuthFragment
|
|||
public void onSocialAuthenticationCancel(@Framework.AuthTokenType int type)
|
||||
{
|
||||
Statistics.INSTANCE.trackEvent(Statistics.EventName.UGC_AUTH_DECLINED);
|
||||
Utils.toastShortcut(getContext(), R.string.ugc_thanks_message_not_auth);
|
||||
Utils.showSnackbar(requireContext(), root, R.string.ugc_thanks_message_not_auth);
|
||||
finishActivity();
|
||||
}
|
||||
|
||||
|
@ -180,7 +183,7 @@ public class UGCEditorFragment extends BaseToolbarAuthFragment
|
|||
public void onSocialAuthenticationError(int type, @Nullable String error)
|
||||
{
|
||||
Statistics.INSTANCE.trackUGCAuthFailed(type, error);
|
||||
Utils.toastShortcut(getContext(), R.string.ugc_thanks_message_not_auth);
|
||||
Utils.showSnackbar(requireContext(), root, R.string.ugc_thanks_message_not_auth);
|
||||
finishActivity();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.R;
|
||||
|
@ -540,8 +539,7 @@ public class UgcSharingOptionsFragment extends BaseToolbarAuthFragment implement
|
|||
int successMsgResId = isRefreshManual ? R.string.direct_link_updating_success
|
||||
: isDirectLinkMode ? R.string.direct_link_success
|
||||
: R.string.upload_and_publish_success;
|
||||
|
||||
Toast.makeText(getContext(), successMsgResId, Toast.LENGTH_SHORT).show();
|
||||
Utils.showSnackbar(requireContext(), getViewOrThrow(), successMsgResId);
|
||||
toggleViews();
|
||||
Statistics.INSTANCE.trackSharingOptionsUploadSuccess(mCategory);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.view.KeyEvent;
|
|||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -31,6 +30,7 @@ import com.mapswithme.util.ConnectionState;
|
|||
import com.mapswithme.util.InputUtils;
|
||||
import com.mapswithme.util.StringUtils;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.Utils;
|
||||
import com.mapswithme.util.statistics.AlohaHelper;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
||||
|
@ -472,7 +472,8 @@ public class SearchToolbarController extends ToolbarController
|
|||
}
|
||||
else if (!FilterUtils.isWithinMaxStayingDays(checkinMillis, checkoutMillis))
|
||||
{
|
||||
Toast.makeText(requireActivity(), R.string.thirty_days_limit_dialog, Toast.LENGTH_LONG).show();
|
||||
Utils.showSnackbar(requireActivity(), mToolbarContainer.getRootView(),
|
||||
R.string.thirty_days_limit_dialog);
|
||||
formatAndSetChosenDates(checkinMillis, FilterUtils.getMaxCheckoutInMillis(checkinMillis));
|
||||
}
|
||||
else
|
||||
|
|
|
@ -6,9 +6,9 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.util.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -84,7 +84,7 @@ class FacilitiesAdapter extends RecyclerView.Adapter<FacilitiesAdapter.ViewHolde
|
|||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
Toast.makeText(mName.getContext(), mName.getText(), Toast.LENGTH_LONG).show();
|
||||
Utils.showSnackbar(v.getRootView(), mName.getText().toString());
|
||||
}
|
||||
|
||||
public void bind(Sponsored.FacilityType facility)
|
||||
|
|
|
@ -1977,8 +1977,7 @@ public class PlacePageView extends NestedScrollViewClickFixed
|
|||
final String tagStr = tag == null ? "" : tag.toString();
|
||||
AlohaHelper.logLongClick(tagStr);
|
||||
|
||||
Context wrapper = new ContextThemeWrapper(getContext(), R.style.MwmWidget_PopupMenu);
|
||||
final PopupMenu popup = new PopupMenu(wrapper, v);
|
||||
final PopupMenu popup = new PopupMenu(getContext(), v);
|
||||
final Menu menu = popup.getMenu();
|
||||
final List<String> items = new ArrayList<>();
|
||||
switch (v.getId())
|
||||
|
@ -2030,9 +2029,11 @@ public class PlacePageView extends NestedScrollViewClickFixed
|
|||
final int id = item.getItemId();
|
||||
final Context ctx = getContext();
|
||||
Utils.copyTextToClipboard(ctx, items.get(id));
|
||||
Utils.toastShortcut(ctx, ctx.getString(R.string.copied_to_clipboard, items.get(id)));
|
||||
Statistics.INSTANCE.trackEvent(Statistics.EventName.PP_METADATA_COPY + ":" + tagStr);
|
||||
AlohaHelper.logClick(AlohaHelper.PP_METADATA_COPY + ":" + tagStr);
|
||||
Utils.showSnackbarAbove(findViewById(R.id.pp__details_frame),
|
||||
getRootView().findViewById(R.id.menu_frame),
|
||||
ctx.getString(R.string.copied_to_clipboard, items.get(id)));
|
||||
return true;
|
||||
});
|
||||
|
||||
|
|
|
@ -31,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;
|
||||
import com.mapswithme.maps.R;
|
||||
|
@ -115,15 +116,30 @@ public class Utils
|
|||
w.clearFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
|
||||
public static void toastShortcut(Context context, String message)
|
||||
public static void showSnackbar(@NonNull View view, @NonNull String message)
|
||||
{
|
||||
Toast.makeText(context, message, Toast.LENGTH_LONG).show();
|
||||
Snackbar.make(view, message, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
public static void toastShortcut(Context context, int messageResId)
|
||||
public static void showSnackbarAbove(@NonNull View view, @NonNull View viewAbove, @NonNull String message)
|
||||
{
|
||||
Snackbar.make(view, message, Snackbar.LENGTH_LONG)
|
||||
.setAnchorView(viewAbove).show();
|
||||
}
|
||||
|
||||
public static void showSnackbar(@NonNull Context context, @NonNull View view, int messageResId)
|
||||
{
|
||||
showSnackbar(context, view, null, messageResId);
|
||||
}
|
||||
|
||||
public static void showSnackbar(@NonNull Context context, @NonNull View view,
|
||||
@Nullable View viewAbove, int messageResId)
|
||||
{
|
||||
final String message = context.getString(messageResId);
|
||||
toastShortcut(context, message);
|
||||
if (viewAbove == null)
|
||||
showSnackbar(view, message);
|
||||
else
|
||||
showSnackbarAbove(view, viewAbove, message);
|
||||
}
|
||||
|
||||
public static boolean isIntentSupported(Context context, Intent intent)
|
||||
|
@ -684,8 +700,7 @@ public class Utils
|
|||
LOGGER.e(TAG, "Failed to get string with id '" + key + "'", e);
|
||||
if (isDebugOrBeta())
|
||||
{
|
||||
Toast.makeText(context, "Add string id for '" + key + "'!",
|
||||
Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(context, "Add string id for '" + key + "'!", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
return INVALID_ID;
|
||||
|
|
Loading…
Add table
Reference in a new issue