aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-07-20 17:26:39 -0700
committerScott Jackson <daneren2005@gmail.com>2014-07-20 17:26:39 -0700
commit856e2829ea93294447bf47a215b8db2c24708142 (patch)
treea012fb0a988c7d2e6eef7875e78ec5d503fb4585 /src
parentc3afd24b4ee51c9bd9e2789dfe26c4d758d57809 (diff)
downloaddsub-856e2829ea93294447bf47a215b8db2c24708142.tar.gz
dsub-856e2829ea93294447bf47a215b8db2c24708142.tar.bz2
dsub-856e2829ea93294447bf47a215b8db2c24708142.zip
Start of basic Tasker plugin
Diffstat (limited to 'src')
-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
5 files changed, 100 insertions, 6 deletions
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;