diff --git a/framework/framework.iml b/framework/framework.iml
index 4465d18..dad98d5 100644
--- a/framework/framework.iml
+++ b/framework/framework.iml
@@ -67,14 +67,6 @@
-
-
-
-
-
-
-
-
@@ -83,6 +75,14 @@
+
+
+
+
+
+
+
+
diff --git a/playmusicexporter/build.gradle b/playmusicexporter/build.gradle
index 6f685fa..94f04e1 100644
--- a/playmusicexporter/build.gradle
+++ b/playmusicexporter/build.gradle
@@ -32,6 +32,7 @@ android {
applicationId "re.jcg.playmusicexporter"
minSdkVersion 21
targetSdkVersion 25
+ // TODO Change Version with releases
versionCode 102
versionName '2.4.2'
vectorDrawables.useSupportLibrary = true
diff --git a/playmusicexporter/playmusicexporter.iml b/playmusicexporter/playmusicexporter.iml
index fc48e4c..9833dc1 100644
--- a/playmusicexporter/playmusicexporter.iml
+++ b/playmusicexporter/playmusicexporter.iml
@@ -66,14 +66,6 @@
-
-
-
-
-
-
-
-
@@ -82,6 +74,14 @@
+
+
+
+
+
+
+
+
diff --git a/playmusicexporter/src/main/java/re/jcg/playmusicexporter/services/ExportAllJob.java b/playmusicexporter/src/main/java/re/jcg/playmusicexporter/services/ExportAllJob.java
index abe15db..d5b0ffd 100644
--- a/playmusicexporter/src/main/java/re/jcg/playmusicexporter/services/ExportAllJob.java
+++ b/playmusicexporter/src/main/java/re/jcg/playmusicexporter/services/ExportAllJob.java
@@ -31,18 +31,14 @@ public class ExportAllJob extends JobService {
boolean lRequireCharging = lPreferences.getBoolean("settings", true);
JobScheduler lJobScheduler = (JobScheduler) pContext.getSystemService(JOB_SCHEDULER_SERVICE);
- if (lInterval == -1) {
- lJobScheduler.cancel(42);
- } else {
- ComponentName lComponentName = new ComponentName(pContext, ExportAllJob.class);
- JobInfo.Builder lBuilder = new JobInfo.Builder(42, lComponentName);
- lBuilder.setPeriodic(lInterval);
- lBuilder.setPersisted(true);
- if (lRequireUnmeteredNetwork)
- lBuilder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_UNMETERED);
- lBuilder.setRequiresCharging(lRequireCharging);
- lJobScheduler.schedule(lBuilder.build());
- }
+ ComponentName lComponentName = new ComponentName(pContext, ExportAllJob.class);
+ JobInfo.Builder lBuilder = new JobInfo.Builder(42, lComponentName);
+ lBuilder.setPeriodic(lInterval);
+ lBuilder.setPersisted(true);
+ if (lRequireUnmeteredNetwork)
+ lBuilder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_UNMETERED);
+ lBuilder.setRequiresCharging(lRequireCharging);
+ lJobScheduler.schedule(lBuilder.build());
}
@Override
diff --git a/playmusicexporter/src/main/java/re/jcg/playmusicexporter/services/ExportAllService.java b/playmusicexporter/src/main/java/re/jcg/playmusicexporter/services/ExportAllService.java
index 28794ff..ac72805 100644
--- a/playmusicexporter/src/main/java/re/jcg/playmusicexporter/services/ExportAllService.java
+++ b/playmusicexporter/src/main/java/re/jcg/playmusicexporter/services/ExportAllService.java
@@ -3,14 +3,13 @@ package re.jcg.playmusicexporter.services;
import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
-import android.content.SharedPreferences;
import android.net.Uri;
-import android.preference.PreferenceManager;
import android.support.v4.provider.DocumentFile;
import android.util.Log;
import java.util.List;
+import re.jcg.playmusicexporter.settings.PlayMusicExporterPreferences;
import re.jcg.playmusicexporter.utils.MusicPathBuilder;
import de.arcus.playmusiclib.PlayMusicManager;
import de.arcus.playmusiclib.datasources.AlbumDataSource;
@@ -50,7 +49,7 @@ public class ExportAllService extends IntentService {
}
private void export() {
- SharedPreferences lPreferences = PreferenceManager.getDefaultSharedPreferences(this);
+ PlayMusicExporterPreferences.init(this);
PlayMusicManager lPlayMusicManager = new PlayMusicManager(this);
try {
@@ -58,10 +57,9 @@ public class ExportAllService extends IntentService {
} catch (PlayMusicNotFoundException | NoSuperUserException | CouldNotOpenDatabaseException e) {
e.printStackTrace();
}
- String lStringUri = lPreferences.getString("preference_export_tree_uri", null);
- String lExportStructure = lPreferences.getString("preference_structure_alba", "{album-artist}/{album}/{disc=CD $}/{no=$$.} {title}.mp3");
- Log.i(TAG, lStringUri);
- Uri lUri = Uri.parse(lStringUri);
+ Uri lUri = PlayMusicExporterPreferences.getConditionedAutoExportPath();
+ String lExportStructure = PlayMusicExporterPreferences.getConditionedAutoExportStructure();
+ Log.i(TAG, lUri.toString());
AlbumDataSource lAlbumDataSource = new AlbumDataSource(lPlayMusicManager);
lAlbumDataSource.setOfflineOnly(true);
List lAlba = lAlbumDataSource.getAll();
diff --git a/playmusicexporter/src/main/java/re/jcg/playmusicexporter/settings/PlayMusicExporterPreferences.java b/playmusicexporter/src/main/java/re/jcg/playmusicexporter/settings/PlayMusicExporterPreferences.java
new file mode 100644
index 0000000..fe8cb0b
--- /dev/null
+++ b/playmusicexporter/src/main/java/re/jcg/playmusicexporter/settings/PlayMusicExporterPreferences.java
@@ -0,0 +1,79 @@
+package re.jcg.playmusicexporter.settings;
+
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.net.Uri;
+import android.preference.PreferenceManager;
+
+public class PlayMusicExporterPreferences {
+ private static SharedPreferences preferences;
+
+ private static final String AUTO_EXPORT_USES_DIFFERENT_PATH = "preference_auto_export_use_different_path";
+ private static final boolean AUTO_EXPORT_USES_DIFFERENT_PATH_DEFAULT = false;
+ private static final String AUTO_EXPORT_USES_DIFFERENT_STRUCTURE = "preference_auto_export_use_different_structure";
+ private static final boolean AUTO_EXPORT_USES_DIFFERENT_STRUCTURE_DEFAULT = false;
+
+ private static final String AUTO_EXPORT_PATH = "preference_auto_export_path";
+ //TODO Split Export Paths in export prefs, this won't work else.
+ private static final String ALBA_EXPORT_PATH = "preference_alba_export_path";
+ private static final String GROUP_EXPORT_PATH = "preference_group_export_path";
+ private static final String URI_DEFAULT = Uri.EMPTY.toString();
+
+ private static final String AUTO_EXPORT_STRUCTURE = "preference_auto_export_structure";
+ private static final String ALBA_EXPORT_STRUCTURE = "preference_auto_export_structure";
+ private static final String EXPORT_STRUCTURE_DEFAULT = "{album-artist}/{album}/{disc=CD $}/{no=$$.} {title}.mp3";
+
+
+ public static void init(Context pContext) {
+ preferences = PreferenceManager.getDefaultSharedPreferences(pContext);
+ }
+
+ public static Uri getConditionedAutoExportPath() {
+ if (getAutoExportUsesDifferentPath()) {
+ return getAutoExportPath();
+ } else {
+ return getAlbaExportPath();
+ }
+ }
+
+ public static boolean getAutoExportUsesDifferentPath() {
+ return preferences.getBoolean(AUTO_EXPORT_USES_DIFFERENT_PATH, AUTO_EXPORT_USES_DIFFERENT_PATH_DEFAULT);
+ }
+
+ public static Uri getAutoExportPath() {
+ return getUri(AUTO_EXPORT_PATH);
+ }
+
+ public static Uri getAlbaExportPath() {
+ return getUri(ALBA_EXPORT_PATH);
+ }
+
+ public static Uri getGroupExportPath() {
+ return getUri(GROUP_EXPORT_PATH);
+ }
+
+ private static Uri getUri(String key) {
+ return Uri.parse(preferences.getString(key, URI_DEFAULT));
+ }
+
+ public static String getConditionedAutoExportStructure() {
+ if (getAutoExportUsesDifferentStructure()) {
+ return getAutoExportStructure();
+ } else {
+ return getAlbaExportStructure();
+ }
+ }
+
+ public static String getAlbaExportStructure() {
+ return preferences.getString(ALBA_EXPORT_STRUCTURE, EXPORT_STRUCTURE_DEFAULT);
+ }
+
+ public static String getAutoExportStructure() {
+ return preferences.getString(AUTO_EXPORT_STRUCTURE, EXPORT_STRUCTURE_DEFAULT);
+ }
+
+ public static boolean getAutoExportUsesDifferentStructure() {
+ return preferences.getBoolean(AUTO_EXPORT_USES_DIFFERENT_STRUCTURE, AUTO_EXPORT_USES_DIFFERENT_STRUCTURE_DEFAULT);
+ }
+}
diff --git a/playmusicexporter/src/main/res/values/array.xml b/playmusicexporter/src/main/res/values/array.xml
index 727fcb8..c1bf411 100644
--- a/playmusicexporter/src/main/res/values/array.xml
+++ b/playmusicexporter/src/main/res/values/array.xml
@@ -6,7 +6,6 @@
- Every Day
- Every 2 Days
- Every Week
- - Never
- 2160000
@@ -14,7 +13,6 @@
- 86400000
- 172800000
- 604800000
- - -1
diff --git a/playmusicexporter/src/main/res/values/strings.xml b/playmusicexporter/src/main/res/values/strings.xml
index 5b7a770..de596d1 100644
--- a/playmusicexporter/src/main/res/values/strings.xml
+++ b/playmusicexporter/src/main/res/values/strings.xml
@@ -65,11 +65,25 @@
About me
Thanks to
About this version
+ Export conditions
+ Export path and subdirectory structure
Debug
+
Version Number
Build date
+ Enable automatic export
+ Require unmetered network?
+ Require charging?
+ Export interval
+ Use a different export path
+ Off means that the automatic export uses the same export path as alba.
+ Export path
+ Use a different subdirectory structure
+ Off means that the automatic export uses the same subdirectory structure as alba.
+ Subdirectory structure
+
Export Location
Export Base Path
Use / for a new folder \n Available Tags: \n - {album-artist} \n - {album} \n - {artist} \n - {title} \n - {disc=CD $} \n - {no=$$.} \n - {year} \n - {genre} \n
@@ -108,10 +122,14 @@
%d tracks selected
+
Export
Automation
About
+ Debug
+
{album-artist}/{album}/{disc=CD $}/{no=$$.} {title}.mp3
{group}/{group-no=$$.} {artist} - {title}.mp3
+
Trigger ExportAllService now
diff --git a/playmusicexporter/src/main/res/xml/pref_about.xml b/playmusicexporter/src/main/res/xml/pref_about.xml
index c3ce777..980a873 100644
--- a/playmusicexporter/src/main/res/xml/pref_about.xml
+++ b/playmusicexporter/src/main/res/xml/pref_about.xml
@@ -47,6 +47,7 @@
+
-
-
+
+
+
-
+ android:key="preference_auto_export_use_different_path"
+ android:summary="@string/settings_auto_export_different_path_switch_summary"
+ android:title="@string/settings_auto_export_different_path_switch" />
+
+
+
+
+
+ android:key="preference_auto_export_require_charging"
+ android:title="@string/settings_auto_export_require_charging_checkbox" />
-
+ android:key="preference_auto_export_require_unmetered"
+ android:title="@string/settings_auto_export_require_unmetered_checkbox" />
diff --git a/playmusicexporter/src/main/res/xml/pref_headers.xml b/playmusicexporter/src/main/res/xml/pref_headers.xml
index 3dc99ac..9866a60 100644
--- a/playmusicexporter/src/main/res/xml/pref_headers.xml
+++ b/playmusicexporter/src/main/res/xml/pref_headers.xml
@@ -19,6 +19,6 @@
+ android:title="@string/pref_header_debug" />
diff --git a/playmusiclib/playmusiclib.iml b/playmusiclib/playmusiclib.iml
index 11d5cb3..3b7fcb2 100644
--- a/playmusiclib/playmusiclib.iml
+++ b/playmusiclib/playmusiclib.iml
@@ -67,14 +67,6 @@
-
-
-
-
-
-
-
-
@@ -83,6 +75,14 @@
+
+
+
+
+
+
+
+