From 85462de254050cc693f6f51cc549899fd656913a Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 26 Aug 2018 10:49:58 -0600 Subject: [PATCH] MonkeyedSnackbar: remove This didn't actually help with much and caused problems. Signed-off-by: Jason A. Donenfeld --- .../android/fragment/BaseFragment.java | 3 +- .../fragment/TunnelEditorFragment.java | 9 +++-- .../android/fragment/TunnelListFragment.java | 5 ++- .../preference/LogExporterPreference.java | 3 +- .../preference/ZipExporterPreference.java | 3 +- .../android/util/ClipboardUtils.java | 4 +-- .../android/widget/MonkeyedSnackbar.java | 36 ------------------- 7 files changed, 10 insertions(+), 53 deletions(-) delete mode 100644 app/src/main/java/com/wireguard/android/widget/MonkeyedSnackbar.java diff --git a/app/src/main/java/com/wireguard/android/fragment/BaseFragment.java b/app/src/main/java/com/wireguard/android/fragment/BaseFragment.java index 14150150..f89ece75 100644 --- a/app/src/main/java/com/wireguard/android/fragment/BaseFragment.java +++ b/app/src/main/java/com/wireguard/android/fragment/BaseFragment.java @@ -27,7 +27,6 @@ import com.wireguard.android.databinding.TunnelListItemBinding; import com.wireguard.android.model.Tunnel; import com.wireguard.android.model.Tunnel.State; import com.wireguard.android.util.ExceptionLoggers; -import com.wireguard.android.widget.MonkeyedSnackbar; /** * Base class for fragments that need to know the currently-selected tunnel. Only does anything when @@ -119,7 +118,7 @@ public abstract class BaseFragment extends Fragment implements OnSelectedTunnelC final String message = getContext().getString(messageResId, error); final View view = getView(); if (view != null) - MonkeyedSnackbar.make(view, message, Snackbar.LENGTH_LONG).show(); + Snackbar.make(view, message, Snackbar.LENGTH_LONG).show(); else Toast.makeText(getContext(), message, Toast.LENGTH_LONG).show(); Log.e(TAG, message, throwable); diff --git a/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java b/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java index b5c3f0ad..0d432a20 100644 --- a/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java +++ b/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java @@ -32,7 +32,6 @@ import com.wireguard.android.fragment.AppListDialogFragment.AppExclusionListener import com.wireguard.android.model.Tunnel; import com.wireguard.android.model.TunnelManager; import com.wireguard.android.util.ExceptionLoggers; -import com.wireguard.android.widget.MonkeyedSnackbar; import com.wireguard.config.Attribute; import com.wireguard.config.Config; import com.wireguard.config.Peer; @@ -73,7 +72,7 @@ public class TunnelEditorFragment extends BaseFragment implements AppExclusionLi message = getString(R.string.config_save_error, savedTunnel.getName(), error); Log.e(TAG, message, throwable); if (binding != null) { - MonkeyedSnackbar.make(binding.mainContainer, message, Snackbar.LENGTH_LONG).show(); + Snackbar.make(binding.mainContainer, message, Snackbar.LENGTH_LONG).show(); } } } @@ -196,7 +195,7 @@ public class TunnelEditorFragment extends BaseFragment implements AppExclusionLi final String tunnelName = tunnel == null ? binding.getConfig().getName() : tunnel.getName(); final String message = getString(R.string.config_save_error, tunnelName, error); Log.e(TAG, message, e); - MonkeyedSnackbar.make(binding.mainContainer, error, Snackbar.LENGTH_LONG).show(); + Snackbar.make(binding.mainContainer, error, Snackbar.LENGTH_LONG).show(); return false; } if (tunnel == null) { @@ -249,7 +248,7 @@ public class TunnelEditorFragment extends BaseFragment implements AppExclusionLi message = getString(R.string.tunnel_create_error, error); Log.e(TAG, message, throwable); if (binding != null) { - MonkeyedSnackbar.make(binding.mainContainer, message, Snackbar.LENGTH_LONG).show(); + Snackbar.make(binding.mainContainer, message, Snackbar.LENGTH_LONG).show(); } } } @@ -268,7 +267,7 @@ public class TunnelEditorFragment extends BaseFragment implements AppExclusionLi message = getString(R.string.tunnel_rename_error, error); Log.e(TAG, message, throwable); if (binding != null) { - MonkeyedSnackbar.make(binding.mainContainer, message, Snackbar.LENGTH_LONG).show(); + Snackbar.make(binding.mainContainer, message, Snackbar.LENGTH_LONG).show(); } } } diff --git a/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java b/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java index f9634eba..afc00530 100644 --- a/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java +++ b/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java @@ -40,7 +40,6 @@ import com.wireguard.android.databinding.TunnelListItemBinding; import com.wireguard.android.model.Tunnel; import com.wireguard.android.util.ExceptionLoggers; import com.wireguard.android.util.ObservableSortedKeyedList; -import com.wireguard.android.widget.MonkeyedSnackbar; import com.wireguard.android.widget.MultiselectableRelativeLayout; import com.wireguard.android.widget.fab.FloatingActionsMenuRecyclerViewScrollListener; import com.wireguard.config.Config; @@ -290,7 +289,7 @@ public class TunnelListFragment extends BaseFragment { Log.e(TAG, message, throwable); } if (binding != null) { - MonkeyedSnackbar.make(binding.mainContainer, message, Snackbar.LENGTH_LONG).show(); + Snackbar.make(binding.mainContainer, message, Snackbar.LENGTH_LONG).show(); } } @@ -316,7 +315,7 @@ public class TunnelListFragment extends BaseFragment { tunnels.size(), tunnels.size() + throwables.size()); if (binding != null) - MonkeyedSnackbar.make(binding.mainContainer, message, Snackbar.LENGTH_LONG).show(); + Snackbar.make(binding.mainContainer, message, Snackbar.LENGTH_LONG).show(); } @Override diff --git a/app/src/main/java/com/wireguard/android/preference/LogExporterPreference.java b/app/src/main/java/com/wireguard/android/preference/LogExporterPreference.java index 2c620f7e..a96cb9c8 100644 --- a/app/src/main/java/com/wireguard/android/preference/LogExporterPreference.java +++ b/app/src/main/java/com/wireguard/android/preference/LogExporterPreference.java @@ -20,7 +20,6 @@ import com.wireguard.android.Application; import com.wireguard.android.R; import com.wireguard.android.util.ExceptionLoggers; import com.wireguard.android.util.FragmentUtils; -import com.wireguard.android.widget.MonkeyedSnackbar; import java.io.BufferedReader; import java.io.File; @@ -80,7 +79,7 @@ public class LogExporterPreference extends Preference { final String error = ExceptionLoggers.unwrapMessage(throwable); final String message = getContext().getString(R.string.log_export_error, error); Log.e(TAG, message, throwable); - MonkeyedSnackbar.make( + Snackbar.make( FragmentUtils.getPrefActivity(this).findViewById(android.R.id.content), message, Snackbar.LENGTH_LONG).show(); setEnabled(true); diff --git a/app/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java b/app/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java index 10a9edd6..140cffa3 100644 --- a/app/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java +++ b/app/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java @@ -21,7 +21,6 @@ import com.wireguard.android.R; import com.wireguard.android.model.Tunnel; import com.wireguard.android.util.ExceptionLoggers; import com.wireguard.android.util.FragmentUtils; -import com.wireguard.android.widget.MonkeyedSnackbar; import com.wireguard.config.Config; import java.io.File; @@ -89,7 +88,7 @@ public class ZipExporterPreference extends Preference { final String error = ExceptionLoggers.unwrapMessage(throwable); final String message = getContext().getString(R.string.zip_export_error, error); Log.e(TAG, message, throwable); - MonkeyedSnackbar.make( + Snackbar.make( FragmentUtils.getPrefActivity(this).findViewById(android.R.id.content), message, Snackbar.LENGTH_LONG).show(); setEnabled(true); diff --git a/app/src/main/java/com/wireguard/android/util/ClipboardUtils.java b/app/src/main/java/com/wireguard/android/util/ClipboardUtils.java index 4857d762..ae6d9543 100644 --- a/app/src/main/java/com/wireguard/android/util/ClipboardUtils.java +++ b/app/src/main/java/com/wireguard/android/util/ClipboardUtils.java @@ -13,8 +13,6 @@ import android.support.design.widget.Snackbar; import android.view.View; import android.widget.TextView; -import com.wireguard.android.widget.MonkeyedSnackbar; - /** * Standalone utilities for interacting with the system clipboard. */ @@ -35,6 +33,6 @@ public final class ClipboardUtils { return; final CharSequence description = view.getContentDescription(); ((ClipboardManager) service).setPrimaryClip(ClipData.newPlainText(description, text)); - MonkeyedSnackbar.make(view, description + " copied to clipboard", Snackbar.LENGTH_LONG).show(); + Snackbar.make(view, description + " copied to clipboard", Snackbar.LENGTH_LONG).show(); } } diff --git a/app/src/main/java/com/wireguard/android/widget/MonkeyedSnackbar.java b/app/src/main/java/com/wireguard/android/widget/MonkeyedSnackbar.java deleted file mode 100644 index 5a243913..00000000 --- a/app/src/main/java/com/wireguard/android/widget/MonkeyedSnackbar.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright © 2018 Jason A. Donenfeld . All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -package com.wireguard.android.widget; - -import android.support.annotation.NonNull; -import android.support.design.widget.BaseTransientBottomBar; -import android.support.design.widget.Snackbar; -import android.util.Log; -import android.view.View; -import android.view.accessibility.AccessibilityManager; - -import java.lang.reflect.Field; - -public class MonkeyedSnackbar { - private static final String TAG = "WireGuard/" + MonkeyedSnackbar.class.getSimpleName(); - - public static Snackbar make(@NonNull final View view, @NonNull final CharSequence text, - @BaseTransientBottomBar.Duration final int duration) { - final Snackbar snackbar = Snackbar.make(view, text, duration); - - try { - final Field accessibilityManager = Snackbar.class.getSuperclass().getDeclaredField("mAccessibilityManager"); - accessibilityManager.setAccessible(true); - final Field isEnabled = AccessibilityManager.class.getDeclaredField("mIsEnabled"); - isEnabled.setAccessible(true); - isEnabled.setBoolean(accessibilityManager.get(snackbar), false); - } catch (final Exception e) { - Log.e(TAG, "Unable to force-enable snackbar animations", e); - } - - return snackbar; - } -}