[automerger] Making the whole preference entry a single tap target when notification access is not available am: b65e13ca83

Change-Id: I4a2aab526002c59fcbc479121451988ae0872c23
This commit is contained in:
Sunny Goyal 2017-08-01 18:05:29 +00:00
commit 0c793abf56
3 changed files with 11 additions and 16 deletions

View File

@ -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" />

View File

@ -34,7 +34,6 @@ import android.preference.Preference;
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 @@ public class SettingsActivity extends Activity {
* 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 @@ public class SettingsActivity extends Activity {
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;
}
}

View File

@ -28,7 +28,7 @@ import android.view.ViewGroup;
*/
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 @@ public class ButtonPreference extends Preference {
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 @@ public class ButtonPreference extends Preference {
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);
}
}
}