aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml18
-rw-r--r--res/layout/edit_play_action.xml26
-rw-r--r--res/values/strings.xml4
-rw-r--r--src/github/daneren2005/dsub/activity/EditPlayActionActivity.java50
-rw-r--r--src/github/daneren2005/dsub/receiver/PlayActionReceiver.java38
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java1
-rw-r--r--src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java15
-rw-r--r--src/github/daneren2005/dsub/util/Constants.java2
8 files changed, 148 insertions, 6 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 97edccd1..3b3d7623 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -67,6 +67,16 @@
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable"/>
</activity>
+ <activity
+ android:name="github.daneren2005.dsub.activity.EditPlayActionActivity"
+ android:label="@string/tasker.start_playing"
+ android:icon="@drawable/launch">
+
+ <intent-filter>
+ <action android:name="com.twofortyfouram.locale.intent.action.EDIT_SETTING" />
+ </intent-filter>
+ </activity>
+
<service android:name=".service.DownloadService"
android:label="Subsonic Download Service"/>
<service android:name="github.daneren2005.dsub.service.sync.AuthenticatorService">
@@ -169,6 +179,14 @@
<meta-data android:name="android.appwidget.provider" android:resource="@xml/appwidget4x4"/>
</receiver>
+ <receiver
+ android:name="github.daneren2005.dsub.receiver.PlayActionReceiver">
+
+ <intent-filter>
+ <action android:name="com.twofortyfouram.locale.intent.action.FIRE_SETTING" />
+ </intent-filter>
+ </receiver>
+
<provider android:name="github.daneren2005.dsub.provider.DSubSearchProvider"
android:authorities="github.daneren2005.dsub.provider.DSubSearchProvider"/>
<provider android:name="github.daneren2005.dsub.provider.PlaylistStubProvider"
diff --git a/res/layout/edit_play_action.xml b/res/layout/edit_play_action.xml
new file mode 100644
index 00000000..6eb3b651
--- /dev/null
+++ b/res/layout/edit_play_action.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+
+ <TextView
+ android:id="@+id/edit_shuffle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="4dp"
+ android:textSize="20dp"
+ android:text="@string/tasker.edit_shuffle_mode" />
+ <CheckBox
+ android:id="@+id/edit_shuffle_checkbox"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:longClickable="true"
+ />
+ </LinearLayout>
+</LinearLayout> \ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f2d48d86..1de825ea 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -530,6 +530,10 @@
<string name="changelog_version_format" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">Version <xliff:g id="version_name">%s</xliff:g></string>
+ <string name="tasker.start_playing">Start playing DSub</string>
+ <string name="tasker.start_playing_title">Tasker -> Start Playing DSub</string>
+ <string name="tasker.edit_shuffle_mode">Start in shuffle mode: </string>
+
<plurals name="select_album_n_songs">
<item quantity="zero">No songs</item>
<item quantity="one">One song</item>
diff --git a/src/github/daneren2005/dsub/activity/EditPlayActionActivity.java b/src/github/daneren2005/dsub/activity/EditPlayActionActivity.java
new file mode 100644
index 00000000..3ae62f5f
--- /dev/null
+++ b/src/github/daneren2005/dsub/activity/EditPlayActionActivity.java
@@ -0,0 +1,50 @@
+/*
+ This file is part of Subsonic.
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+ Copyright 2014 (C) Scott Jackson
+*/
+
+package github.daneren2005.dsub.activity;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.CheckBox;
+
+import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.util.Constants;
+
+public class EditPlayActionActivity extends SubsonicActivity {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.edit_play_action);
+ }
+
+ private void accept() {
+ Intent intent = new Intent();
+ intent.putExtra("com.twofortyfouram.locale.intent.extra.BLURB", "Start DSub");
+
+ CheckBox checkBox = (CheckBox) findViewById(R.id.edit_shuffle_checkbox);
+
+ Bundle data = new Bundle();
+ data.putBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE, checkBox.isChecked());
+ intent.putExtra(Constants.TASKER_EXTRA_BUNDLE, data);
+
+ setResult(Activity.RESULT_OK);
+ finish();
+ }
+ private void cancel() {
+ setResult(Activity.RESULT_CANCELED);
+ finish();
+ }
+}
diff --git a/src/github/daneren2005/dsub/receiver/PlayActionReceiver.java b/src/github/daneren2005/dsub/receiver/PlayActionReceiver.java
new file mode 100644
index 00000000..a5f4f561
--- /dev/null
+++ b/src/github/daneren2005/dsub/receiver/PlayActionReceiver.java
@@ -0,0 +1,38 @@
+/*
+ This file is part of Subsonic.
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+ Copyright 2014 (C) Scott Jackson
+*/
+
+package github.daneren2005.dsub.receiver;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+
+import github.daneren2005.dsub.service.DownloadService;
+import github.daneren2005.dsub.util.Constants;
+
+public class PlayActionReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if(intent.hasExtra(Constants.TASKER_EXTRA_BUNDLE)) {
+ Bundle data = intent.getBundleExtra(Constants.TASKER_EXTRA_BUNDLE);
+ Boolean startShuffled = data.getBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE);
+
+ Intent start = new Intent(DownloadService.START_PLAY);
+ start.putExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE, startShuffled);
+ context.startService(start);
+ }
+ }
+}
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java
index f458379d..c4837260 100644
--- a/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/src/github/daneren2005/dsub/service/DownloadService.java
@@ -91,6 +91,7 @@ public class DownloadService extends Service {
public static final String CMD_PREVIOUS = "github.daneren2005.dsub.CMD_PREVIOUS";
public static final String CMD_NEXT = "github.daneren2005.dsub.CMD_NEXT";
public static final String CANCEL_DOWNLOADS = "github.daneren2005.dsub.CANCEL_DOWNLOADS";
+ public static final String START_PLAY = "github.daneren2005.dsub.START_PLAYING";
public static final int FAST_FORWARD = 30000;
public static final int REWIND = 10000;
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
index 18502846..04a2535c 100644
--- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
+++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
@@ -159,7 +159,15 @@ public class DownloadServiceLifecycleSupport {
public void onStart(Intent intent) {
if (intent != null) {
- if(intent.getExtras() != null) {
+ String action = intent.getAction();
+ if(DownloadService.START_PLAY.equals(action)) {
+ if(intent.getBooleanExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE, false)) {
+ downloadService.setShufflePlayEnabled(true);
+ }
+ downloadService.play();
+ } else if(DownloadService.CANCEL_DOWNLOADS.equals(action)) {
+ downloadService.clearBackground();
+ } else if(intent.getExtras() != null) {
final KeyEvent event = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT);
if (event != null) {
eventHandler.post(new Runnable() {
@@ -173,11 +181,6 @@ public class DownloadServiceLifecycleSupport {
}
});
}
- } else {
- String action = intent.getAction();
- if(DownloadService.CANCEL_DOWNLOADS.equals(action)) {
- downloadService.clearBackground();
- }
}
}
}
diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java
index f566c78c..0f9d78b9 100644
--- a/src/github/daneren2005/dsub/util/Constants.java
+++ b/src/github/daneren2005/dsub/util/Constants.java
@@ -174,6 +174,8 @@ public final class Constants {
public static final String SYNC_ACCOUNT_STARRED_AUTHORITY = "github.daneren2005.dsub.starred.provider";
public static final String SYNC_ACCOUNT_MOST_RECENT_AUTHORITY = "github.daneren2005.dsub.mostrecent.provider";
+ public static final String TASKER_EXTRA_BUNDLE = "com.twofortyfouram.locale.intent.extra.BUNDLE";
+
// Number of free trial days for non-licensed servers.
public static final int FREE_TRIAL_DAYS = 30;