Add unavailable state to the flashlight icon

Bug: 26851684
Change-Id: I08c438aaef3e5f0731fbd1b5fef79c87c75d3022
This commit is contained in:
Jason Monk
2016-02-25 16:46:55 -05:00
parent 74b493b7bf
commit 611994e01f
2 changed files with 17 additions and 3 deletions

View File

@@ -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] -->

View File

@@ -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) {