Make cover press/long-press actions configurable
Also don't update the swipe action preferences through the service. There's no reason to do that; I'm not sure why I was doing so before...
This commit is contained in:
parent
1088ea67ee
commit
ef924a80b9
@ -55,6 +55,7 @@ THE SOFTWARE.
|
||||
<item>Enqueue Current Artist</item>
|
||||
<item>Enqueue Current Genre</item>
|
||||
<item>Clear Queue</item>
|
||||
<item>Toggle Controls</item>
|
||||
</string-array>
|
||||
<string-array name="entry_values">
|
||||
<!-- Note: even if this was an integer-array, these would be converted
|
||||
@ -72,5 +73,6 @@ THE SOFTWARE.
|
||||
<item>9</item>
|
||||
<item>10</item>
|
||||
<item>11</item>
|
||||
<item>12</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
@ -138,6 +138,10 @@ THE SOFTWARE.
|
||||
<string name="swipe_up_action_summary">What to do when a swipe up gesture is performed</string>
|
||||
<string name="swipe_down_action_title">Swipe Down Action</string>
|
||||
<string name="swipe_down_action_summary">What to do when a swipe down gesture is performed</string>
|
||||
<string name="cover_press_action_title">Cover Tap Action</string>
|
||||
<string name="cover_press_action_summary">What to do when the cover is tapped</string>
|
||||
<string name="cover_longpress_action_title">Cover Long Press Action</string>
|
||||
<string name="cover_longpress_action_summary">What to do when the cover is long-pressed</string>
|
||||
<string name="disable_cover_art_title">Disable Cover Art</string>
|
||||
<string name="disable_cover_art_summary">Do not show cover art anywhere in the application</string>
|
||||
|
||||
|
@ -87,6 +87,20 @@ THE SOFTWARE.
|
||||
android:entries="@array/swipe_action_entries"
|
||||
android:entryValues="@array/entry_values"
|
||||
android:defaultValue="0" />
|
||||
<ListPreference
|
||||
android:key="cover_press_action"
|
||||
android:title="@string/cover_press_action_title"
|
||||
android:summary="@string/cover_press_action_summary"
|
||||
android:entries="@array/swipe_action_entries"
|
||||
android:entryValues="@array/entry_values"
|
||||
android:defaultValue="12" />
|
||||
<ListPreference
|
||||
android:key="cover_longpress_action"
|
||||
android:title="@string/cover_longpress_action_title"
|
||||
android:summary="@string/cover_longpress_action_summary"
|
||||
android:entries="@array/swipe_action_entries"
|
||||
android:entryValues="@array/entry_values"
|
||||
android:defaultValue="2" />
|
||||
<CheckBoxPreference
|
||||
android:key="disable_cover_art"
|
||||
android:title="@string/disable_cover_art_title"
|
||||
|
@ -41,7 +41,7 @@ import android.widget.RelativeLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class FullPlaybackActivity extends PlaybackActivity implements SeekBar.OnSeekBarChangeListener, View.OnLongClickListener {
|
||||
public class FullPlaybackActivity extends PlaybackActivity implements SeekBar.OnSeekBarChangeListener {
|
||||
public static final int DISPLAY_INFO_OVERLAP = 0;
|
||||
public static final int DISPLAY_INFO_BELOW = 1;
|
||||
public static final int DISPLAY_INFO_WIDGETS = 2;
|
||||
@ -353,28 +353,6 @@ public class FullPlaybackActivity extends PlaybackActivity implements SeekBar.On
|
||||
mHandler.sendMessage(mHandler.obtainMessage(MSG_SAVE_CONTROLS, hidden, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
switch (view.getId()) {
|
||||
case R.id.cover_view:
|
||||
toggleControls();
|
||||
break;
|
||||
default:
|
||||
super.onClick(view);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onLongClick(View view)
|
||||
{
|
||||
if (view.getId() == R.id.cover_view) {
|
||||
playPause();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the seekbar progress with the current song progress. This must be
|
||||
* called on the UI Handler.
|
||||
@ -421,4 +399,13 @@ public class FullPlaybackActivity extends PlaybackActivity implements SeekBar.On
|
||||
{
|
||||
mSeekBarTracking = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performAction(int action)
|
||||
{
|
||||
if (action == PlaybackActivity.ACTION_TOGGLE_CONTROLS)
|
||||
toggleControls();
|
||||
else
|
||||
super.performAction(action);
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ public class MiniPlaybackActivity extends PlaybackActivity {
|
||||
|
||||
mCoverView = (CoverView)findViewById(R.id.cover_view);
|
||||
mCoverView.setOnClickListener(this);
|
||||
mCoverView.setOnLongClickListener(this);
|
||||
mCoverView.setup(mLooper, this, CoverBitmap.STYLE_OVERLAPPING_BOX);
|
||||
|
||||
View previousButton = findViewById(R.id.previous);
|
||||
|
@ -39,7 +39,12 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class PlaybackActivity extends Activity implements Handler.Callback, View.OnClickListener, CoverView.Callback {
|
||||
public class PlaybackActivity extends Activity
|
||||
implements Handler.Callback,
|
||||
View.OnClickListener,
|
||||
View.OnLongClickListener,
|
||||
CoverView.Callback
|
||||
{
|
||||
public static final int ACTION_NOTHING = 0;
|
||||
public static final int ACTION_LIBRARY = 1;
|
||||
public static final int ACTION_PLAY_PAUSE = 2;
|
||||
@ -52,9 +57,12 @@ public class PlaybackActivity extends Activity implements Handler.Callback, View
|
||||
public static final int ACTION_ENQUEUE_ARTIST = 9;
|
||||
public static final int ACTION_ENQUEUE_GENRE = 10;
|
||||
public static final int ACTION_CLEAR_QUEUE = 11;
|
||||
public static final int ACTION_TOGGLE_CONTROLS = 12;
|
||||
|
||||
public static int mUpAction;
|
||||
public static int mDownAction;
|
||||
private int mUpAction;
|
||||
private int mDownAction;
|
||||
private int mCoverPressAction;
|
||||
private int mCoverLongPressAction;
|
||||
|
||||
protected Handler mHandler;
|
||||
protected Looper mLooper;
|
||||
@ -78,10 +86,6 @@ public class PlaybackActivity extends Activity implements Handler.Callback, View
|
||||
HandlerThread thread = new HandlerThread(getClass().getName());
|
||||
thread.start();
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
mUpAction = Integer.parseInt(prefs.getString("swipe_up_action", "0"));
|
||||
mDownAction = Integer.parseInt(prefs.getString("swipe_down_action", "0"));
|
||||
|
||||
mLooper = thread.getLooper();
|
||||
mHandler = new Handler(mLooper, this);
|
||||
}
|
||||
@ -103,6 +107,12 @@ public class PlaybackActivity extends Activity implements Handler.Callback, View
|
||||
onServiceReady();
|
||||
else
|
||||
startService(new Intent(this, PlaybackService.class));
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
mUpAction = Integer.parseInt(prefs.getString("swipe_up_action", "0"));
|
||||
mDownAction = Integer.parseInt(prefs.getString("swipe_down_action", "0"));
|
||||
mCoverPressAction = Integer.parseInt(prefs.getString("cover_press_action", "12"));
|
||||
mCoverLongPressAction = Integer.parseInt(prefs.getString("cover_longpress_action", "2"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -166,6 +176,7 @@ public class PlaybackActivity extends Activity implements Handler.Callback, View
|
||||
setState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
switch (view.getId()) {
|
||||
@ -178,9 +189,23 @@ public class PlaybackActivity extends Activity implements Handler.Callback, View
|
||||
case R.id.previous:
|
||||
previousSong();
|
||||
break;
|
||||
case R.id.cover_view:
|
||||
performAction(mCoverPressAction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View view)
|
||||
{
|
||||
if (view.getId() == R.id.cover_view) {
|
||||
performAction(mCoverLongPressAction);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the PlaybackService state has changed.
|
||||
*
|
||||
|
@ -372,10 +372,6 @@ public final class PlaybackService extends Service implements Handler.Callback,
|
||||
}
|
||||
} else if ("notification_inverted_color".equals(key)) {
|
||||
updateNotification();
|
||||
} else if ("swipe_up_action".equals(key)) {
|
||||
PlaybackActivity.mUpAction = Integer.parseInt(settings.getString(key, "0"));
|
||||
} else if ("swipe_down_action".equals(key)) {
|
||||
PlaybackActivity.mDownAction = Integer.parseInt(settings.getString(key, "0"));
|
||||
} else if ("headset_only".equals(key)) {
|
||||
mHeadsetOnly = settings.getBoolean(key, false);
|
||||
if (mHeadsetOnly && isSpeakerOn())
|
||||
|
Loading…
x
Reference in New Issue
Block a user