Alan Viverette | f6a6798 | 2014-04-08 15:27:24 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.settings; |
| 18 | |
| 19 | import android.content.Context; |
yuemingw | eb2bf7d18 | 2018-01-23 16:05:08 +0000 | [diff] [blame] | 20 | import android.content.Intent; |
Alan Viverette | f6a6798 | 2014-04-08 15:27:24 -0700 | [diff] [blame] | 21 | import android.util.AttributeSet; |
| 22 | import android.view.MotionEvent; |
Selim Cinek | 4949c75 | 2015-06-26 14:49:18 -0400 | [diff] [blame] | 23 | import android.view.accessibility.AccessibilityNodeInfo; |
Alan Viverette | f6a6798 | 2014-04-08 15:27:24 -0700 | [diff] [blame] | 24 | import android.widget.SeekBar; |
| 25 | |
yuemingw | eb2bf7d18 | 2018-01-23 16:05:08 +0000 | [diff] [blame] | 26 | import com.android.settingslib.RestrictedLockUtils; |
| 27 | import com.android.systemui.Dependency; |
| 28 | import com.android.systemui.plugins.ActivityStarter; |
| 29 | |
Alan Viverette | f6a6798 | 2014-04-08 15:27:24 -0700 | [diff] [blame] | 30 | public class ToggleSeekBar extends SeekBar { |
Selim Cinek | 4949c75 | 2015-06-26 14:49:18 -0400 | [diff] [blame] | 31 | private String mAccessibilityLabel; |
| 32 | |
yuemingw | eb2bf7d18 | 2018-01-23 16:05:08 +0000 | [diff] [blame] | 33 | private RestrictedLockUtils.EnforcedAdmin mEnforcedAdmin = null; |
| 34 | |
Alan Viverette | f6a6798 | 2014-04-08 15:27:24 -0700 | [diff] [blame] | 35 | public ToggleSeekBar(Context context) { |
| 36 | super(context); |
| 37 | } |
| 38 | |
| 39 | public ToggleSeekBar(Context context, AttributeSet attrs) { |
| 40 | super(context, attrs); |
| 41 | } |
| 42 | |
| 43 | public ToggleSeekBar(Context context, AttributeSet attrs, int defStyleAttr) { |
| 44 | super(context, attrs, defStyleAttr); |
| 45 | } |
| 46 | |
| 47 | @Override |
| 48 | public boolean onTouchEvent(MotionEvent event) { |
yuemingw | eb2bf7d18 | 2018-01-23 16:05:08 +0000 | [diff] [blame] | 49 | if (mEnforcedAdmin != null) { |
| 50 | Intent intent = RestrictedLockUtils.getShowAdminSupportDetailsIntent( |
| 51 | mContext, mEnforcedAdmin); |
| 52 | Dependency.get(ActivityStarter.class).postStartActivityDismissingKeyguard(intent, 0); |
| 53 | return true; |
| 54 | } |
Alan Viverette | f6a6798 | 2014-04-08 15:27:24 -0700 | [diff] [blame] | 55 | if (!isEnabled()) { |
| 56 | setEnabled(true); |
| 57 | } |
| 58 | |
| 59 | return super.onTouchEvent(event); |
| 60 | } |
Selim Cinek | 4949c75 | 2015-06-26 14:49:18 -0400 | [diff] [blame] | 61 | |
| 62 | public void setAccessibilityLabel(String label) { |
| 63 | mAccessibilityLabel = label; |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { |
| 68 | super.onInitializeAccessibilityNodeInfo(info); |
| 69 | if (mAccessibilityLabel != null) { |
| 70 | info.setText(mAccessibilityLabel); |
| 71 | } |
| 72 | } |
yuemingw | eb2bf7d18 | 2018-01-23 16:05:08 +0000 | [diff] [blame] | 73 | |
| 74 | public void setEnforcedAdmin(RestrictedLockUtils.EnforcedAdmin admin) { |
| 75 | mEnforcedAdmin = admin; |
| 76 | } |
Alan Viverette | f6a6798 | 2014-04-08 15:27:24 -0700 | [diff] [blame] | 77 | } |