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.widget; 18 19 import android.content.Context; 20 import android.util.AttributeSet; 21 import android.view.View; 22 23 import androidx.preference.Preference; 24 import androidx.preference.PreferenceViewHolder; 25 26 import com.android.settings.R; 27 28 /** 29 * A preference with single target and a gear icon on the side. 30 */ 31 public class SingleTargetGearPreference extends Preference { SingleTargetGearPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)32 public SingleTargetGearPreference(Context context, AttributeSet attrs, int defStyleAttr, 33 int defStyleRes) { 34 super(context, attrs, defStyleAttr, defStyleRes); 35 init(); 36 } 37 SingleTargetGearPreference(Context context, AttributeSet attrs, int defStyleAttr)38 public SingleTargetGearPreference(Context context, AttributeSet attrs, int defStyleAttr) { 39 super(context, attrs, defStyleAttr); 40 init(); 41 } 42 SingleTargetGearPreference(Context context, AttributeSet attrs)43 public SingleTargetGearPreference(Context context, AttributeSet attrs) { 44 super(context, attrs); 45 init(); 46 } 47 SingleTargetGearPreference(Context context)48 public SingleTargetGearPreference(Context context) { 49 super(context); 50 init(); 51 } 52 init()53 private void init() { 54 setLayoutResource(R.layout.preference_single_target); 55 setWidgetLayoutResource(R.layout.preference_widget_gear_optional_background); 56 } 57 58 @Override onBindViewHolder(PreferenceViewHolder holder)59 public void onBindViewHolder(PreferenceViewHolder holder) { 60 super.onBindViewHolder(holder); 61 final View divider = holder.findViewById(com.android.settingslib.R.id.two_target_divider); 62 if (divider != null) { 63 divider.setVisibility(View.INVISIBLE); 64 } 65 } 66 } 67