Remove ControlButton

This commit is contained in:
Christopher Eby 2011-09-24 18:15:45 -05:00
parent 09135ac52d
commit 6be7e4d69e
31 changed files with 114 additions and 167 deletions

BIN
orig/previous_focused.svgz Normal file

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 815 B

After

Width:  |  Height:  |  Size: 815 B

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 588 B

After

Width:  |  Height:  |  Size: 588 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

6
res/drawable/next.xml Normal file
View File

@ -0,0 +1,6 @@
<?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>

View File

@ -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" />
</selector>

6
res/drawable/pause.xml Normal file
View File

@ -0,0 +1,6 @@
<?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>

View File

@ -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" />
</selector>

6
res/drawable/play.xml Normal file
View File

@ -0,0 +1,6 @@
<?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>

View File

@ -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" />
</selector>

View File

@ -0,0 +1,6 @@
<?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>

View File

@ -76,7 +76,7 @@ THE SOFTWARE.
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="1"
android:src="@drawable/play_multi"
android:src="@drawable/play"
android:padding="5dip"
android:background="#0000"
android:scaleType="fitCenter" />
@ -86,7 +86,7 @@ THE SOFTWARE.
android:layout_height="0px"
android:layout_weight="1"
android:padding="5dip"
android:src="@drawable/next_multi"
android:src="@drawable/next"
android:background="#0000"
android:scaleType="fitCenter" />
</LinearLayout>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2010 Christopher Eby <kreed@kreed.org>
Copyright (C) 2010, 2011 Christopher Eby <kreed@kreed.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -53,10 +53,34 @@ THE SOFTWARE.
<LinearLayout
android:id="@+id/controls_bottom"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:layout_width="fill_parent"
android:layout_gravity="bottom|left"
android:layout_margin="0dip"
android:background="#a000"
android:orientation="horizontal">
<include layout="@layout/playback_buttons" />
<ImageButton
android:id="@+id/previous"
android:layout_height="wrap_content"
android:layout_width="0px"
android:layout_weight="1"
android:background="@null"
android:scaleType="fitCenter"
android:src="@drawable/previous" />
<ImageButton
android:id="@+id/play_pause"
android:layout_height="wrap_content"
android:layout_width="0px"
android:layout_weight="1"
android:background="@null"
android:scaleType="fitCenter"
android:src="@drawable/play" />
<ImageButton
android:id="@+id/next"
android:layout_height="wrap_content"
android:layout_width="0px"
android:layout_weight="1"
android:background="@null"
android:scaleType="fitCenter"
android:src="@drawable/next" />
</LinearLayout>
</merge>

View File

@ -85,24 +85,29 @@ THE SOFTWARE.
android:layout_margin="0dip"
android:background="#a000"
android:orientation="horizontal">
<!-- TODO: maybe add library button here? -->
<org.kreed.vanilla.ControlButton
<ImageButton
android:id="@+id/previous"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_width="0px"
android:layout_weight="1"
android:background="@null"
android:scaleType="fitCenter"
android:src="@drawable/previous" />
<org.kreed.vanilla.ControlButton
<ImageButton
android:id="@+id/play_pause"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_width="0px"
android:layout_weight="1"
android:background="@null"
android:scaleType="fitCenter"
android:src="@drawable/play" />
<org.kreed.vanilla.ControlButton
<ImageButton
android:id="@+id/next"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_width="0px"
android:layout_weight="1"
android:background="@null"
android:scaleType="fitCenter"
android:src="@drawable/next" />
</LinearLayout>
</merge>

View File

@ -153,12 +153,13 @@ THE SOFTWARE.
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textFilter" />
<org.kreed.vanilla.ControlButton
<ImageButton
android:id="@+id/clear_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="@android:drawable/ic_menu_close_clear_cancel" />
android:background="@null"
android:src="@drawable/ic_menu_close_clear_cancel" />
</RelativeLayout>
</merge>

View File

@ -58,23 +58,29 @@ THE SOFTWARE.
android:layout_toRightOf="@id/cover"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true">
<org.kreed.vanilla.ControlButton
<ImageButton
android:id="@+id/previous"
android:layout_height="wrap_content"
android:layout_width="0px"
android:layout_weight="1"
android:background="@null"
android:scaleType="fitCenter"
android:src="@drawable/previous" />
<org.kreed.vanilla.ControlButton
<ImageButton
android:id="@+id/play_pause"
android:layout_height="wrap_content"
android:layout_width="0px"
android:layout_weight="1"
android:background="@null"
android:scaleType="fitCenter"
android:src="@drawable/play" />
<org.kreed.vanilla.ControlButton
<ImageButton
android:id="@+id/next"
android:layout_height="wrap_content"
android:layout_width="0px"
android:layout_weight="1"
android:background="@null"
android:scaleType="fitCenter"
android:src="@drawable/next" />
</LinearLayout>
</RelativeLayout>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2010 Christopher Eby <kreed@kreed.org>
Copyright (C) 2010, 2011 Christopher Eby <kreed@kreed.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -29,9 +29,32 @@ THE SOFTWARE.
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<include layout="@layout/playback_buttons" />
android:layout_width="wrap_content"
android:orientation="horizontal">
<ImageButton
android:id="@+id/previous"
android:layout_height="wrap_content"
android:layout_width="0px"
android:layout_weight="1"
android:background="@null"
android:scaleType="fitCenter"
android:src="@drawable/previous" />
<ImageButton
android:id="@+id/play_pause"
android:layout_height="wrap_content"
android:layout_width="0px"
android:layout_weight="1"
android:background="@null"
android:scaleType="fitCenter"
android:src="@drawable/play" />
<ImageButton
android:id="@+id/next"
android:layout_height="wrap_content"
android:layout_width="0px"
android:layout_weight="1"
android:background="@null"
android:scaleType="fitCenter"
android:src="@drawable/next" />
</LinearLayout>
</org.kreed.vanilla.MiniPlaybackActivityLayout>

View File

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2010 Christopher Eby <kreed@kreed.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<org.kreed.vanilla.ControlButton
android:id="@+id/previous"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="15px"
android:src="@drawable/previous" />
<org.kreed.vanilla.ControlButton
android:id="@+id/play_pause"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="25px"
android:src="@drawable/play" />
<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:src="@drawable/next" />
</merge>

View File

@ -1,67 +0,0 @@
/*
* Copyright (C) 2010 Christopher Eby <kreed@kreed.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.kreed.vanilla;
import android.content.Context;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.util.AttributeSet;
import android.widget.ImageView;
/**
* ControlButton is a simple extension of ImageView to make it clickable and
* focusable and provide a visual indication of when these states occur by
* tinting the image green.
*/
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;
/**
* Constructor intended to be called by inflating from XML.
*/
public ControlButton(Context context, AttributeSet attrs)
{
super(context, attrs);
setFocusable(true);
setClickable(true);
}
/**
* Change the tint of the view when the state changes to pressed or
* focused.
*/
@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;
}
}
}

View File

@ -112,7 +112,7 @@ public class FourLongWidget extends AppWidgetProvider {
}
boolean playing = (state & PlaybackService.FLAG_PLAYING) != 0;
views.setImageViewResource(R.id.play_pause, playing ? R.drawable.pause_multi : R.drawable.play_multi);
views.setImageViewResource(R.id.play_pause, playing ? R.drawable.pause : R.drawable.play);
Intent intent;
PendingIntent pendingIntent;

View File

@ -36,6 +36,7 @@ import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
@ -118,7 +119,7 @@ public class FullPlaybackActivity extends PlaybackActivity implements SeekBar.On
View previousButton = findViewById(R.id.previous);
previousButton.setOnClickListener(this);
mPlayPauseButton = (ControlButton)findViewById(R.id.play_pause);
mPlayPauseButton = (ImageButton)findViewById(R.id.play_pause);
mPlayPauseButton.setOnClickListener(this);
View nextButton = findViewById(R.id.next);
nextButton.setOnClickListener(this);

View File

@ -47,6 +47,7 @@ import android.view.SubMenu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
@ -121,7 +122,7 @@ public class LibraryActivity extends PlaybackActivity implements AdapterView.OnI
mStatusText = (TextView)mControls.findViewById(R.id.status_text);
mCover = (ImageView)mControls.findViewById(R.id.cover);
View previous = mControls.findViewById(R.id.previous);
mPlayPauseButton = (ControlButton)mControls.findViewById(R.id.play_pause);
mPlayPauseButton = (ImageButton)mControls.findViewById(R.id.play_pause);
View next = mControls.findViewById(R.id.next);
mCover.setOnClickListener(this);

View File

@ -26,6 +26,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.ImageButton;
/**
* Compact playback activity that displays itself like a dialog. That is, the
@ -48,7 +49,7 @@ public class MiniPlaybackActivity extends PlaybackActivity {
View previousButton = findViewById(R.id.previous);
previousButton.setOnClickListener(this);
mPlayPauseButton = (ControlButton)findViewById(R.id.play_pause);
mPlayPauseButton = (ImageButton)findViewById(R.id.play_pause);
mPlayPauseButton.setOnClickListener(this);
View nextButton = findViewById(R.id.next);
nextButton.setOnClickListener(this);

View File

@ -37,6 +37,7 @@ import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;
import android.widget.Toast;
public class PlaybackActivity extends Activity
@ -68,7 +69,7 @@ public class PlaybackActivity extends Activity
protected Looper mLooper;
protected CoverView mCoverView;
protected ControlButton mPlayPauseButton;
protected ImageButton mPlayPauseButton;
protected int mState;
private long mLastStateEvent;