Generate tinted control buttons on-the-fly
@ -2,9 +2,9 @@
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:state_pressed="true"
|
||||
android:drawable="@drawable/next_normal" />
|
||||
android:drawable="@drawable/next" />
|
||||
<item
|
||||
android:state_focused="true"
|
||||
android:drawable="@drawable/next_normal" />
|
||||
android:drawable="@drawable/next" />
|
||||
<item android:drawable="@drawable/empty" />
|
||||
</selector>
|
@ -2,9 +2,9 @@
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:state_pressed="true"
|
||||
android:drawable="@drawable/pause_normal" />
|
||||
android:drawable="@drawable/pause" />
|
||||
<item
|
||||
android:state_focused="true"
|
||||
android:drawable="@drawable/pause_normal" />
|
||||
android:drawable="@drawable/pause" />
|
||||
<item android:drawable="@drawable/empty" />
|
||||
</selector>
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:state_pressed="true"
|
||||
android:drawable="@drawable/next_focused" />
|
||||
<item
|
||||
android:state_focused="true"
|
||||
android:drawable="@drawable/next_focused" />
|
||||
<item android:drawable="@drawable/next_normal" />
|
||||
</selector>
|
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1003 B After Width: | Height: | Size: 1003 B |
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:state_pressed="true"
|
||||
android:drawable="@drawable/pause_focused" />
|
||||
<item
|
||||
android:state_focused="true"
|
||||
android:drawable="@drawable/pause_focused" />
|
||||
<item android:drawable="@drawable/pause_normal" />
|
||||
</selector>
|
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:state_pressed="true"
|
||||
android:drawable="@drawable/play_focused" />
|
||||
<item
|
||||
android:state_focused="true"
|
||||
android:drawable="@drawable/play_focused" />
|
||||
<item android:drawable="@drawable/play_normal" />
|
||||
</selector>
|
Before Width: | Height: | Size: 910 B |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:state_pressed="true"
|
||||
android:drawable="@drawable/previous_focused" />
|
||||
<item
|
||||
android:state_focused="true"
|
||||
android:drawable="@drawable/previous_focused" />
|
||||
<item android:drawable="@drawable/previous_normal" />
|
||||
</selector>
|
Before Width: | Height: | Size: 1.8 KiB |
@ -1,25 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<ImageButton
|
||||
<org.kreed.vanilla.ControlButton
|
||||
android:id="@+id/previous"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginLeft="15px"
|
||||
android:background="@null"
|
||||
android:src="@drawable/previous" />
|
||||
<ImageButton
|
||||
<org.kreed.vanilla.ControlButton
|
||||
android:id="@+id/play_pause"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginLeft="25px"
|
||||
android:background="@null"
|
||||
android:src="@drawable/play" />
|
||||
<ImageButton
|
||||
<org.kreed.vanilla.ControlButton
|
||||
android:id="@+id/next"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginLeft="25px"
|
||||
android:layout_marginRight="15px"
|
||||
android:background="@null"
|
||||
android:src="@drawable/next" />
|
||||
</merge>
|
32
src/org/kreed/vanilla/ControlButton.java
Normal file
@ -0,0 +1,32 @@
|
||||
package org.kreed.vanilla;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
|
||||
public class ControlButton extends ImageView {
|
||||
private static final int ACTIVE_TINT = Color.argb(100, 0, 255, 0);
|
||||
private static final int INACTIVE_TINT = Color.TRANSPARENT;
|
||||
private int mTint = Color.TRANSPARENT;
|
||||
|
||||
public ControlButton(Context context, AttributeSet attrs)
|
||||
{
|
||||
super(context, attrs);
|
||||
|
||||
setFocusable(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawableStateChanged()
|
||||
{
|
||||
super.drawableStateChanged();
|
||||
|
||||
int tint = isPressed() || isFocused() ? ACTIVE_TINT : INACTIVE_TINT;
|
||||
if (tint != mTint) {
|
||||
setColorFilter(tint, PorterDuff.Mode.SRC_ATOP);
|
||||
mTint = tint;
|
||||
}
|
||||
}
|
||||
}
|
@ -40,7 +40,7 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.SeekBar;
|
||||
@ -55,9 +55,9 @@ public class NowPlayingActivity extends Activity implements ServiceConnection, V
|
||||
private View mControlsTop;
|
||||
private View mControlsBottom;
|
||||
|
||||
private ImageButton mPreviousButton;
|
||||
private ImageButton mPlayPauseButton;
|
||||
private ImageButton mNextButton;
|
||||
private View mPreviousButton;
|
||||
private ImageView mPlayPauseButton;
|
||||
private View mNextButton;
|
||||
private SeekBar mSeekBar;
|
||||
private TextView mSeekText;
|
||||
private Button mReconnectButton;
|
||||
@ -81,20 +81,20 @@ public class NowPlayingActivity extends Activity implements ServiceConnection, V
|
||||
mCoverView.setOnClickListener(this);
|
||||
|
||||
mLayout = (ViewGroup)mCoverView.getParent();
|
||||
|
||||
|
||||
mControlsTop = findViewById(R.id.controls_top);
|
||||
mControlsBottom = findViewById(R.id.controls_bottom);
|
||||
|
||||
mPreviousButton = (ImageButton)findViewById(R.id.previous);
|
||||
|
||||
mPreviousButton = findViewById(R.id.previous);
|
||||
mPreviousButton.setOnClickListener(this);
|
||||
mPreviousButton.setOnFocusChangeListener(this);
|
||||
mPlayPauseButton = (ImageButton)findViewById(R.id.play_pause);
|
||||
mPlayPauseButton = (ImageView)findViewById(R.id.play_pause);
|
||||
mPlayPauseButton.setOnClickListener(this);
|
||||
mPlayPauseButton.setOnFocusChangeListener(this);
|
||||
mNextButton = (ImageButton)findViewById(R.id.next);
|
||||
mNextButton = findViewById(R.id.next);
|
||||
mNextButton.setOnClickListener(this);
|
||||
mNextButton.setOnFocusChangeListener(this);
|
||||
|
||||
|
||||
mSeekText = (TextView)findViewById(R.id.seek_text);
|
||||
mSeekBar = (SeekBar)findViewById(R.id.seek_bar);
|
||||
mSeekBar.setMax(1000);
|
||||
|
@ -32,7 +32,7 @@ import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
|
||||
public class RemoteActivity extends Activity implements ServiceConnection, View.OnClickListener {
|
||||
private CoverView mCoverView;
|
||||
@ -40,7 +40,7 @@ public class RemoteActivity extends Activity implements ServiceConnection, View.
|
||||
private View mOpenButton;
|
||||
private View mKillButton;
|
||||
private View mPreviousButton;
|
||||
private ImageButton mPlayPauseButton;
|
||||
private ImageView mPlayPauseButton;
|
||||
private View mNextButton;
|
||||
|
||||
@Override
|
||||
@ -59,7 +59,7 @@ public class RemoteActivity extends Activity implements ServiceConnection, View.
|
||||
mKillButton.setOnClickListener(this);
|
||||
mPreviousButton = findViewById(R.id.previous);
|
||||
mPreviousButton.setOnClickListener(this);
|
||||
mPlayPauseButton = (ImageButton)findViewById(R.id.play_pause);
|
||||
mPlayPauseButton = (ImageView)findViewById(R.id.play_pause);
|
||||
mPlayPauseButton.setOnClickListener(this);
|
||||
mNextButton = findViewById(R.id.next);
|
||||
mNextButton.setOnClickListener(this);
|
||||
|