| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.service.controls.templates; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.os.Bundle; |
| 21 |
import android.service.controls.Control; |
| 22 |
import android.service.controls.actions.BooleanAction; |
| 23 |
|
| 24 |
import com.android.internal.util.Preconditions; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
public final class ToggleTemplate extends ControlTemplate { |
| 35 |
|
| 36 |
private static final @TemplateType int TYPE = TYPE_TOGGLE; |
| 37 |
private static final String KEY_BUTTON = "key_button"; |
| 38 |
private final @NonNull ControlButton mButton; |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
public ToggleTemplate(@NonNull String templateId, @NonNull ControlButton button) { |
| 45 |
super(templateId); |
| 46 |
Preconditions.checkNotNull(button); |
| 47 |
mButton = button; |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
ToggleTemplate(Bundle b) { |
| 55 |
super(b); |
| 56 |
mButton = b.getParcelable(KEY_BUTTON); |
| 57 |
} |
| 58 |
|
| 59 |
public boolean isChecked() { |
| 60 |
return mButton.isChecked(); |
| 61 |
} |
| 62 |
|
| 63 |
@NonNull |
| 64 |
public CharSequence getContentDescription() { |
| 65 |
return mButton.getActionDescription(); |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
@Override |
| 72 |
public int getTemplateType() { |
| 73 |
return TYPE; |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
@Override |
| 81 |
@NonNull |
| 82 |
Bundle getDataBundle() { |
| 83 |
Bundle b = super.getDataBundle(); |
| 84 |
b.putParcelable(KEY_BUTTON, mButton); |
| 85 |
return b; |
| 86 |
} |
| 87 |
} |