Add unavailable state to the flashlight icon
Bug: 26851684 Change-Id: I08c438aaef3e5f0731fbd1b5fef79c87c75d3022
This commit is contained in:
@@ -497,6 +497,8 @@
|
|||||||
<string name="accessibility_quick_settings_less_time">Less time.</string>
|
<string name="accessibility_quick_settings_less_time">Less time.</string>
|
||||||
<!-- Content description of the flashlight tile in quick settings when off (not shown on the screen). [CHAR LIMIT=NONE] -->
|
<!-- Content description of the flashlight tile in quick settings when off (not shown on the screen). [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_quick_settings_flashlight_off">Flashlight off.</string>
|
<string name="accessibility_quick_settings_flashlight_off">Flashlight off.</string>
|
||||||
|
<!-- Content description of the flashlight tile in quick settings when unavailable (not shown on the screen). [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="accessibility_quick_settings_flashlight_unavailable">Flashlight unavailable.</string>
|
||||||
<!-- Content description of the flashlight tile in quick settings when on (not shown on the screen). [CHAR LIMIT=NONE] -->
|
<!-- Content description of the flashlight tile in quick settings when on (not shown on the screen). [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_quick_settings_flashlight_on">Flashlight on.</string>
|
<string name="accessibility_quick_settings_flashlight_on">Flashlight on.</string>
|
||||||
<!-- Announcement made when the flashlight state changes to off (not shown on the screen). [CHAR LIMIT=NONE] -->
|
<!-- Announcement made when the flashlight state changes to off (not shown on the screen). [CHAR LIMIT=NONE] -->
|
||||||
|
|||||||
@@ -17,9 +17,11 @@
|
|||||||
package com.android.systemui.qs.tiles;
|
package com.android.systemui.qs.tiles;
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
|
import android.text.SpannableStringBuilder;
|
||||||
|
import android.text.style.ForegroundColorSpan;
|
||||||
import com.android.internal.logging.MetricsLogger;
|
import com.android.internal.logging.MetricsLogger;
|
||||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
@@ -79,9 +81,19 @@ public class FlashlightTile extends QSTile<QSTile.BooleanState> implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleUpdateState(BooleanState state, Object arg) {
|
protected void handleUpdateState(BooleanState state, Object arg) {
|
||||||
// TODO: Flashlight available handling...
|
|
||||||
// state.visible = mFlashlightController.isAvailable();
|
|
||||||
state.label = mHost.getContext().getString(R.string.quick_settings_flashlight_label);
|
state.label = mHost.getContext().getString(R.string.quick_settings_flashlight_label);
|
||||||
|
if (!mFlashlightController.isAvailable()) {
|
||||||
|
Drawable icon = mHost.getContext().getDrawable(R.drawable.ic_signal_flashlight_disable);
|
||||||
|
final int disabledColor = mHost.getContext().getColor(R.color.qs_tile_tint_unavailable);
|
||||||
|
icon.setTint(disabledColor);
|
||||||
|
state.icon = new DrawableIcon(icon);
|
||||||
|
state.label = new SpannableStringBuilder().append(state.label,
|
||||||
|
new ForegroundColorSpan(disabledColor),
|
||||||
|
SpannableStringBuilder.SPAN_INCLUSIVE_INCLUSIVE);
|
||||||
|
state.contentDescription = mContext.getString(
|
||||||
|
R.string.accessibility_quick_settings_flashlight_unavailable);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (arg instanceof Boolean) {
|
if (arg instanceof Boolean) {
|
||||||
boolean value = (Boolean) arg;
|
boolean value = (Boolean) arg;
|
||||||
if (value == state.value) {
|
if (value == state.value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user