Making the whole preference entry a single tap target when notification access
is not available
Bug: 64232287
Change-Id: I93dadfb88ee5d008dee7582c5f37ea3d354330cd
diff --git a/res/layout/notification_pref_warning.xml b/res/layout/notification_pref_warning.xml
index 795699e..100fac5 100644
--- a/res/layout/notification_pref_warning.xml
+++ b/res/layout/notification_pref_warning.xml
@@ -17,8 +17,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="48dp"
android:layout_height="match_parent"
- android:background="?android:attr/selectableItemBackgroundBorderless"
- android:contentDescription="@string/title_missing_notification_access"
+ android:importantForAccessibility="no"
android:scaleType="center"
android:src="@drawable/ic_warning"
android:tint="?android:attr/textColorSecondary" />
diff --git a/src/com/android/launcher3/SettingsActivity.java b/src/com/android/launcher3/SettingsActivity.java
index d5d5eab..fa7769e 100644
--- a/src/com/android/launcher3/SettingsActivity.java
+++ b/src/com/android/launcher3/SettingsActivity.java
@@ -34,7 +34,6 @@
import android.preference.PreferenceFragment;
import android.provider.Settings;
import android.provider.Settings.System;
-import android.view.View;
import com.android.launcher3.graphics.IconShapeOverride;
import com.android.launcher3.notification.NotificationListener;
@@ -172,7 +171,7 @@
* and updates the launcher badging setting subtext accordingly.
*/
private static class IconBadgingObserver extends ContentObserver
- implements View.OnClickListener {
+ implements Preference.OnPreferenceClickListener {
private final ButtonPreference mBadgingPref;
private final ContentResolver mResolver;
@@ -205,14 +204,16 @@
summary = R.string.title_missing_notification_access;
}
}
- mBadgingPref.setButtonOnClickListener(serviceEnabled ? null : this);
+ mBadgingPref.setWidgetFrameVisible(!serviceEnabled);
+ mBadgingPref.setOnPreferenceClickListener(serviceEnabled ? null : this);
mBadgingPref.setSummary(summary);
}
@Override
- public void onClick(View view) {
+ public boolean onPreferenceClick(Preference preference) {
new NotificationAccessConfirmation().show(mFragmentManager, "notification_access");
+ return true;
}
}
diff --git a/src/com/android/launcher3/views/ButtonPreference.java b/src/com/android/launcher3/views/ButtonPreference.java
index 4697e25..fdcf2ca 100644
--- a/src/com/android/launcher3/views/ButtonPreference.java
+++ b/src/com/android/launcher3/views/ButtonPreference.java
@@ -28,7 +28,7 @@
*/
public class ButtonPreference extends Preference {
- private View.OnClickListener mClickListener;
+ private boolean mWidgetFrameVisible = false;
public ButtonPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
@@ -46,9 +46,9 @@
super(context);
}
- public void setButtonOnClickListener(View.OnClickListener clickListener) {
- if (mClickListener != clickListener) {
- mClickListener = clickListener;
+ public void setWidgetFrameVisible(boolean isVisible) {
+ if (mWidgetFrameVisible != isVisible) {
+ mWidgetFrameVisible = isVisible;
notifyChanged();
}
}
@@ -59,12 +59,7 @@
ViewGroup widgetFrame = view.findViewById(android.R.id.widget_frame);
if (widgetFrame != null) {
- View button = widgetFrame.getChildAt(0);
- if (button != null) {
- button.setOnClickListener(mClickListener);
- }
- widgetFrame.setVisibility(
- (mClickListener == null || button == null) ? View.GONE : View.VISIBLE);
+ widgetFrame.setVisibility(mWidgetFrameVisible ? View.VISIBLE : View.GONE);
}
}
}