aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml18
-rw-r--r--res/layout/edit_play_action.xml26
-rw-r--r--res/menu/tasker_configuration.xml16
-rw-r--r--res/values/strings.xml5
-rw-r--r--src/github/daneren2005/dsub/activity/EditPlayActionActivity.java87
-rw-r--r--src/github/daneren2005/dsub/receiver/PlayActionReceiver.java42
-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
9 files changed, 206 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/menu/tasker_configuration.xml b/res/menu/tasker_configuration.xml
new file mode 100644
index 00000000..07613640
--- /dev/null
+++ b/res/menu/tasker_configuration.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:compat="http://schemas.android.com/apk/res-auto">
+
+ <item
+ android:id="@+id/menu_cancel"
+ android:icon="?attr/remove"
+ android:title="@string/common.cancel"
+ compat:showAsAction="always|withText"/>
+
+ <item
+ android:id="@+id/menu_accept"
+ android:icon="?attr/save"
+ android:title="@string/common.ok"
+ compat:showAsAction="always|withText"/>
+</menu>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5adc09fd..1afeda49 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -534,6 +534,11 @@
<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_shuffled">Start playing DSub in Shuffle Mode</string>
+ <string name="tasker.start_playing_title">Tasker -> Start 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..b7f9de94
--- /dev/null
+++ b/src/github/daneren2005/dsub/activity/EditPlayActionActivity.java
@@ -0,0 +1,87 @@
+/*
+ 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.support.v4.widget.DrawerLayout;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.widget.CheckBox;
+
+import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.util.Constants;
+
+public class EditPlayActionActivity extends SubsonicActivity {
+ private CheckBox checkBox;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setTitle(R.string.tasker_start_playing_title);
+ setContentView(R.layout.edit_play_action);
+
+ checkBox = (CheckBox) findViewById(R.id.edit_shuffle_checkbox);
+ if(getIntent().getBundleExtra(Constants.TASKER_EXTRA_BUNDLE) != null && getIntent().getBundleExtra(Constants.TASKER_EXTRA_BUNDLE).getBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE)) {
+ checkBox.setChecked(true);
+ }
+
+ drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater menuInflater = getMenuInflater();
+ menuInflater.inflate(R.menu.tasker_configuration, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if(item.getItemId() == android.R.id.home) {
+ cancel();
+ return true;
+ } else if(item.getItemId() == R.id.menu_accept) {
+ accept();
+ return true;
+ } else if(item.getItemId() == R.id.menu_cancel) {
+ cancel();
+ return true;
+ }
+
+ return false;
+ }
+
+ private void accept() {
+ Intent intent = new Intent();
+
+ String blurb = getResources().getString(checkBox.isChecked() ? R.string.tasker_start_playing_shuffled : R.string.tasker_start_playing);
+ intent.putExtra("com.twofortyfouram.locale.intent.extra.BLURB", blurb);
+
+ Bundle data = new Bundle();
+ data.putBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE, checkBox.isChecked());
+ intent.putExtra(Constants.TASKER_EXTRA_BUNDLE, data);
+
+ setResult(Activity.RESULT_OK, intent);
+ 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..60814cc6
--- /dev/null
+++ b/src/github/daneren2005/dsub/receiver/PlayActionReceiver.java
@@ -0,0 +1,42 @@
+/*
+ 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 android.util.Log;
+
+import github.daneren2005.dsub.service.DownloadService;
+import github.daneren2005.dsub.util.Constants;
+
+public class PlayActionReceiver extends BroadcastReceiver {
+ private static final String TAG = PlayActionReceiver.class.getSimpleName();
+
+ @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(context, DownloadService.class);
+ start.setAction(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;