• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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.settings.slices;
18 
19 import android.content.Context;
20 import android.util.AttributeSet;
21 
22 import androidx.slice.Slice;
23 import androidx.slice.widget.SliceView;
24 
25 import com.android.settings.R;
26 import com.android.settingslib.widget.LayoutPreference;
27 
28 /**
29  * Preference for {@link SliceView}
30  */
31 public class SlicePreference extends LayoutPreference {
32     private SliceView mSliceView;
33 
SlicePreference(Context context, AttributeSet attrs)34     public SlicePreference(Context context, AttributeSet attrs) {
35         super(context, attrs, R.attr.slicePreferenceStyle);
36         init();
37     }
38 
SlicePreference(Context context, AttributeSet attrs, int defStyleAttr)39     public SlicePreference(Context context, AttributeSet attrs, int defStyleAttr) {
40         super(context, attrs, defStyleAttr);
41         init();
42     }
43 
init()44     private void init() {
45         mSliceView = findViewById(R.id.slice_view);
46         mSliceView.showTitleItems(true);
47         mSliceView.setScrollable(false);
48     }
49 
onSliceUpdated(Slice slice)50     public void onSliceUpdated(Slice slice) {
51         mSliceView.onChanged(slice);
52         notifyChanged();
53     }
54 }
55