diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2017-07-07 03:12:21 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2017-07-10 11:10:35 -0700 |
commit | 848cad56ced14a2149d937bd6482387df8538c98 (patch) | |
tree | 2e6cbe2b29a982ff123c2c48a924b98d93e83820 /src/com/android/launcher3/views | |
parent | 6c5d10261eceaf1b57bce82e4e31d272bad2c349 (diff) | |
download | android_packages_apps_Trebuchet-848cad56ced14a2149d937bd6482387df8538c98.tar.gz android_packages_apps_Trebuchet-848cad56ced14a2149d937bd6482387df8538c98.tar.bz2 android_packages_apps_Trebuchet-848cad56ced14a2149d937bd6482387df8538c98.zip |
Adding a warning button when notification access is not available
Bug: 63418030
Change-Id: I4c2c497d989902ac002314a3b8fb97083757958b
Diffstat (limited to 'src/com/android/launcher3/views')
-rw-r--r-- | src/com/android/launcher3/views/ButtonPreference.java | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/com/android/launcher3/views/ButtonPreference.java b/src/com/android/launcher3/views/ButtonPreference.java new file mode 100644 index 000000000..4697e25e4 --- /dev/null +++ b/src/com/android/launcher3/views/ButtonPreference.java @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.launcher3.views; + +import android.content.Context; +import android.preference.Preference; +import android.util.AttributeSet; +import android.view.View; +import android.view.ViewGroup; + +/** + * Extension of {@link Preference} which makes the widget layout clickable. + * + * @see #setWidgetLayoutResource(int) + */ +public class ButtonPreference extends Preference { + + private View.OnClickListener mClickListener; + + public ButtonPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + } + + public ButtonPreference(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + public ButtonPreference(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public ButtonPreference(Context context) { + super(context); + } + + public void setButtonOnClickListener(View.OnClickListener clickListener) { + if (mClickListener != clickListener) { + mClickListener = clickListener; + notifyChanged(); + } + } + + @Override + protected void onBindView(View view) { + super.onBindView(view); + + 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); + } + } +} |