1 /* 2 * Copyright (C) 2016 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.soundpicker; 18 19 import android.content.Context; 20 import android.widget.Checkable; 21 import android.widget.CheckedTextView; 22 import android.widget.RelativeLayout; 23 import android.util.AttributeSet; 24 25 /** 26 * The {@link CheckedListItem} is a layout item that represents a ringtone, and is used in 27 * {@link RingtonePickerActivity}. It contains the ringtone's name, and a work badge to right of the 28 * name if the ringtone belongs to a work profile. 29 */ 30 public class CheckedListItem extends RelativeLayout implements Checkable { 31 CheckedListItem(Context context)32 public CheckedListItem(Context context) { 33 super(context); 34 } 35 CheckedListItem(Context context, AttributeSet attrs)36 public CheckedListItem(Context context, AttributeSet attrs) { 37 super(context, attrs); 38 } 39 CheckedListItem(Context context, AttributeSet attrs, int defStyleAttr)40 public CheckedListItem(Context context, AttributeSet attrs, int defStyleAttr) { 41 super(context, attrs, defStyleAttr); 42 } 43 CheckedListItem(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)44 public CheckedListItem(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 45 super(context, attrs, defStyleAttr, defStyleRes); 46 } 47 48 @Override setChecked(boolean checked)49 public void setChecked(boolean checked) { 50 getCheckedTextView().setChecked(checked); 51 } 52 53 @Override isChecked()54 public boolean isChecked() { 55 return getCheckedTextView().isChecked(); 56 } 57 58 @Override toggle()59 public void toggle() { 60 getCheckedTextView().toggle(); 61 } 62 getCheckedTextView()63 private CheckedTextView getCheckedTextView() { 64 return (CheckedTextView) findViewById(R.id.checked_text_view); 65 } 66 67 } 68