Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b65e13ca authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Making the whole preference entry a single tap target when notification access

is not available

Bug: 64232287
Change-Id: I93dadfb88ee5d008dee7582c5f37ea3d354330cd
parent ec99420f
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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" />
+5 −4
Original line number Diff line number Diff line
@@ -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;
        }
    }

+5 −10
Original line number Diff line number Diff line
@@ -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);
        }
    }
}