OSDN Git Service

1e05e8199445c6b8c08bfcfba1772e2ad79fc4a7
[android-x86/packages-apps-Eleven.git] / src / org / lineageos / eleven / widgets / AudioButton.java
1 package com.cyanogenmod.eleven.widgets;
2
3 import android.content.Context;
4 import android.text.TextUtils;
5 import android.util.AttributeSet;
6 import android.view.View;
7 import android.view.View.OnClickListener;
8 import android.view.View.OnLongClickListener;
9 import android.widget.ImageButton;
10
11 import com.cyanogenmod.eleven.R;
12 import com.cyanogenmod.eleven.utils.ApolloUtils;
13
14 public abstract class AudioButton extends ImageButton implements OnClickListener, OnLongClickListener {
15     public static float ACTIVE_ALPHA = 1.0f;
16     public static float INACTIVE_ALPHA = 0.4f;
17
18     @SuppressWarnings("deprecation")
19     public AudioButton(final Context context, final AttributeSet attrs) {
20         super(context, attrs);
21         setPadding(0, 0, 0, 0);
22         setBackground(getResources().getDrawable(R.drawable.selectable_background));
23         // Control playback (cycle shuffle)
24         setOnClickListener(this);
25         // Show the cheat sheet
26         setOnLongClickListener(this);
27     }
28
29     @Override
30     public boolean onLongClick(final View view) {
31         if (TextUtils.isEmpty(view.getContentDescription())) {
32             return false;
33         } else {
34             ApolloUtils.showCheatSheet(view);
35             return true;
36         }
37     }
38 }