Merge "Volume: Remove silent mode icon." into lmp-dev

This commit is contained in:
John Spurlock
2014-07-20 22:19:52 +00:00
committed by Android (Google) Code Review
7 changed files with 111 additions and 87 deletions

View File

@@ -1,28 +0,0 @@
<!--
Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android" >
<size
android:width="32dp"
android:height="32dp"/>
<viewport
android:viewportWidth="24.0"
android:viewportHeight="24.0"/>
<path
android:fill="@color/qs_subhead"
android:pathData="M11.5,22.0c1.1,0.0 2.0,-0.9 2.0,-2.0l-4.0,0.0C9.5,21.1 10.4,22.0 11.5,22.0zM18.0,10.5c0.0,-3.1 -2.1,-5.6 -5.0,-6.3L13.0,3.5C13.0,2.7 12.3,2.0 11.5,2.0C10.7,2.0 10.0,2.7 10.0,3.5l0.0,0.7C9.5,4.3 9.0,4.5 8.6,4.7l9.4,9.4L18.0,10.5zM17.7,19.0l2.0,2.0l1.3,-1.3L4.3,3.0L3.0,4.3l2.9,2.9C5.3,8.2 5.0,9.3 5.0,10.5L5.0,16.0l-2.0,2.0l0.0,1.0L17.7,19.0z" />
</vector>

View File

@@ -1,28 +0,0 @@
<!--
Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android" >
<size
android:width="19dp"
android:height="19dp"/>
<viewport
android:viewportWidth="24.0"
android:viewportHeight="24.0"/>
<path
android:fill="#FFFFFFFF"
android:pathData="M11.5,22.0c1.1,0.0 2.0,-0.9 2.0,-2.0l-4.0,0.0C9.5,21.1 10.4,22.0 11.5,22.0zM18.0,10.5c0.0,-3.1 -2.1,-5.6 -5.0,-6.3L13.0,3.5C13.0,2.7 12.3,2.0 11.5,2.0C10.7,2.0 10.0,2.7 10.0,3.5l0.0,0.7C9.5,4.3 9.0,4.5 8.6,4.7l9.4,9.4L18.0,10.5zM17.7,19.0l2.0,2.0l1.3,-1.3L4.3,3.0L3.0,4.3l2.9,2.9C5.3,8.2 5.0,9.3 5.0,10.5L5.0,16.0l-2.0,2.0l0.0,1.0L17.7,19.0z" />
</vector>

View File

@@ -60,12 +60,17 @@ public class DemoStatusIcons extends LinearLayout implements DemoMode {
} else if (mDemoMode && command.equals(COMMAND_STATUS)) {
String volume = args.getString("volume");
if (volume != null) {
int iconId = volume.equals("important") ? R.drawable.stat_sys_zen_important
: volume.equals("silent") ? R.drawable.stat_sys_ringer_silent
: volume.equals("vibrate") ? R.drawable.stat_sys_ringer_vibrate
int iconId = volume.equals("vibrate") ? R.drawable.stat_sys_ringer_vibrate
: 0;
updateSlot("volume", null, iconId);
}
String zen = args.getString("zen");
if (zen != null) {
int iconId = zen.equals("important") ? R.drawable.stat_sys_zen_important
: zen.equals("none") ? R.drawable.stat_sys_zen_none
: 0;
updateSlot("zen", null, iconId);
}
String bt = args.getString("bluetooth");
if (bt != null) {
int iconId = bt.equals("disconnected") ? R.drawable.stat_sys_data_bluetooth

View File

@@ -148,7 +148,7 @@ public class PhoneStatusBarPolicy {
mService.setIconVisibility(SLOT_ZEN, false);
// volume
mService.setIcon(SLOT_VOLUME, R.drawable.stat_sys_ringer_silent, 0, null);
mService.setIcon(SLOT_VOLUME, R.drawable.stat_sys_ringer_vibrate, 0, null);
mService.setIconVisibility(SLOT_VOLUME, false);
updateVolumeZen();
}

View File

@@ -20,5 +20,4 @@ import com.android.systemui.statusbar.policy.ZenModeController;
public interface VolumeComponent {
ZenModeController getZenController();
void setVolumePanel(VolumePanel panel);
}

View File

@@ -25,6 +25,7 @@ import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.PixelFormat;
import android.graphics.drawable.ColorDrawable;
import android.media.AudioAttributes;
@@ -42,13 +43,13 @@ import android.os.Message;
import android.os.Vibrator;
import android.provider.Settings.Global;
import android.util.Log;
import android.util.SparseArray;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
@@ -59,7 +60,8 @@ import android.widget.SeekBar.OnSeekBarChangeListener;
import com.android.internal.R;
import com.android.systemui.statusbar.policy.ZenModeController;
import java.util.HashMap;
import java.io.FileDescriptor;
import java.io.PrintWriter;
/**
* Handles the user interface for the volume keys.
@@ -123,6 +125,9 @@ public class VolumePanel extends Handler {
private boolean mZenModeCapable;
private boolean mZenPanelExpanded;
private int mTimeoutDelay = TIMEOUT_DELAY;
private float mDisabledAlpha;
private int mLastRingerMode = AudioManager.RINGER_MODE_NORMAL;
private int mLastRingerProgress = 0;
// True if we want to play tones on the system stream when the master stream is specified.
private final boolean mPlayMasterStreamTones;
@@ -145,7 +150,7 @@ public class VolumePanel extends Handler {
/** Currently active stream that shows up at the top of the list of sliders */
private int mActiveStreamType = -1;
/** All the slider controls mapped by stream type */
private HashMap<Integer,StreamControl> mStreamControls;
private SparseArray<StreamControl> mStreamControls;
private enum StreamResources {
BluetoothSCOStream(AudioManager.STREAM_BLUETOOTH_SCO,
@@ -156,7 +161,7 @@ public class VolumePanel extends Handler {
RingerStream(AudioManager.STREAM_RING,
R.string.volume_icon_description_ringer,
com.android.systemui.R.drawable.ic_ringer_audible,
com.android.systemui.R.drawable.ic_ringer_silent,
com.android.systemui.R.drawable.ic_ringer_vibrate,
false),
VoiceStream(AudioManager.STREAM_VOICE_CALL,
R.string.volume_icon_description_incall,
@@ -176,7 +181,7 @@ public class VolumePanel extends Handler {
NotificationStream(AudioManager.STREAM_NOTIFICATION,
R.string.volume_icon_description_notification,
com.android.systemui.R.drawable.ic_ringer_audible,
com.android.systemui.R.drawable.ic_ringer_silent,
com.android.systemui.R.drawable.ic_ringer_vibrate,
true),
// for now, use media resources for master volume
MasterStream(STREAM_MASTER,
@@ -271,7 +276,6 @@ public class VolumePanel extends Handler {
}
}
public VolumePanel(Context context, ZenModeController zenController) {
mTag = String.format("%s.%08x", TAG, hashCode());
mContext = context;
@@ -289,6 +293,14 @@ public class VolumePanel extends Handler {
}
if (LOGD) Log.d(mTag, "new VolumePanel");
mDisabledAlpha = 0.5f;
if (mContext.getTheme() != null) {
final TypedArray arr = mContext.getTheme().obtainStyledAttributes(
new int[] { android.R.attr.disabledAlpha });
mDisabledAlpha = arr.getFloat(0, mDisabledAlpha);
arr.recycle();
}
mDialog = new Dialog(context) {
@Override
public boolean onTouchEvent(MotionEvent event) {
@@ -362,6 +374,43 @@ public class VolumePanel extends Handler {
listenToRingerMode();
}
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.println("VolumePanel state:");
pw.print(" mTag="); pw.println(mTag);
pw.print(" mRingIsSilent="); pw.println(mRingIsSilent);
pw.print(" mVoiceCapable="); pw.println(mVoiceCapable);
pw.print(" mZenModeCapable="); pw.println(mZenModeCapable);
pw.print(" mZenPanelExpanded="); pw.println(mZenPanelExpanded);
pw.print(" mTimeoutDelay="); pw.println(mTimeoutDelay);
pw.print(" mDisabledAlpha="); pw.println(mDisabledAlpha);
pw.print(" mLastRingerMode="); pw.println(mLastRingerMode);
pw.print(" mLastRingerProgress="); pw.println(mLastRingerProgress);
pw.print(" mPlayMasterStreamTones="); pw.println(mPlayMasterStreamTones);
pw.print(" isShowing()="); pw.println(isShowing());
pw.print(" mCallback="); pw.println(mCallback);
pw.print(" sConfirmSafeVolumeDialog=");
pw.println(sConfirmSafeVolumeDialog != null ? "<not null>" : null);
pw.print(" mActiveStreamType="); pw.println(mActiveStreamType);
pw.print(" mStreamControls=");
if (mStreamControls == null) {
pw.println("null");
} else {
final int N = mStreamControls.size();
pw.print("<size "); pw.print(N); pw.println('>');
for (int i = 0; i < N; i++) {
final StreamControl sc = mStreamControls.valueAt(i);
pw.print(" stream "); pw.print(sc.streamType); pw.print(":");
if (sc.seekbarView != null) {
pw.print(" progress="); pw.print(sc.seekbarView.getProgress());
pw.print(" of "); pw.print(sc.seekbarView.getMax());
if (!sc.seekbarView.isEnabled()) pw.print(" (disabled)");
}
if (sc.icon != null && sc.icon.isClickable()) pw.print(" (clickable)");
pw.println();
}
}
}
private void initZenModePanel() {
mZenPanel.init(mZenController);
mZenPanel.setCallback(new ZenModePanel.Callback() {
@@ -474,7 +523,7 @@ public class VolumePanel extends Handler {
final LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
mStreamControls = new HashMap<Integer, StreamControl>(STREAMS.length);
mStreamControls = new SparseArray<StreamControl>(STREAMS.length);
for (int i = 0; i < STREAMS.length; i++) {
StreamResources streamRes = STREAMS[i];
@@ -540,17 +589,40 @@ public class VolumePanel extends Handler {
}
}
private void updateSliderProgress(StreamControl sc, int progress) {
final boolean isRinger = isNotificationOrRing(sc.streamType);
if (isRinger && mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) {
progress = mLastRingerProgress;
}
if (progress < 0) {
progress = getStreamVolume(sc.streamType);
}
sc.seekbarView.setProgress(progress);
if (isRinger) {
mLastRingerProgress = progress;
}
}
private void updateSliderIcon(StreamControl sc, boolean muted) {
if (isNotificationOrRing(sc.streamType)) {
int ringerMode = mAudioManager.getRingerMode();
if (ringerMode == AudioManager.RINGER_MODE_SILENT) {
ringerMode = mLastRingerMode;
} else {
mLastRingerMode = ringerMode;
}
muted = ringerMode == AudioManager.RINGER_MODE_VIBRATE;
}
sc.icon.setImageResource(muted ? sc.iconMuteRes : sc.iconRes);
}
/** Update the mute and progress state of a slider */
private void updateSlider(StreamControl sc) {
sc.seekbarView.setProgress(getStreamVolume(sc.streamType));
updateSliderProgress(sc, -1);
final boolean muted = isMuted(sc.streamType);
// Force reloading the image resource
sc.icon.setImageDrawable(null);
sc.icon.setImageResource(muted ? sc.iconMuteRes : sc.iconRes);
if (isNotificationOrRing(sc.streamType) &&
mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE) {
sc.icon.setImageResource(com.android.systemui.R.drawable.ic_ringer_vibrate);
}
updateSliderIcon(sc, muted);
updateSliderEnabled(sc, muted, false);
}
@@ -568,10 +640,12 @@ public class VolumePanel extends Handler {
} else if (isRinger && mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) {
sc.seekbarView.setEnabled(false);
sc.icon.setEnabled(false);
sc.icon.setAlpha(mDisabledAlpha);
sc.icon.setClickable(false);
} else {
sc.seekbarView.setEnabled(true);
sc.icon.setEnabled(true);
sc.icon.setAlpha(1f);
}
// show the silent hint when the disabled slider is touched in silent mode
if (isRinger && wasEnabled != sc.seekbarView.isEnabled()) {
@@ -769,7 +843,7 @@ public class VolumePanel extends Handler {
StreamControl sc = mStreamControls.get(streamType);
if (sc != null) {
sc.icon.setImageResource(isMuted(sc.streamType) ? sc.iconMuteRes : sc.iconRes);
updateSliderIcon(sc, isMuted(sc.streamType));
}
onVolumeChanged(streamType, flags);
@@ -885,8 +959,7 @@ public class VolumePanel extends Handler {
if (sc.seekbarView.getMax() != max) {
sc.seekbarView.setMax(max);
}
sc.seekbarView.setProgress(index);
updateSliderProgress(sc, index);
updateSliderEnabled(sc, isMuted(streamType),
(flags & AudioManager.FLAG_FIXED_VOLUME) != 0);
}
@@ -1096,7 +1169,7 @@ public class VolumePanel extends Handler {
if (sc != null) {
sc.iconRes = resId;
sc.iconMuteRes = resMuteId;
sc.icon.setImageResource(isMuted(sc.streamType) ? sc.iconMuteRes : sc.iconRes);
updateSliderIcon(sc, isMuted(sc.streamType));
}
}

View File

@@ -24,6 +24,9 @@ import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.statusbar.policy.ZenModeControllerImpl;
import java.io.FileDescriptor;
import java.io.PrintWriter;
/*
* Copyright (C) 2014 The Android Open Source Project
*
@@ -53,7 +56,6 @@ public class VolumeUI extends SystemUI {
private VolumeController mVolumeController;
private RemoteVolumeController mRemoteVolumeController;
private VolumePanel mDialogPanel;
private VolumePanel mPanel;
private int mDismissDelay;
@@ -70,6 +72,13 @@ public class VolumeUI extends SystemUI {
mContext.getContentResolver().registerContentObserver(SETTING_URI, false, mObserver);
}
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (mPanel != null) {
mPanel.dump(fd, pw, args);
}
}
private void updateController() {
if (Settings.Global.getInt(mContext.getContentResolver(), SETTING, DEFAULT) != 0) {
Log.d(TAG, "Registering volume controller");
@@ -107,7 +116,6 @@ public class VolumeUI extends SystemUI {
}
}
});
mDialogPanel = mPanel;
}
private final ContentObserver mObserver = new ContentObserver(mHandler) {
@@ -137,7 +145,7 @@ public class VolumeUI extends SystemUI {
mContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
}
});
mDialogPanel.postDismiss(mDismissDelay);
mPanel.postDismiss(mDismissDelay);
}
};
@@ -178,12 +186,7 @@ public class VolumeUI extends SystemUI {
@Override
public ZenModeController getZenController() {
return mDialogPanel.getZenController();
}
@Override
public void setVolumePanel(VolumePanel panel) {
mPanel = panel == null ? mDialogPanel : panel;
return mPanel.getZenController();
}
}