summaryrefslogtreecommitdiffstats
path: root/mobile/android/base/java/org/mozilla/gecko/util/ViewUtil.java
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /mobile/android/base/java/org/mozilla/gecko/util/ViewUtil.java
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'mobile/android/base/java/org/mozilla/gecko/util/ViewUtil.java')
-rw-r--r--mobile/android/base/java/org/mozilla/gecko/util/ViewUtil.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/mobile/android/base/java/org/mozilla/gecko/util/ViewUtil.java b/mobile/android/base/java/org/mozilla/gecko/util/ViewUtil.java
new file mode 100644
index 000000000..180e821e7
--- /dev/null
+++ b/mobile/android/base/java/org/mozilla/gecko/util/ViewUtil.java
@@ -0,0 +1,33 @@
+/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+package org.mozilla.gecko.util;
+
+import android.content.res.TypedArray;
+import android.view.View;
+
+import org.mozilla.gecko.AppConstants;
+import org.mozilla.gecko.R;
+
+public class ViewUtil {
+
+ /**
+ * Enable a circular touch ripple for a given view. This is intended for borderless views,
+ * such as (3-dot) menu buttons.
+ *
+ * Because of platform limitations a square ripple is used on Android 4.
+ */
+ public static void enableTouchRipple(View view) {
+ final TypedArray backgroundDrawableArray;
+ if (AppConstants.Versions.feature21Plus) {
+ backgroundDrawableArray = view.getContext().obtainStyledAttributes(new int[] { R.attr.selectableItemBackgroundBorderless });
+ } else {
+ backgroundDrawableArray = view.getContext().obtainStyledAttributes(new int[] { R.attr.selectableItemBackground });
+ }
+
+ // This call is deprecated, but the replacement setBackground(Drawable) isn't available
+ // until API 16.
+ view.setBackgroundDrawable(backgroundDrawableArray.getDrawable(0));
+ }
+}