mirror of
https://github.com/playmusicexporter/playmusicexporter
synced 2024-05-15 11:46:42 +00:00
Merge branch 'release/v0.9.1'
This commit is contained in:
commit
73cdb73b34
|
@ -67,14 +67,6 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
|
||||
|
@ -83,6 +75,14 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
|
||||
|
|
|
@ -1,271 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 David Schulte
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package de.arcus.framework.settings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
|
||||
/**
|
||||
* Helper class to read and write app settings without to care about to open and close an editor
|
||||
*/
|
||||
public class AppSettings {
|
||||
/**
|
||||
* The default settings file
|
||||
*/
|
||||
public static final String DEFAULT_SETTINGS_FILENAME = "app_settings";
|
||||
|
||||
/**
|
||||
* The preferences
|
||||
*/
|
||||
private SharedPreferences mSharedPreferences;
|
||||
|
||||
/**
|
||||
* Creates a new instance of AppSettings that access to the default settings file
|
||||
* @param context Context of the app
|
||||
*/
|
||||
public AppSettings(Context context) {
|
||||
this(context, DEFAULT_SETTINGS_FILENAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of AppSettings that access to a specific settings file
|
||||
* @param context Context of the app
|
||||
*/
|
||||
public AppSettings(Context context, String settingsFilename) {
|
||||
mSharedPreferences = context.getSharedPreferences(settingsFilename, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a string from the settings
|
||||
* @param key Key of the setting
|
||||
* @param defValue Default value which is returned if the key doesn't exists
|
||||
* @return Value
|
||||
*/
|
||||
public String getString(String key, String defValue) {
|
||||
return mSharedPreferences.getString(key, defValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a boolean from the settings
|
||||
* @param key Key of the setting
|
||||
* @param defValue Default value which is returned if the key doesn't exists
|
||||
* @return Value
|
||||
*/
|
||||
public boolean getBoolean(String key, boolean defValue) {
|
||||
return mSharedPreferences.getBoolean(key, defValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a float from the settings
|
||||
* @param key Key of the setting
|
||||
* @param defValue Default value which is returned if the key doesn't exists
|
||||
* @return Value
|
||||
*/
|
||||
public float getFloat(String key, float defValue) {
|
||||
return mSharedPreferences.getFloat(key, defValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an int from the settings
|
||||
* @param key Key of the setting
|
||||
* @param defValue Default value which is returned if the key doesn't exists
|
||||
* @return Value
|
||||
*/
|
||||
public int getInt(String key, int defValue) {
|
||||
return mSharedPreferences.getInt(key, defValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a long from the settings
|
||||
* @param key Key of the setting
|
||||
* @param defValue Default value which is returned if the key doesn't exists
|
||||
* @return Value
|
||||
*/
|
||||
public long getLong(String key, long defValue) {
|
||||
return mSharedPreferences.getLong(key, defValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a uri from the settings
|
||||
* @param key Key of the setting
|
||||
* @param defValue Default value which is returned if the key doesn't exists
|
||||
* @return Value
|
||||
*/
|
||||
public Uri getUri(String key, Uri defValue) {
|
||||
if (mSharedPreferences.contains(key))
|
||||
return Uri.parse(mSharedPreferences.getString(key, ""));
|
||||
else return defValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an enum value from the settings
|
||||
* @param key Key of the setting
|
||||
* @param defValue Default value which is returned if the key doesn't exists
|
||||
* @param <E> The enum type
|
||||
* @return Value
|
||||
*/
|
||||
public <E extends Enum<E>> E getEnum(String key, E defValue) {
|
||||
String value = mSharedPreferences.getString(key, defValue.name());
|
||||
|
||||
// Null check
|
||||
if (value != null) {
|
||||
// Checks all enum values
|
||||
for (E constant : defValue.getDeclaringClass().getEnumConstants()) {
|
||||
if (value.equals(constant.name()))
|
||||
return constant;
|
||||
}
|
||||
}
|
||||
// Return default
|
||||
return defValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the settings contains a specific key
|
||||
* @param key Key of the setting
|
||||
* @return Returns whether the settings contains a specific key
|
||||
*/
|
||||
public boolean contains(String key) {
|
||||
return mSharedPreferences.contains(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an setting from the settings
|
||||
* @param key Key of the setting
|
||||
*/
|
||||
public void remove(String key) {
|
||||
// Opens the editor
|
||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||
|
||||
// Removes the key
|
||||
editor.remove(key);
|
||||
|
||||
// Commits the change
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a string to the settings
|
||||
* @param key Key of the setting
|
||||
* @param value Value
|
||||
*/
|
||||
public void setString(String key, String value) {
|
||||
// Opens the editor
|
||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||
|
||||
editor.putString(key, value);
|
||||
|
||||
// Commits the change
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a boolean to the settings
|
||||
* @param key Key of the setting
|
||||
* @param value Value
|
||||
*/
|
||||
public void setBoolean(String key, boolean value) {
|
||||
// Opens the editor
|
||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||
|
||||
editor.putBoolean(key, value);
|
||||
|
||||
// Commits the change
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a float to the settings
|
||||
* @param key Key of the setting
|
||||
* @param value Value
|
||||
*/
|
||||
public void setFloat(String key, float value) {
|
||||
// Opens the editor
|
||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||
|
||||
editor.putFloat(key, value);
|
||||
|
||||
// Commits the change
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves an int to the settings
|
||||
* @param key Key of the setting
|
||||
* @param value Value
|
||||
*/
|
||||
public void setInt(String key, int value) {
|
||||
// Opens the editor
|
||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||
|
||||
editor.putInt(key, value);
|
||||
|
||||
// Commits the change
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a long to the settings
|
||||
* @param key Key of the setting
|
||||
* @param value Value
|
||||
*/
|
||||
public void setLong(String key, long value) {
|
||||
// Opens the editor
|
||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||
|
||||
editor.putLong(key, value);
|
||||
|
||||
// Commits the change
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a uri to the settings
|
||||
* @param key Key of the setting
|
||||
* @param value Value
|
||||
*/
|
||||
public void setUri(String key, Uri value) {
|
||||
// Opens the editor
|
||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||
|
||||
editor.putString(key, value.toString());
|
||||
|
||||
// Commits the change
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves an enum value to the settings
|
||||
* @param key Key of the setting
|
||||
* @param value Value
|
||||
*/
|
||||
public <E extends Enum<E>> void setEnum(String key, E value) {
|
||||
// Opens the editor
|
||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||
|
||||
editor.putString(key, value.name());
|
||||
|
||||
// Commits the change
|
||||
editor.commit();
|
||||
}
|
||||
}
|
|
@ -32,8 +32,9 @@ android {
|
|||
applicationId "re.jcg.playmusicexporter"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 25
|
||||
versionCode 102
|
||||
versionName '2.4.2'
|
||||
// TODO Change Version with releases
|
||||
versionCode 103
|
||||
versionName '0.9.1'
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
buildTypes {
|
||||
|
|
|
@ -66,14 +66,6 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
|
||||
|
@ -82,6 +74,14 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
||||
|
|
|
@ -5,8 +5,6 @@ import android.annotation.TargetApi;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
@ -16,8 +14,6 @@ import android.preference.PreferenceActivity;
|
|||
import android.support.v7.app.ActionBar;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.preference.RingtonePreference;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.support.v4.app.NavUtils;
|
||||
|
@ -25,11 +21,10 @@ import android.support.v4.app.NavUtils;
|
|||
import re.jcg.playmusicexporter.BuildConfig;
|
||||
import re.jcg.playmusicexporter.R;
|
||||
import re.jcg.playmusicexporter.services.ExportAllService;
|
||||
import re.jcg.playmusicexporter.settings.PlayMusicExporterPreferences;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static android.os.Build.VERSION_CODES.LOLLIPOP;
|
||||
|
||||
/**
|
||||
* A {@link PreferenceActivity} that presents a set of application settings. On
|
||||
* handset devices, settings are presented as a single list. On tablets,
|
||||
|
@ -43,7 +38,8 @@ import static android.os.Build.VERSION_CODES.LOLLIPOP;
|
|||
*/
|
||||
public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
private static final String TAG = "MusicExporter_Settings";
|
||||
private static final int OPEN_DOCUMENT_TREE_REQUEST_CODE = 0;
|
||||
private static final int REQUEST_CODE_OPEN_DOCUMENT_TREE_ALBA_PATH = 0;
|
||||
private static final int REQUEST_CODE_OPEN_DOCUMENT_TREE_GROUPS_PATH = 1;
|
||||
/**
|
||||
* A preference value change listener that updates the preference's summary
|
||||
* to reflect its new value.
|
||||
|
@ -84,26 +80,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds a preference's summary to its value. More specifically, when the
|
||||
* preference's value is changed, its summary (line of text below the
|
||||
* preference title) is updated to reflect the value. The summary is also
|
||||
* immediately updated upon calling this method. The exact display format is
|
||||
* dependent on the type of preference.
|
||||
*
|
||||
* @see #sBindPreferenceSummaryToValueListener
|
||||
*/
|
||||
private static void bindPreferenceSummaryToValue(Preference preference) {
|
||||
// Set the listener to watch for value changes.
|
||||
preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
|
||||
|
||||
// Trigger the listener immediately with the preference's
|
||||
// current value.
|
||||
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
|
||||
PreferenceManager
|
||||
.getDefaultSharedPreferences(preference.getContext())
|
||||
.getString(preference.getKey(), ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -174,6 +150,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
}
|
||||
|
||||
public static class ExportPreferenceFragment extends PreferenceFragment {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -181,10 +158,17 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
setHasOptionsMenu(true);
|
||||
|
||||
|
||||
findPreference("preference_export_path").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
findPreference("preference_alba_export_path").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
startActivityForResult(new Intent("android.intent.action.OPEN_DOCUMENT_TREE"), OPEN_DOCUMENT_TREE_REQUEST_CODE);
|
||||
startActivityForResult(new Intent("android.intent.action.OPEN_DOCUMENT_TREE"), REQUEST_CODE_OPEN_DOCUMENT_TREE_ALBA_PATH);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
findPreference("preference_groups_export_path").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
startActivityForResult(new Intent("android.intent.action.OPEN_DOCUMENT_TREE"), REQUEST_CODE_OPEN_DOCUMENT_TREE_GROUPS_PATH);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -192,10 +176,21 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
|
||||
switch (requestCode) {
|
||||
case OPEN_DOCUMENT_TREE_REQUEST_CODE:
|
||||
case REQUEST_CODE_OPEN_DOCUMENT_TREE_ALBA_PATH:
|
||||
if (resultCode == RESULT_OK) {
|
||||
Uri treeUri = resultData.getData();
|
||||
PreferenceManager.getDefaultSharedPreferences(getActivity()).edit().putString("preference_export_tree_uri", treeUri.toString()).apply();
|
||||
PlayMusicExporterPreferences.init(getActivity());
|
||||
PlayMusicExporterPreferences.setAlbaExportPath(treeUri);
|
||||
getActivity().getContentResolver().takePersistableUriPermission(treeUri,
|
||||
Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
Log.i(TAG, "Selected " + treeUri.toString());
|
||||
}
|
||||
break;
|
||||
case REQUEST_CODE_OPEN_DOCUMENT_TREE_GROUPS_PATH:
|
||||
if (resultCode == RESULT_OK) {
|
||||
Uri treeUri = resultData.getData();
|
||||
PlayMusicExporterPreferences.init(getActivity());
|
||||
PlayMusicExporterPreferences.setGroupsExportPath(treeUri);
|
||||
getActivity().getContentResolver().takePersistableUriPermission(treeUri,
|
||||
Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
Log.i(TAG, "Selected " + treeUri.toString());
|
||||
|
|
|
@ -22,10 +22,8 @@
|
|||
|
||||
package re.jcg.playmusicexporter.fragments;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.TextUtils;
|
||||
|
@ -44,7 +42,7 @@ import re.jcg.playmusicexporter.activities.MusicTrackListActivity;
|
|||
import re.jcg.playmusicexporter.adapter.MusicTrackListAdapter;
|
||||
import re.jcg.playmusicexporter.items.SelectedTrack;
|
||||
import re.jcg.playmusicexporter.items.SelectedTrackList;
|
||||
import re.jcg.playmusicexporter.settings.PlayMusicExporterSettings;
|
||||
import re.jcg.playmusicexporter.settings.PlayMusicExporterPreferences;
|
||||
import re.jcg.playmusicexporter.utils.ArtworkViewLoader;
|
||||
import re.jcg.playmusicexporter.utils.MusicPathBuilder;
|
||||
import de.arcus.playmusiclib.PlayMusicManager;
|
||||
|
@ -113,7 +111,7 @@ public class MusicTrackListFragment extends Fragment {
|
|||
*/
|
||||
public void selectAll() {
|
||||
// Select all tracks
|
||||
for(int i = 0; i < mMusicTrackAdapter.getCount(); i++ ) {
|
||||
for (int i = 0; i < mMusicTrackAdapter.getCount(); i++) {
|
||||
MusicTrack musicTrack = mMusicTrackAdapter.getItem(i);
|
||||
|
||||
selectTrack(musicTrack, null, TrackSelectionState.Select);
|
||||
|
@ -127,7 +125,7 @@ public class MusicTrackListFragment extends Fragment {
|
|||
*/
|
||||
public void deselectAll() {
|
||||
// Deselect all tracks
|
||||
for(int i = 0; i < mMusicTrackAdapter.getCount(); i++ ) {
|
||||
for (int i = 0; i < mMusicTrackAdapter.getCount(); i++) {
|
||||
MusicTrack musicTrack = mMusicTrackAdapter.getItem(i);
|
||||
|
||||
selectTrack(musicTrack, null, TrackSelectionState.Deselect);
|
||||
|
@ -141,7 +139,7 @@ public class MusicTrackListFragment extends Fragment {
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (getArguments().containsKey(ARG_MUSIC_TRACK_LIST_ID)
|
||||
&& getArguments().containsKey(ARG_MUSIC_TRACK_LIST_TYPE)) {
|
||||
&& getArguments().containsKey(ARG_MUSIC_TRACK_LIST_TYPE)) {
|
||||
|
||||
// Loads the track list
|
||||
long id = getArguments().getLong(ARG_MUSIC_TRACK_LIST_ID);
|
||||
|
@ -162,7 +160,7 @@ public class MusicTrackListFragment extends Fragment {
|
|||
|
||||
// Show the dummy content as text in a TextView.
|
||||
if (mMusicTrackList != null) {
|
||||
mListView = (ListView)rootView.findViewById(R.id.list_music_track);
|
||||
mListView = (ListView) rootView.findViewById(R.id.list_music_track);
|
||||
mMusicTrackAdapter = new MusicTrackListAdapter(getActivity());
|
||||
|
||||
mMusicTrackAdapter.setShowArtworks(mMusicTrackList.getShowArtworkInTrack());
|
||||
|
@ -174,17 +172,17 @@ public class MusicTrackListFragment extends Fragment {
|
|||
ImageView imageView;
|
||||
|
||||
// Sets the artwork image
|
||||
imageView = (ImageView)headerView.findViewById(R.id.image_music_track_artwork);
|
||||
imageView = (ImageView) headerView.findViewById(R.id.image_music_track_artwork);
|
||||
|
||||
// Loads the artwork
|
||||
ArtworkViewLoader.loadImage(mMusicTrackList, imageView, R.drawable.cd_case);
|
||||
|
||||
// Sets the title
|
||||
textView = (TextView)headerView.findViewById(R.id.text_music_track_list_title);
|
||||
textView = (TextView) headerView.findViewById(R.id.text_music_track_list_title);
|
||||
textView.setText(mMusicTrackList.getTitle());
|
||||
|
||||
// Sets the description
|
||||
textView = (TextView)headerView.findViewById(R.id.text_music_track_list_description);
|
||||
textView = (TextView) headerView.findViewById(R.id.text_music_track_list_description);
|
||||
textView.setText(mMusicTrackList.getDescription());
|
||||
|
||||
mListView.addHeaderView(headerView);
|
||||
|
@ -212,12 +210,12 @@ public class MusicTrackListFragment extends Fragment {
|
|||
});
|
||||
|
||||
// The floating action button
|
||||
mFloatingButtonExport = (FloatingActionButton)rootView.findViewById(R.id.floating_button_export);
|
||||
mFloatingButtonExport = (FloatingActionButton) rootView.findViewById(R.id.floating_button_export);
|
||||
mFloatingButtonExport.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// Export all selected tracks
|
||||
for(SelectedTrack selectedTrack : SelectedTrackList.getInstance().getSelectedItems()) {
|
||||
for (SelectedTrack selectedTrack : SelectedTrackList.getInstance().getSelectedItems()) {
|
||||
selectedTrack.export(getActivity());
|
||||
}
|
||||
|
||||
|
@ -231,33 +229,37 @@ public class MusicTrackListFragment extends Fragment {
|
|||
return rootView;
|
||||
}
|
||||
|
||||
private enum TrackSelectionState { Deselect, Select, Toggle }
|
||||
private enum TrackSelectionState {Deselect, Select, Toggle}
|
||||
|
||||
/**
|
||||
* Select a track
|
||||
*
|
||||
* @param musicTrack The track
|
||||
* @param view The view
|
||||
* @param state Selection state
|
||||
* @param view The view
|
||||
* @param state Selection state
|
||||
*/
|
||||
private void selectTrack(MusicTrack musicTrack, View view, TrackSelectionState state) {
|
||||
// Track is available
|
||||
if (musicTrack.isOfflineAvailable()) {
|
||||
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
PlayMusicExporterPreferences.init(getContext());
|
||||
|
||||
// Default structure
|
||||
String pathStructure = preferences.getString("preference_structure_alba", "{album-artist}/{album}/{disc=CD $}/{no=$$.} {title}.mp3");
|
||||
//Creating Variables
|
||||
String pathStructure;
|
||||
Uri uri;
|
||||
|
||||
// Track is exported from a group (playlist or artist)
|
||||
if (!TextUtils.isEmpty(musicTrack.getContainerName())) {
|
||||
pathStructure = preferences.getString("preference_structure_groups", "{group}/{group-no=$$.} {artist} - {title}.mp3");
|
||||
if (TextUtils.isEmpty(musicTrack.getContainerName())) {
|
||||
pathStructure = PlayMusicExporterPreferences.getAlbaExportStructure();
|
||||
uri = PlayMusicExporterPreferences.getAlbaExportPath();
|
||||
} else {
|
||||
pathStructure = PlayMusicExporterPreferences.getGroupsExportStructure();
|
||||
uri = PlayMusicExporterPreferences.getGroupsExportPath();
|
||||
}
|
||||
|
||||
// Build the path
|
||||
String path = MusicPathBuilder.Build(musicTrack, pathStructure);
|
||||
|
||||
// Gets the root uri
|
||||
Uri uri = Uri.parse(preferences.getString("preference_export_tree_uri", Uri.EMPTY.toString()));
|
||||
|
||||
|
||||
// Prevent the closing
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
package re.jcg.playmusicexporter.fragments;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.PorterDuff;
|
||||
|
@ -44,7 +45,7 @@ import android.widget.Button;
|
|||
|
||||
import re.jcg.playmusicexporter.R;
|
||||
import re.jcg.playmusicexporter.activities.SettingsActivity;
|
||||
import re.jcg.playmusicexporter.settings.PlayMusicExporterSettings;
|
||||
import re.jcg.playmusicexporter.settings.PlayMusicExporterPreferences;
|
||||
|
||||
/**
|
||||
* Fragment used for managing interactions for and presentation of a navigation drawer.
|
||||
|
@ -74,7 +75,15 @@ public class NavigationDrawerFragment extends Fragment {
|
|||
private Button mButtonSettings;
|
||||
|
||||
public enum ViewType {
|
||||
Album, Artist, Playlist, Rated
|
||||
Album, Artist, Playlist, Rated;
|
||||
|
||||
public static ViewType fromName(String name) {
|
||||
for (ViewType type : values()) {
|
||||
if (type.name().equals(name)) return type;
|
||||
}
|
||||
return Album;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private ViewType mViewType;
|
||||
|
@ -103,8 +112,8 @@ public class NavigationDrawerFragment extends Fragment {
|
|||
mViewType = viewType;
|
||||
|
||||
// Save the selection
|
||||
PlayMusicExporterSettings appSettings = new PlayMusicExporterSettings(getActivity());
|
||||
appSettings.setEnum(PlayMusicExporterSettings.PREF_DRAWER_SELECTED_TYPE, viewType);
|
||||
PlayMusicExporterPreferences.init(getContext());
|
||||
PlayMusicExporterPreferences.setDrawerViewType(viewType);
|
||||
|
||||
// Close the drawer
|
||||
if (mDrawerLayout != null)
|
||||
|
@ -119,9 +128,9 @@ public class NavigationDrawerFragment extends Fragment {
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Load the settings
|
||||
PlayMusicExporterSettings appSettings = new PlayMusicExporterSettings(getActivity());
|
||||
mUserLearnedDrawer = appSettings.getBoolean(PlayMusicExporterSettings.PREF_DRAWER_LEARNED, false);
|
||||
mViewType = appSettings.getEnum(PlayMusicExporterSettings.PREF_DRAWER_SELECTED_TYPE, ViewType.Album);
|
||||
PlayMusicExporterPreferences.init(getContext());
|
||||
mUserLearnedDrawer = PlayMusicExporterPreferences.getDrawerLearned();
|
||||
mViewType = PlayMusicExporterPreferences.getDrawerViewType();
|
||||
|
||||
|
||||
}
|
||||
|
@ -140,12 +149,12 @@ public class NavigationDrawerFragment extends Fragment {
|
|||
R.layout.fragment_navigation_drawer, container, false);
|
||||
|
||||
// Gets all buttons
|
||||
mButtonTypeAlbum = (Button)view.findViewById(R.id.button_type_album);
|
||||
mButtonTypeArtist = (Button)view.findViewById(R.id.button_type_artist);
|
||||
mButtonTypePlaylist = (Button)view.findViewById(R.id.button_type_playlist);
|
||||
mButtonTypeRated = (Button)view.findViewById(R.id.button_type_rated);
|
||||
mButtonTypeAlbum = (Button) view.findViewById(R.id.button_type_album);
|
||||
mButtonTypeArtist = (Button) view.findViewById(R.id.button_type_artist);
|
||||
mButtonTypePlaylist = (Button) view.findViewById(R.id.button_type_playlist);
|
||||
mButtonTypeRated = (Button) view.findViewById(R.id.button_type_rated);
|
||||
|
||||
mButtonSettings = (Button)view.findViewById(R.id.button_setting);
|
||||
mButtonSettings = (Button) view.findViewById(R.id.button_setting);
|
||||
|
||||
// Set the default
|
||||
setViewType(mViewType);
|
||||
|
@ -202,6 +211,7 @@ public class NavigationDrawerFragment extends Fragment {
|
|||
|
||||
/**
|
||||
* Format the button
|
||||
*
|
||||
* @param button The button
|
||||
* @param active Active
|
||||
*/
|
||||
|
@ -282,8 +292,8 @@ public class NavigationDrawerFragment extends Fragment {
|
|||
// The user manually opened the drawer; store this flag to prevent auto-showing
|
||||
// the navigation drawer automatically in the future.
|
||||
mUserLearnedDrawer = true;
|
||||
PlayMusicExporterSettings appSettings = new PlayMusicExporterSettings(getActivity());
|
||||
appSettings.setBoolean(PlayMusicExporterSettings.PREF_DRAWER_LEARNED, mUserLearnedDrawer);
|
||||
PlayMusicExporterPreferences.init(getContext());
|
||||
PlayMusicExporterPreferences.setDrawerLearned(mUserLearnedDrawer);
|
||||
}
|
||||
|
||||
getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
|
||||
|
@ -308,10 +318,10 @@ public class NavigationDrawerFragment extends Fragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
try {
|
||||
mCallbacks = (NavigationDrawerCallbacks) activity;
|
||||
mCallbacks = (NavigationDrawerCallbacks) context;
|
||||
} catch (ClassCastException e) {
|
||||
throw new ClassCastException("Activity must implement NavigationDrawerCallbacks.");
|
||||
}
|
||||
|
|
|
@ -7,33 +7,31 @@ import android.app.job.JobService;
|
|||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.util.Log;
|
||||
|
||||
import re.jcg.playmusicexporter.settings.PlayMusicExporterPreferences;
|
||||
|
||||
public class ExportAllJob extends JobService {
|
||||
public static final String TAG = "AutoGPME_ExportJob";
|
||||
|
||||
|
||||
public static void scheduleExport(final Context pContext) {
|
||||
SharedPreferences lPreferences = PreferenceManager.getDefaultSharedPreferences(pContext);
|
||||
lPreferences.registerOnSharedPreferenceChangeListener(new SharedPreferences.OnSharedPreferenceChangeListener() {
|
||||
PlayMusicExporterPreferences.init(pContext);
|
||||
PlayMusicExporterPreferences.registerOnSharedPreferenceChangeListener(new SharedPreferences.OnSharedPreferenceChangeListener() {
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
scheduleExport(pContext);
|
||||
Log.i(TAG, "Preference changed: " + key);
|
||||
if (key.contains("auto")) {
|
||||
scheduleExport(pContext);
|
||||
Log.i(TAG, "Preference changed: " + key);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (PlayMusicExporterPreferences.getAutoExportEnabled()) {
|
||||
long lInterval = PlayMusicExporterPreferences.getAutoExportFrequency();
|
||||
boolean lRequireUnmeteredNetwork = PlayMusicExporterPreferences.getAutoExportRequireUnmetered();
|
||||
boolean lRequireCharging = PlayMusicExporterPreferences.getAutoExportRequireCharging();
|
||||
|
||||
long lInterval = Long.parseLong(lPreferences.getString("settings_export_frequency", "86400000"));
|
||||
boolean lRequireUnmeteredNetwork = lPreferences.getBoolean("settings_export_", false);
|
||||
boolean lRequireCharging = lPreferences.getBoolean("settings", true);
|
||||
|
||||
JobScheduler lJobScheduler = (JobScheduler) pContext.getSystemService(JOB_SCHEDULER_SERVICE);
|
||||
if (lInterval == -1) {
|
||||
lJobScheduler.cancel(42);
|
||||
} else {
|
||||
JobScheduler lJobScheduler = (JobScheduler) pContext.getSystemService(JOB_SCHEDULER_SERVICE);
|
||||
ComponentName lComponentName = new ComponentName(pContext, ExportAllJob.class);
|
||||
JobInfo.Builder lBuilder = new JobInfo.Builder(42, lComponentName);
|
||||
lBuilder.setPeriodic(lInterval);
|
||||
|
|
|
@ -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<Album> lAlba = lAlbumDataSource.getAll();
|
||||
|
|
|
@ -0,0 +1,144 @@
|
|||
package re.jcg.playmusicexporter.settings;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import re.jcg.playmusicexporter.fragments.NavigationDrawerFragment;
|
||||
|
||||
public class PlayMusicExporterPreferences {
|
||||
private static SharedPreferences preferences;
|
||||
|
||||
private static final String AUTO_EXPORT_ENABLED = "preference_auto_export_enabled";
|
||||
private static final boolean AUTO_EXPORT_ENABLED_DEFAULT = false;
|
||||
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_FREQUENCY = "preference_auto_export_frequency";
|
||||
private static final String AUTO_EXPORT_FREQUENCY_DEFAULT = "86400000";
|
||||
public static final String AUTO_EXPORT_REQUIRE_CHARGING = "preference_auto_export_require_charging";
|
||||
public static final String AUTO_EXPORT_REQUIRE_UNMETERED = "preference_auto_export_require_unmetered";
|
||||
public static final boolean AUTO_EXPORT_REQUIRE_CONDITION_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 GROUPS_EXPORT_PATH = "preference_groups_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_alba_export_structure";
|
||||
private static final String GROUPS_EXPORT_STRUCTURE = "preference_groups_export_structure";
|
||||
private static final String EXPORT_STRUCTURE_DEFAULT = "{album-artist}/{album}/{disc=CD $}/{no=$$.} {title}.mp3";
|
||||
|
||||
private static final String DRAWER_LEARNED = "pref_drawer_learned";
|
||||
private static final boolean DRAWER_LEARNED_DEFAULT = false;
|
||||
private static final String DRAWER_SELECTED_TYPE = "pref_drawer_selected_type";
|
||||
private static final String DRAWER_SELECTED_TYPE_DEFAULT = "Album";
|
||||
|
||||
|
||||
private PlayMusicExporterPreferences() {
|
||||
}
|
||||
|
||||
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 getGroupsExportPath() {
|
||||
return getUri(GROUPS_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 getGroupsExportStructure() {
|
||||
return preferences.getString(GROUPS_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);
|
||||
}
|
||||
|
||||
public static boolean getDrawerLearned() {
|
||||
return preferences.getBoolean(DRAWER_LEARNED, DRAWER_LEARNED_DEFAULT);
|
||||
}
|
||||
public static void setDrawerLearned(boolean drawerLearned) {
|
||||
preferences.edit().putBoolean(DRAWER_LEARNED, drawerLearned).apply();
|
||||
}
|
||||
|
||||
public static NavigationDrawerFragment.ViewType getDrawerViewType() {
|
||||
return NavigationDrawerFragment.ViewType.fromName(preferences.getString(DRAWER_SELECTED_TYPE, DRAWER_SELECTED_TYPE_DEFAULT));
|
||||
}
|
||||
|
||||
public static void setDrawerViewType(NavigationDrawerFragment.ViewType viewType) {
|
||||
preferences.edit().putString(DRAWER_SELECTED_TYPE, viewType.name()).apply();
|
||||
}
|
||||
|
||||
public static void setAlbaExportPath(Uri treeUri) {
|
||||
preferences.edit().putString(ALBA_EXPORT_PATH, treeUri.toString()).apply();
|
||||
}
|
||||
|
||||
public static void setGroupsExportPath(Uri treeUri) {
|
||||
preferences.edit().putString(GROUPS_EXPORT_PATH, treeUri.toString()).apply();
|
||||
}
|
||||
|
||||
public static boolean getAutoExportEnabled() {
|
||||
return preferences.getBoolean(AUTO_EXPORT_ENABLED, AUTO_EXPORT_ENABLED_DEFAULT);
|
||||
}
|
||||
|
||||
public static void registerOnSharedPreferenceChangeListener(SharedPreferences.OnSharedPreferenceChangeListener sharedPreferenceChangeListener) {
|
||||
preferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
|
||||
}
|
||||
|
||||
public static long getAutoExportFrequency() {
|
||||
return Long.parseLong(preferences.getString(AUTO_EXPORT_FREQUENCY, AUTO_EXPORT_FREQUENCY_DEFAULT));
|
||||
}
|
||||
|
||||
public static boolean getAutoExportRequireUnmetered() {
|
||||
return preferences.getBoolean(AUTO_EXPORT_REQUIRE_UNMETERED, AUTO_EXPORT_REQUIRE_CONDITION_DEFAULT);
|
||||
}
|
||||
|
||||
public static boolean getAutoExportRequireCharging() {
|
||||
return preferences.getBoolean(AUTO_EXPORT_REQUIRE_CHARGING, AUTO_EXPORT_REQUIRE_CONDITION_DEFAULT);
|
||||
}
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 David Schulte
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package re.jcg.playmusicexporter.settings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
|
||||
import de.arcus.framework.settings.AppSettings;
|
||||
import re.jcg.playmusicexporter.R;
|
||||
|
||||
/**
|
||||
* Helper class to read and write app settings without to care about to open and close an editor
|
||||
*/
|
||||
public class PlayMusicExporterSettings extends AppSettings {
|
||||
private static PlayMusicExporterSettings settings;
|
||||
/**
|
||||
* The default settings file
|
||||
*/
|
||||
public static final String DEFAULT_SETTINGS_FILENAME = "play_music_exporter";
|
||||
|
||||
// Preference constants
|
||||
private static final String PREF_ID3 = "pref_id3";
|
||||
private static final String PREF_ID3_ARTWORK_SIZE = "pref_id3_artwork_size";
|
||||
public static final String PREF_EXPORT_URI = "pref_export_uri";
|
||||
private static final String PREF_STRUCTURE_ALBA = "pref_structure_albua";
|
||||
private static final String PREF_STRUCTURE_GROUPS = "pref_structure_groups";
|
||||
public static final String PREF_DRAWER_LEARNED = "pref_drawer_learned";
|
||||
public static final String PREF_DRAWER_SELECTED_TYPE = "pref_drawer_selected_type";
|
||||
|
||||
public PlayMusicExporterSettings(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new instance of PlayMusicExporterSettings that access to the default settings file
|
||||
* @param context Context of the app
|
||||
*/
|
||||
public static void init(Context context) {
|
||||
settings = new PlayMusicExporterSettings(context);
|
||||
|
||||
// Init the default values
|
||||
|
||||
// ID3 settings
|
||||
if (!settings.contains(PREF_ID3))
|
||||
settings.setString(PREF_ID3, "id3_with_cover");
|
||||
|
||||
// ID3 artwork settings
|
||||
if (!settings.contains(PREF_ID3_ARTWORK_SIZE))
|
||||
settings.setInt(PREF_ID3_ARTWORK_SIZE, 1024);
|
||||
|
||||
// Export path
|
||||
if (!settings.contains(PREF_EXPORT_URI))
|
||||
settings.setUri(PREF_EXPORT_URI, Uri.fromFile(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC)));
|
||||
|
||||
// Alba export structure
|
||||
if (!settings.contains(PREF_STRUCTURE_ALBA))
|
||||
settings.setString(PREF_STRUCTURE_ALBA, context.getString(R.string.settings_export_structure_alba_default_value));
|
||||
|
||||
// Groups export structure
|
||||
if (!settings.contains(PREF_STRUCTURE_GROUPS))
|
||||
settings.setString(PREF_STRUCTURE_GROUPS, context.getString(R.string.settings_export_structure_groups_default_value));
|
||||
|
||||
// Drawer learned
|
||||
if (!settings.contains(PREF_DRAWER_LEARNED))
|
||||
settings.setBoolean(PREF_DRAWER_LEARNED, false);
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -6,7 +6,6 @@
|
|||
<item>Every Day</item>
|
||||
<item>Every 2 Days</item>
|
||||
<item>Every Week</item>
|
||||
<item>Never</item>
|
||||
</string-array>
|
||||
<string-array name="settings_export_frequency_values" translatable="false">
|
||||
<item>2160000</item>
|
||||
|
@ -14,7 +13,6 @@
|
|||
<item>86400000</item>
|
||||
<item>172800000</item>
|
||||
<item>604800000</item>
|
||||
<item>-1</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="settings_export_id3_artwork_size_value_names" translatable="false">
|
||||
|
|
|
@ -65,19 +65,38 @@
|
|||
<string name="settings_category_about_me">About me</string>
|
||||
<string name="settings_category_thanks">Thanks to</string>
|
||||
<string name="settings_category_develop">About this version</string>
|
||||
<string name="settings_category_auto_export_conditions">Export conditions</string>
|
||||
<string name="settings_category_auto_export_path_subdir">Export path and subdirectory structure</string>
|
||||
<string name="settings_category_debug">Debug</string>
|
||||
<string name="settings_category_alba_export">Export location alba</string>
|
||||
<string name="settings_category_groups_export">Export location groups</string>
|
||||
|
||||
|
||||
<string name="settings_version_number">Version Number</string>
|
||||
<string name="settings_build_date">Build date</string>
|
||||
|
||||
<string name="settings_auto_export_enable_checkbox">Enable automatic export</string>
|
||||
<string name="settings_auto_export_require_unmetered_checkbox">Require unmetered network?</string>
|
||||
<string name="settings_auto_export_require_charging_checkbox">Require charging?</string>
|
||||
<string name="settings_auto_export_interval_list">Export interval</string>
|
||||
<string name="settings_auto_export_different_path_switch">Use a different export path</string>
|
||||
<string name="settings_auto_export_different_path_switch_summary">Off means that the automatic export uses the same export path as alba.</string>
|
||||
<string name="settings_auto_export_different_path">Export path</string>
|
||||
<string name="settings_auto_export_different_structure_switch">Use a different subdirectory structure</string>
|
||||
<string name="settings_auto_export_different_structure_switch_summary">Off means that the automatic export uses the same subdirectory structure as alba.</string>
|
||||
<string name="settings_auto_export_different_structure">Subdirectory structure</string>
|
||||
|
||||
<string name="settings_category_export_location">Export Location</string>
|
||||
<string name="settings_export_path">Export Base Path</string>
|
||||
<string name="settings_export_subdirectory_structure_dialog_message">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</string>
|
||||
|
||||
|
||||
<string name="settings_export_path_alba">Export path for alba</string>
|
||||
<string name="settings_export_structure_alba">Subdirectory structure for albums</string>
|
||||
<string name="settings_export_subdirectory_structure_album">Set your subdirectory structure</string>
|
||||
<string name="settings_export_subdirectory_structure_album_example">Example: Beatles/Help!/13. Yesterday.mp3</string>
|
||||
|
||||
<string name="settings_export_path_groups">Export path for groups</string>
|
||||
<string name="settings_export_structure_groups">Subdirectory structure for playlists</string>
|
||||
<string name="settings_export_subdirectory_structure_group">Set your subdirectory structure</string>
|
||||
<string name="settings_export_subdirectory_structure_group_example">Example: Great Songs/4. Beatles - Yesterday.mp3</string>
|
||||
|
@ -108,10 +127,14 @@
|
|||
<string name="settings_donation_old_url" translatable="false"><![CDATA[https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A2VD24Z5E32RU]]></string>
|
||||
|
||||
<string name="action_mode_track_selection">%d tracks selected</string>
|
||||
|
||||
<string name="pref_header_export">Export</string>
|
||||
<string name="pref_header_automation">Automation</string>
|
||||
<string name="pref_header_about">About</string>
|
||||
<string name="pref_header_debug">Debug</string>
|
||||
|
||||
<string name="settings_export_structure_alba_default_value" translatable="false">{album-artist}/{album}/{disc=CD $}/{no=$$.} {title}.mp3</string>
|
||||
<string name="settings_export_structure_groups_default_value" translatable="false">{group}/{group-no=$$.} {artist} - {title}.mp3</string>
|
||||
|
||||
<string name="debug_trigger_export_all_title">Trigger ExportAllService now</string>
|
||||
</resources>
|
||||
|
|
|
@ -47,13 +47,14 @@
|
|||
|
||||
<!-- Develop -->
|
||||
<PreferenceCategory android:title="@string/settings_category_develop">
|
||||
<!-- TODO change Version number and build date with releases -->
|
||||
<!-- Version number-->
|
||||
<Preference
|
||||
android:summary="3.0.0"
|
||||
android:summary="0.9.1"
|
||||
android:title="@string/settings_version_number" />
|
||||
<!-- Build date-->
|
||||
<Preference
|
||||
android:summary="29.11.2016"
|
||||
android:summary="31.12.2016"
|
||||
android:title="@string/settings_build_date" />
|
||||
</PreferenceCategory>
|
||||
|
||||
|
|
|
@ -1,23 +1,35 @@
|
|||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<Preference
|
||||
android:title="System Requirements"
|
||||
android:summary="Automated export requires Android 5.0 Lollipop, so enabling this on lower Android versions won't do anything."/>
|
||||
<PreferenceCategory android:title="Automation Settings">
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="preference_auto_export_enabled"
|
||||
android:title="@string/settings_auto_export_enable_checkbox" />
|
||||
<ListPreference
|
||||
android:entries="@array/settings_export_frequency_value_names"
|
||||
android:entryValues="@array/settings_export_frequency_values"
|
||||
android:key="preference_auto_export_frequency"
|
||||
android:title="@string/settings_auto_export_interval_list" />
|
||||
<PreferenceCategory android:title="@string/settings_category_auto_export_path_subdir">
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="preference_automatic_export_enabled"
|
||||
android:title="Enable Automatic Export" />
|
||||
<ListPreference
|
||||
android:entries="@array/settings_export_frequency_value_names"
|
||||
android:entryValues="@array/settings_export_frequency_values"
|
||||
android:key="preference_automatic_export_frequency"
|
||||
android:title="Export Interval" />
|
||||
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" />
|
||||
<Preference
|
||||
android:key="preference_auto_export_path"
|
||||
android:title="@string/settings_auto_export_different_path" />
|
||||
<SwitchPreference
|
||||
android:key="preference_auto_export_use_different_structure"
|
||||
android:summary="@string/settings_auto_export_different_structure_switch_summary"
|
||||
android:title="@string/settings_auto_export_different_structure_switch" />
|
||||
<Preference
|
||||
android:key="preference_auto_export_structure"
|
||||
android:title="@string/settings_auto_export_different_structure" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/settings_category_auto_export_conditions">
|
||||
<CheckBoxPreference
|
||||
android:key="preference_automatic_export_require_charging"
|
||||
android:title="Require Charging?" />
|
||||
android:key="preference_auto_export_require_charging"
|
||||
android:title="@string/settings_auto_export_require_charging_checkbox" />
|
||||
<CheckBoxPreference
|
||||
android:key="preference_automatic_export_require_unmetered"
|
||||
android:title="Require Unmetered Network?" />
|
||||
|
||||
android:key="preference_auto_export_require_unmetered"
|
||||
android:title="@string/settings_auto_export_require_unmetered_checkbox" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -1,20 +1,25 @@
|
|||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_export_location">
|
||||
<PreferenceCategory android:title="@string/settings_category_alba_export">
|
||||
<!-- Base path for alba -->
|
||||
<Preference
|
||||
android:key="preference_export_path"
|
||||
android:title="@string/settings_export_path">
|
||||
</Preference>
|
||||
android:key="preference_alba_export_path"
|
||||
android:title="@string/settings_export_path_alba" />
|
||||
|
||||
<!-- Path structure for albums -->
|
||||
<!-- Path structure for alba -->
|
||||
<EditTextPreference
|
||||
android:defaultValue="@string/settings_export_structure_alba_default_value"
|
||||
android:dialogMessage="@string/settings_export_subdirectory_structure_dialog_message"
|
||||
android:dialogTitle="@string/settings_export_subdirectory_structure_album"
|
||||
android:hint="@string/settings_export_structure_alba_default_value"
|
||||
android:key="preference_structure_alba"
|
||||
android:key="preference_alba_export_structure"
|
||||
android:summary="@string/settings_export_subdirectory_structure_album_example"
|
||||
android:title="@string/settings_export_structure_alba" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/settings_category_groups_export">
|
||||
<!-- Base path for groups -->
|
||||
<Preference
|
||||
android:key="preference_groups_export_path"
|
||||
android:title="@string/settings_export_path_groups" />
|
||||
|
||||
<!-- Path structure for groups -->
|
||||
<EditTextPreference
|
||||
|
@ -22,7 +27,7 @@
|
|||
android:dialogMessage="@string/settings_export_subdirectory_structure_dialog_message"
|
||||
android:dialogTitle="@string/settings_export_subdirectory_structure_group"
|
||||
android:hint="@string/settings_export_structure_groups_default_value"
|
||||
android:key="preference_structure_groups"
|
||||
android:key="preference_groups_export_structure"
|
||||
android:summary="@string/settings_export_subdirectory_structure_group_example"
|
||||
android:title="@string/settings_export_structure_groups" />
|
||||
</PreferenceCategory>
|
||||
|
|
|
@ -19,6 +19,6 @@
|
|||
<header
|
||||
android:fragment="re.jcg.playmusicexporter.activities.SettingsActivity$DebugPreferenceFragment"
|
||||
android:icon="@drawable/ic_action_settings"
|
||||
android:title="Debug" />
|
||||
android:title="@string/pref_header_debug" />
|
||||
|
||||
</preference-headers>
|
||||
|
|
|
@ -67,14 +67,6 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
||||
|
@ -83,6 +75,14 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
|
||||
|
|
Loading…
Reference in a new issue