am 8e7cefa8: Merge "Add descriptions to MediaController buttons" into lmp-dev

* commit '8e7cefa86d7a54156511b5fb4128b92e8703174c':
  Add descriptions to MediaController buttons
This commit is contained in:
RoboErik
2014-08-07 23:20:12 +00:00
committed by Android Git Automerger
4 changed files with 59 additions and 37 deletions

View File

@@ -17,6 +17,7 @@
package android.widget;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.PixelFormat;
import android.media.AudioManager;
import android.os.Handler;
@@ -55,7 +56,7 @@ import java.util.Locale;
* <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>
@@ -70,32 +71,34 @@ import java.util.Locale;
*/
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);
@@ -132,7 +135,7 @@ public class MediaController extends FrameLayout {
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);
@@ -201,7 +204,7 @@ public class MediaController extends FrameLayout {
return false;
}
};
public void setMediaPlayer(MediaPlayerControl player) {
mPlayer = player;
updatePausePlay();
@@ -249,6 +252,11 @@ public class MediaController extends FrameLayout {
}
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();
@@ -271,7 +279,7 @@ public class MediaController extends FrameLayout {
}
}
// 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);
@@ -328,7 +336,7 @@ public class MediaController extends FrameLayout {
// the buttons.
}
}
/**
* Show the controller on screen. It will go away
* automatically after 'timeout' milliseconds of inactivity.
@@ -347,7 +355,7 @@ public class MediaController extends FrameLayout {
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.
@@ -359,7 +367,7 @@ public class MediaController extends FrameLayout {
mHandler.sendMessageDelayed(msg, timeout);
}
}
public boolean isShowing() {
return mShowing;
}
@@ -525,8 +533,10 @@ public class MediaController extends FrameLayout {
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);
}
}
@@ -668,7 +678,7 @@ public class MediaController extends FrameLayout {
if (mRoot != null) {
installPrevNextListeners();
if (mNextButton != null && !mFromXml) {
mNextButton.setVisibility(View.VISIBLE);
}

View File

@@ -2540,15 +2540,19 @@
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>

View File

@@ -1105,26 +1105,32 @@ please see styles_device_defaults.xml.
<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">

View File

@@ -976,6 +976,8 @@
<java-symbol type="string" name="ssl_ca_cert_noti_by_unknown" />
<java-symbol type="string" name="ssl_ca_cert_noti_managed" />
<java-symbol type="string" name="ssl_ca_cert_warning" />
<java-symbol type="string" name="lockscreen_transport_play_description" />
<java-symbol type="string" name="lockscreen_transport_pause_description" />
<java-symbol type="plurals" name="abbrev_in_num_days" />
<java-symbol type="plurals" name="abbrev_in_num_hours" />