2 * Copyright (C) 2012 Andrew Neal
3 * Copyright (C) 2014 The CyanogenMod Project
4 * Licensed under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with the
6 * License. You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
8 * or agreed to in writing, software distributed under the License is
9 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
10 * KIND, either express or implied. See the License for the specific language
11 * governing permissions and limitations under the License.
14 package com.cyanogenmod.eleven.widgets;
16 import android.content.Context;
17 import android.util.AttributeSet;
18 import android.view.View;
20 import com.cyanogenmod.eleven.MusicPlaybackService;
21 import com.cyanogenmod.eleven.R;
22 import com.cyanogenmod.eleven.utils.MusicUtils;
25 * @author Andrew Neal (andrewdneal@gmail.com)
27 public class ShuffleButton extends AudioButton {
28 public ShuffleButton(final Context context, final AttributeSet attrs) {
29 super(context, attrs);
33 public void onClick(final View v) {
34 MusicUtils.cycleShuffle();
38 /** Sets the correct drawable for the shuffle state. */
39 public void updateShuffleState() {
40 switch (MusicUtils.getShuffleMode()) {
41 case MusicPlaybackService.SHUFFLE_NORMAL:
42 setContentDescription(getResources().getString(R.string.accessibility_shuffle_all));
43 setAlpha(ACTIVE_ALPHA);
45 case MusicPlaybackService.SHUFFLE_AUTO:
46 setContentDescription(getResources().getString(R.string.accessibility_shuffle_all));
47 setAlpha(ACTIVE_ALPHA);
49 case MusicPlaybackService.SHUFFLE_NONE:
50 setContentDescription(getResources().getString(R.string.accessibility_shuffle));
51 setAlpha(INACTIVE_ALPHA);