summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com/wireguard/android
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/com/wireguard/android')
-rw-r--r--app/src/main/java/com/wireguard/android/fragment/BaseFragment.java3
-rw-r--r--app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java9
-rw-r--r--app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java5
-rw-r--r--app/src/main/java/com/wireguard/android/preference/LogExporterPreference.java3
-rw-r--r--app/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java3
-rw-r--r--app/src/main/java/com/wireguard/android/util/ClipboardUtils.java4
-rw-r--r--app/src/main/java/com/wireguard/android/widget/MonkeyedSnackbar.java33
7 files changed, 50 insertions, 10 deletions
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 f89ece75..14150150 100644
--- a/app/src/main/java/com/wireguard/android/fragment/BaseFragment.java
+++ b/app/src/main/java/com/wireguard/android/fragment/BaseFragment.java
@@ -27,6 +27,7 @@ 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
@@ -118,7 +119,7 @@ public abstract class BaseFragment extends Fragment implements OnSelectedTunnelC
final String message = getContext().getString(messageResId, error);
final View view = getView();
if (view != null)
- Snackbar.make(view, message, Snackbar.LENGTH_LONG).show();
+ MonkeyedSnackbar.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 0d432a20..b5c3f0ad 100644
--- a/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
+++ b/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
@@ -32,6 +32,7 @@ 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;
@@ -72,7 +73,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) {
- Snackbar.make(binding.mainContainer, message, Snackbar.LENGTH_LONG).show();
+ MonkeyedSnackbar.make(binding.mainContainer, message, Snackbar.LENGTH_LONG).show();
}
}
}
@@ -195,7 +196,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);
- Snackbar.make(binding.mainContainer, error, Snackbar.LENGTH_LONG).show();
+ MonkeyedSnackbar.make(binding.mainContainer, error, Snackbar.LENGTH_LONG).show();
return false;
}
if (tunnel == null) {
@@ -248,7 +249,7 @@ public class TunnelEditorFragment extends BaseFragment implements AppExclusionLi
message = getString(R.string.tunnel_create_error, error);
Log.e(TAG, message, throwable);
if (binding != null) {
- Snackbar.make(binding.mainContainer, message, Snackbar.LENGTH_LONG).show();
+ MonkeyedSnackbar.make(binding.mainContainer, message, Snackbar.LENGTH_LONG).show();
}
}
}
@@ -267,7 +268,7 @@ public class TunnelEditorFragment extends BaseFragment implements AppExclusionLi
message = getString(R.string.tunnel_rename_error, error);
Log.e(TAG, message, throwable);
if (binding != null) {
- Snackbar.make(binding.mainContainer, message, Snackbar.LENGTH_LONG).show();
+ MonkeyedSnackbar.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 17fecbef..f8b03b25 100644
--- a/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
+++ b/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
@@ -40,6 +40,7 @@ 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.fab.FloatingActionsMenuRecyclerViewScrollListener;
import com.wireguard.config.Config;
@@ -298,7 +299,7 @@ public class TunnelListFragment extends BaseFragment {
Log.e(TAG, message, throwable);
}
if (binding != null) {
- Snackbar.make(binding.mainContainer, message, Snackbar.LENGTH_LONG).show();
+ MonkeyedSnackbar.make(binding.mainContainer, message, Snackbar.LENGTH_LONG).show();
}
}
@@ -324,7 +325,7 @@ public class TunnelListFragment extends BaseFragment {
tunnels.size(), tunnels.size() + throwables.size());
if (binding != null)
- Snackbar.make(binding.mainContainer, message, Snackbar.LENGTH_LONG).show();
+ MonkeyedSnackbar.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 a96cb9c8..2c620f7e 100644
--- a/app/src/main/java/com/wireguard/android/preference/LogExporterPreference.java
+++ b/app/src/main/java/com/wireguard/android/preference/LogExporterPreference.java
@@ -20,6 +20,7 @@ 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;
@@ -79,7 +80,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);
- Snackbar.make(
+ MonkeyedSnackbar.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 140cffa3..10a9edd6 100644
--- a/app/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java
+++ b/app/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java
@@ -21,6 +21,7 @@ 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;
@@ -88,7 +89,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);
- Snackbar.make(
+ MonkeyedSnackbar.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 ae6d9543..4857d762 100644
--- a/app/src/main/java/com/wireguard/android/util/ClipboardUtils.java
+++ b/app/src/main/java/com/wireguard/android/util/ClipboardUtils.java
@@ -13,6 +13,8 @@ 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.
*/
@@ -33,6 +35,6 @@ public final class ClipboardUtils {
return;
final CharSequence description = view.getContentDescription();
((ClipboardManager) service).setPrimaryClip(ClipData.newPlainText(description, text));
- Snackbar.make(view, description + " copied to clipboard", Snackbar.LENGTH_LONG).show();
+ MonkeyedSnackbar.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
new file mode 100644
index 00000000..e32316cd
--- /dev/null
+++ b/app/src/main/java/com/wireguard/android/widget/MonkeyedSnackbar.java
@@ -0,0 +1,33 @@
+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 com.wireguard.android.BootShutdownReceiver;
+
+import java.lang.reflect.Field;
+
+public class MonkeyedSnackbar {
+ private static final String TAG = "WireGuard/" + BootShutdownReceiver.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;
+ }
+}