Add icons for fastforward and rewind buttons
PiperOrigin-RevId: 640206040
This commit is contained in:
parent
6dbf548253
commit
f3444aee5f
@ -61,6 +61,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
@ -211,6 +212,20 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
* <ul>
|
||||
* <li>Default: <b>{@code @drawable/exo_styled_controls_pause}</b>
|
||||
* </ul>
|
||||
* <li><b>{@code fastforward_icon}</b> - The drawable resource ID for the simple fast forward
|
||||
* button without the seek-forward amount. The ID of the {@linkplain ImageButton image button}
|
||||
* in such case should be {@code exo_ffwd}, specified in the {@code
|
||||
* exo_player_control_ffwd_button} layout.
|
||||
* <ul>
|
||||
* <li>Default: <b>{@code @drawable/exo_styled_controls_simple_fastforward}</b>
|
||||
* </ul>
|
||||
* <li><b>{@code rewind_icon}</b> - The drawable resource ID for the simple rewind button without
|
||||
* the seek-back amount. The ID of the {@linkplain ImageButton image button} in such case
|
||||
* should be {@code exo_rew}, specified in the {@code exo_player_control_rewind_button}
|
||||
* layout.
|
||||
* <ul>
|
||||
* <li>Default: <b>{@code @drawable/exo_styled_controls_simple_rewind}</b>
|
||||
* </ul>
|
||||
* <li><b>{@code previous_icon}</b> - The drawable resource ID for the previous button.
|
||||
* <ul>
|
||||
* <li>Default: <b>{@code @drawable/exo_styled_controls_previous}</b>
|
||||
@ -466,7 +481,9 @@ public class PlayerControlView extends FrameLayout {
|
||||
int playDrawableResId = R.drawable.exo_styled_controls_play;
|
||||
int pauseDrawableResId = R.drawable.exo_styled_controls_pause;
|
||||
int nextDrawableResId = R.drawable.exo_styled_controls_next;
|
||||
int fastForwardDrawableResId = R.drawable.exo_styled_controls_simple_fastforward;
|
||||
int previousDrawableResId = R.drawable.exo_styled_controls_previous;
|
||||
int rewindDrawableResId = R.drawable.exo_styled_controls_simple_rewind;
|
||||
int fullScreenExitDrawableResId = R.drawable.exo_styled_controls_fullscreen_exit;
|
||||
int fullScreenEnterDrawableResId = R.drawable.exo_styled_controls_fullscreen_enter;
|
||||
int repeatOffDrawableResId = R.drawable.exo_styled_controls_repeat_off;
|
||||
@ -506,8 +523,13 @@ public class PlayerControlView extends FrameLayout {
|
||||
a.getResourceId(R.styleable.PlayerControlView_pause_icon, pauseDrawableResId);
|
||||
nextDrawableResId =
|
||||
a.getResourceId(R.styleable.PlayerControlView_next_icon, nextDrawableResId);
|
||||
fastForwardDrawableResId =
|
||||
a.getResourceId(
|
||||
R.styleable.PlayerControlView_fastforward_icon, fastForwardDrawableResId);
|
||||
previousDrawableResId =
|
||||
a.getResourceId(R.styleable.PlayerControlView_previous_icon, previousDrawableResId);
|
||||
rewindDrawableResId =
|
||||
a.getResourceId(R.styleable.PlayerControlView_rewind_icon, rewindDrawableResId);
|
||||
fullScreenExitDrawableResId =
|
||||
a.getResourceId(
|
||||
R.styleable.PlayerControlView_fullscreen_exit_icon, fullScreenExitDrawableResId);
|
||||
@ -625,37 +647,57 @@ public class PlayerControlView extends FrameLayout {
|
||||
timeBar.addListener(componentListener);
|
||||
}
|
||||
|
||||
resources = context.getResources();
|
||||
playPauseButton = findViewById(R.id.exo_play_pause);
|
||||
if (playPauseButton != null) {
|
||||
playPauseButton.setOnClickListener(componentListener);
|
||||
}
|
||||
previousButton = findViewById(R.id.exo_prev);
|
||||
if (previousButton != null) {
|
||||
previousButton.setImageDrawable(
|
||||
getDrawable(context, context.getResources(), previousDrawableResId));
|
||||
previousButton.setImageDrawable(getDrawable(context, resources, previousDrawableResId));
|
||||
previousButton.setOnClickListener(componentListener);
|
||||
}
|
||||
nextButton = findViewById(R.id.exo_next);
|
||||
if (nextButton != null) {
|
||||
nextButton.setImageDrawable(getDrawable(context, context.getResources(), nextDrawableResId));
|
||||
nextButton.setImageDrawable(getDrawable(context, resources, nextDrawableResId));
|
||||
nextButton.setOnClickListener(componentListener);
|
||||
}
|
||||
Typeface typeface = ResourcesCompat.getFont(context, R.font.roboto_medium_numbers);
|
||||
View rewButton = findViewById(R.id.exo_rew);
|
||||
rewindButtonTextView = rewButton == null ? findViewById(R.id.exo_rew_with_amount) : null;
|
||||
if (rewindButtonTextView != null) {
|
||||
rewindButtonTextView.setTypeface(typeface);
|
||||
ImageView rewButton = findViewById(R.id.exo_rew);
|
||||
TextView rewButtonWithAmount = findViewById(R.id.exo_rew_with_amount);
|
||||
if (rewButton != null) {
|
||||
// For a simple rewind button without seek-back increment value
|
||||
rewButton.setImageDrawable(getDrawable(context, resources, rewindDrawableResId));
|
||||
rewindButton = rewButton;
|
||||
rewindButtonTextView = null;
|
||||
} else if (rewButtonWithAmount != null) {
|
||||
// For a circular rewind button with the amount in the middle
|
||||
rewButtonWithAmount.setTypeface(typeface);
|
||||
rewindButtonTextView = rewButtonWithAmount;
|
||||
rewindButton = rewindButtonTextView;
|
||||
} else {
|
||||
rewindButtonTextView = null;
|
||||
rewindButton = null;
|
||||
}
|
||||
rewindButton = rewButton == null ? rewindButtonTextView : rewButton;
|
||||
if (rewindButton != null) {
|
||||
rewindButton.setOnClickListener(componentListener);
|
||||
}
|
||||
View ffwdButton = findViewById(R.id.exo_ffwd);
|
||||
fastForwardButtonTextView = ffwdButton == null ? findViewById(R.id.exo_ffwd_with_amount) : null;
|
||||
if (fastForwardButtonTextView != null) {
|
||||
fastForwardButtonTextView.setTypeface(typeface);
|
||||
ImageView ffwdButton = findViewById(R.id.exo_ffwd);
|
||||
TextView ffwdButtonWithAmount = findViewById(R.id.exo_ffwd_with_amount);
|
||||
if (ffwdButton != null) {
|
||||
// For a simple fast forward button without seek-forward increment value
|
||||
ffwdButton.setImageDrawable(getDrawable(context, resources, fastForwardDrawableResId));
|
||||
fastForwardButton = ffwdButton;
|
||||
fastForwardButtonTextView = null;
|
||||
} else if (ffwdButtonWithAmount != null) {
|
||||
// For a circular fastforward button with the amount in the middle
|
||||
ffwdButtonWithAmount.setTypeface(typeface);
|
||||
fastForwardButtonTextView = ffwdButtonWithAmount;
|
||||
fastForwardButton = fastForwardButtonTextView;
|
||||
} else {
|
||||
fastForwardButtonTextView = null;
|
||||
fastForwardButton = null;
|
||||
}
|
||||
fastForwardButton = ffwdButton == null ? fastForwardButtonTextView : ffwdButton;
|
||||
if (fastForwardButton != null) {
|
||||
fastForwardButton.setOnClickListener(componentListener);
|
||||
}
|
||||
@ -668,7 +710,6 @@ public class PlayerControlView extends FrameLayout {
|
||||
shuffleButton.setOnClickListener(componentListener);
|
||||
}
|
||||
|
||||
resources = context.getResources();
|
||||
buttonAlphaEnabled =
|
||||
(float) resources.getInteger(R.integer.exo_media_button_opacity_percentage_enabled) / 100;
|
||||
buttonAlphaDisabled =
|
||||
@ -1133,7 +1174,7 @@ public class PlayerControlView extends FrameLayout {
|
||||
shouldShowPlayButton
|
||||
? R.string.exo_controls_play_description
|
||||
: R.string.exo_controls_pause_description;
|
||||
((ImageView) playPauseButton).setImageDrawable(drawable);
|
||||
playPauseButton.setImageDrawable(drawable);
|
||||
playPauseButton.setContentDescription(resources.getString(stringRes));
|
||||
|
||||
boolean enablePlayPause = shouldEnablePlayPauseButton();
|
||||
|
@ -71,7 +71,9 @@
|
||||
<attr name="fullscreen_enter_icon" format="reference"/>
|
||||
<attr name="show_timeout" format="integer"/>
|
||||
<attr name="show_rewind_button" format="boolean"/>
|
||||
<attr name="rewind_icon" format="reference"/>
|
||||
<attr name="show_fastforward_button" format="boolean"/>
|
||||
<attr name="fastforward_icon" format="reference"/>
|
||||
<attr name="show_previous_button" format="boolean"/>
|
||||
<attr name="previous_icon" format="reference"/>
|
||||
<attr name="show_next_button" format="boolean"/>
|
||||
@ -148,6 +150,8 @@
|
||||
<attr name="fullscreen_exit_icon"/>
|
||||
<attr name="next_icon"/>
|
||||
<attr name="previous_icon"/>
|
||||
<attr name="fastforward_icon"/>
|
||||
<attr name="rewind_icon"/>
|
||||
<!-- DefaultTimeBar attributes -->
|
||||
<attr name="bar_height"/>
|
||||
<attr name="bar_gravity"/>
|
||||
@ -203,7 +207,9 @@
|
||||
<attr name="repeat_one_icon"/>
|
||||
<attr name="repeat_all_icon"/>
|
||||
<attr name="show_rewind_button"/>
|
||||
<attr name="rewind_icon"/>
|
||||
<attr name="show_fastforward_button"/>
|
||||
<attr name="fastforward_icon"/>
|
||||
<attr name="show_previous_button"/>
|
||||
<attr name="previous_icon"/>
|
||||
<attr name="show_next_button"/>
|
||||
|
@ -43,7 +43,9 @@
|
||||
<drawable name="exo_styled_controls_next">@drawable/exo_ic_skip_next</drawable>
|
||||
<drawable name="exo_styled_controls_previous">@drawable/exo_ic_skip_previous</drawable>
|
||||
<drawable name="exo_styled_controls_fastforward">@drawable/exo_ic_forward</drawable>
|
||||
<drawable name="exo_styled_controls_simple_fastforward">@drawable/exo_icon_fastforward</drawable>
|
||||
<drawable name="exo_styled_controls_rewind">@drawable/exo_ic_rewind</drawable>
|
||||
<drawable name="exo_styled_controls_simple_rewind">@drawable/exo_icon_rewind</drawable>
|
||||
<drawable name="exo_styled_controls_repeat_all">@drawable/exo_icon_repeat_all</drawable>
|
||||
<drawable name="exo_styled_controls_repeat_off">@drawable/exo_icon_repeat_off</drawable>
|
||||
<drawable name="exo_styled_controls_repeat_one">@drawable/exo_icon_repeat_one</drawable>
|
||||
|
Loading…
x
Reference in New Issue
Block a user