package android.widget;
import android.content.Context;
+import android.content.res.Resources;
import android.graphics.PixelFormat;
import android.media.AudioManager;
import android.os.Handler;
* <p>
* Functions like show() and hide() have no effect when MediaController
* is created in an xml layout.
- *
+ *
* MediaController will hide and
* show the buttons according to these rules:
* <ul>
*/
public class MediaController extends FrameLayout {
- private MediaPlayerControl mPlayer;
- private Context mContext;
- private View mAnchor;
- private View mRoot;
- private WindowManager mWindowManager;
- private Window mWindow;
- private View mDecor;
+ private MediaPlayerControl mPlayer;
+ private Context mContext;
+ private View mAnchor;
+ private View mRoot;
+ private WindowManager mWindowManager;
+ private Window mWindow;
+ private View mDecor;
private WindowManager.LayoutParams mDecorLayoutParams;
- private ProgressBar mProgress;
- private TextView mEndTime, mCurrentTime;
- private boolean mShowing;
- private boolean mDragging;
- private static final int sDefaultTimeout = 3000;
- private static final int FADE_OUT = 1;
- private static final int SHOW_PROGRESS = 2;
- private boolean mUseFastForward;
- private boolean mFromXml;
- private boolean mListenersSet;
+ private ProgressBar mProgress;
+ private TextView mEndTime, mCurrentTime;
+ private boolean mShowing;
+ private boolean mDragging;
+ private static final int sDefaultTimeout = 3000;
+ private static final int FADE_OUT = 1;
+ private static final int SHOW_PROGRESS = 2;
+ private boolean mUseFastForward;
+ private boolean mFromXml;
+ private boolean mListenersSet;
private View.OnClickListener mNextListener, mPrevListener;
- StringBuilder mFormatBuilder;
- Formatter mFormatter;
- private ImageButton mPauseButton;
- private ImageButton mFfwdButton;
- private ImageButton mRewButton;
- private ImageButton mNextButton;
- private ImageButton mPrevButton;
+ StringBuilder mFormatBuilder;
+ Formatter mFormatter;
+ private ImageButton mPauseButton;
+ private ImageButton mFfwdButton;
+ private ImageButton mRewButton;
+ private ImageButton mNextButton;
+ private ImageButton mPrevButton;
+ private CharSequence mPlayDescription;
+ private CharSequence mPauseDescription;
public MediaController(Context context, AttributeSet attrs) {
super(context, attrs);
mDecor.setOnTouchListener(mTouchListener);
mWindow.setContentView(this);
mWindow.setBackgroundDrawableResource(android.R.color.transparent);
-
+
// While the media controller is up, the volume control keys should
// affect the media stream type
mWindow.setVolumeControlStream(AudioManager.STREAM_MUSIC);
return false;
}
};
-
+
public void setMediaPlayer(MediaPlayerControl player) {
mPlayer = player;
updatePausePlay();
}
private void initControllerView(View v) {
+ Resources res = mContext.getResources();
+ mPlayDescription = res
+ .getText(com.android.internal.R.string.lockscreen_transport_play_description);
+ mPauseDescription = res
+ .getText(com.android.internal.R.string.lockscreen_transport_pause_description);
mPauseButton = (ImageButton) v.findViewById(com.android.internal.R.id.pause);
if (mPauseButton != null) {
mPauseButton.requestFocus();
}
}
- // By default these are hidden. They will be enabled when setPrevNextListeners() is called
+ // By default these are hidden. They will be enabled when setPrevNextListeners() is called
mNextButton = (ImageButton) v.findViewById(com.android.internal.R.id.next);
if (mNextButton != null && !mFromXml && !mListenersSet) {
mNextButton.setVisibility(View.GONE);
// the buttons.
}
}
-
+
/**
* Show the controller on screen. It will go away
* automatically after 'timeout' milliseconds of inactivity.
mShowing = true;
}
updatePausePlay();
-
+
// cause the progress bar to be updated even if mShowing
// was already true. This happens, for example, if we're
// paused with the progress bar showing the user hits play.
mHandler.sendMessageDelayed(msg, timeout);
}
}
-
+
public boolean isShowing() {
return mShowing;
}
if (mPlayer.isPlaying()) {
mPauseButton.setImageResource(com.android.internal.R.drawable.ic_media_pause);
+ mPauseButton.setContentDescription(mPauseDescription);
} else {
mPauseButton.setImageResource(com.android.internal.R.drawable.ic_media_play);
+ mPauseButton.setContentDescription(mPlayDescription);
}
}
if (mRoot != null) {
installPrevNextListeners();
-
+
if (mNextButton != null && !mFromXml) {
mNextButton.setVisibility(View.VISIBLE);
}
Contact your wireless service provider for another SIM card.</string>
<!-- Shown on transport control of lockscreen. Pressing button goes to previous track. -->
- <string name="lockscreen_transport_prev_description">Previous track button</string>
+ <string name="lockscreen_transport_prev_description">Previous track</string>
<!-- Shown on transport control of lockscreen. Pressing button goes to next track. -->
- <string name="lockscreen_transport_next_description">Next track button</string>
+ <string name="lockscreen_transport_next_description">Next track</string>
<!-- Shown on transport control of lockscreen. Pressing button pauses playback -->
- <string name="lockscreen_transport_pause_description">Pause button</string>
+ <string name="lockscreen_transport_pause_description">Pause</string>
<!-- Shown on transport control of lockscreen. Pressing button pauses playback -->
- <string name="lockscreen_transport_play_description">Play button</string>
+ <string name="lockscreen_transport_play_description">Play</string>
<!-- Shown on transport control of lockscreen. Pressing button pauses playback -->
- <string name="lockscreen_transport_stop_description">Stop button</string>
+ <string name="lockscreen_transport_stop_description">Stop</string>
+ <!-- Shown on transport control screens. Pressing button rewinds playback [CHAR LIMIT=NONE]-->
+ <string name="lockscreen_transport_rew_description">Rewind</string>
+ <!-- Shown on transport control screens. Pressing button fast forwards playback [CHAR LIMIT=NONE]-->
+ <string name="lockscreen_transport_ffw_description">Fast forward</string>
<!-- Shown in the lock screen when there is emergency calls only mode. -->
<string name="emergency_calls_only" msgid="2485604591272668370">Emergency calls only</string>
<style name="MediaButton.Previous">
<item name="src">@drawable/ic_media_previous</item>
+ <item name="contentDescription">@string/lockscreen_transport_prev_description</item>
</style>
<style name="MediaButton.Next">
<item name="src">@drawable/ic_media_next</item>
+ <item name="contentDescription">@string/lockscreen_transport_next_description</item>
</style>
<style name="MediaButton.Play">
<item name="src">@drawable/ic_media_play</item>
+ <item name="contentDescription">@string/lockscreen_transport_play_description</item>
</style>
<style name="MediaButton.Ffwd">
<item name="src">@drawable/ic_media_ff</item>
+ <item name="contentDescription">@string/lockscreen_transport_ffw_description</item>
</style>
<style name="MediaButton.Rew">
<item name="src">@drawable/ic_media_rew</item>
+ <item name="contentDescription">@string/lockscreen_transport_rew_description</item>
</style>
<style name="MediaButton.Pause">
<item name="src">@drawable/ic_media_pause</item>
+ <item name="contentDescription">@string/lockscreen_transport_pause_description</item>
</style>
<style name="ZoomControls">