mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
#829 Integrates JMBE Creator with new user preferences editor for auto-downloading and compiling the JMBE library from within sdrtrunk. (#844)
Co-authored-by: Denny <denny@denny-desktop>
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
package io.github.dsheirer.preference.decoder;
|
||||
|
||||
import io.github.dsheirer.jmbe.github.Version;
|
||||
import io.github.dsheirer.preference.Preference;
|
||||
import io.github.dsheirer.preference.PreferenceType;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
@@ -32,6 +33,8 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.prefs.Preferences;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Decoder preferences
|
||||
@@ -42,7 +45,10 @@ public class JmbeLibraryPreference extends Preference
|
||||
private Preferences mPreferences = Preferences.userNodeForPackage(JmbeLibraryPreference.class);
|
||||
|
||||
private static final String PREFERENCE_KEY_PATH_JMBE_LIBRARY = "path.jmbe.library.1.0.0";
|
||||
private static final String PREFERENCE_KEY_PATH_ALERT_LIBRARY_REQUIRED = "alert.jmbe.required";
|
||||
private final Pattern VERSION_PATTERN = Pattern.compile(".*jmbe-(\\d{1,5}.\\d{1,5}.\\d{1,5}\\w*)\\.jar");
|
||||
private Path mPathJmbeLibrary;
|
||||
private Boolean mAlertIfMissingLibraryRequired;
|
||||
|
||||
/**
|
||||
* Constructs this preference with an update listener
|
||||
@@ -60,6 +66,23 @@ public class JmbeLibraryPreference extends Preference
|
||||
return PreferenceType.JMBE_LIBRARY;
|
||||
}
|
||||
|
||||
public Version getCurrentVersion()
|
||||
{
|
||||
Path path = getPathJmbeLibrary();
|
||||
|
||||
if(path != null)
|
||||
{
|
||||
Matcher m = VERSION_PATTERN.matcher(path.toString());
|
||||
|
||||
if(m.matches())
|
||||
{
|
||||
return Version.fromString(m.group(1));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Path to the JMBE audio codec library
|
||||
*/
|
||||
@@ -73,6 +96,14 @@ public class JmbeLibraryPreference extends Preference
|
||||
return mPathJmbeLibrary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if a path to a JMBE library is setup (ie non-null).
|
||||
*/
|
||||
public boolean hasJmbeLibraryPath()
|
||||
{
|
||||
return getPathJmbeLibrary() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the path to the JMBE library
|
||||
*/
|
||||
@@ -93,6 +124,30 @@ public class JmbeLibraryPreference extends Preference
|
||||
notifyPreferenceUpdated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the user should be alerted when the JMBE library is not setup, but required for decoding.
|
||||
*/
|
||||
public boolean getAlertIfMissingLibraryRequired()
|
||||
{
|
||||
if(mAlertIfMissingLibraryRequired == null)
|
||||
{
|
||||
mAlertIfMissingLibraryRequired = mPreferences.getBoolean(PREFERENCE_KEY_PATH_ALERT_LIBRARY_REQUIRED, true);
|
||||
}
|
||||
|
||||
return mAlertIfMissingLibraryRequired;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value for alerting when the library is required for decoding but the library is not currently setup.
|
||||
* @param alert true if the user should be alerted when the library is not setup, but required for decoding.
|
||||
*/
|
||||
public void setAlertIfMissingLibraryRequired(boolean alert)
|
||||
{
|
||||
mAlertIfMissingLibraryRequired = alert;
|
||||
mPreferences.putBoolean(PREFERENCE_KEY_PATH_ALERT_LIBRARY_REQUIRED, mAlertIfMissingLibraryRequired);
|
||||
notifyPreferenceUpdated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path stored in preferences and referenced by the key argument if it exists, otherwise returns the
|
||||
* default path.
|
||||
|
||||
@@ -42,6 +42,7 @@ public class DirectoryPreference extends Preference
|
||||
private static final String DIRECTORY_APPLICATION_ROOT = "SDRTrunk";
|
||||
private static final String DIRECTORY_APPLICATION_LOG = "logs";
|
||||
private static final String DIRECTORY_EVENT_LOG = "event_logs";
|
||||
private static final String DIRECTORY_JMBE = "jmbe";
|
||||
private static final String DIRECTORY_PLAYLIST = "playlist";
|
||||
private static final String DIRECTORY_RECORDING = "recordings";
|
||||
private static final String DIRECTORY_SCREEN_CAPTURE = "screen_captures";
|
||||
@@ -50,6 +51,7 @@ public class DirectoryPreference extends Preference
|
||||
private static final String PREFERENCE_KEY_DIRECTORY_APPLICATION_ROOT = "directory.application.root";
|
||||
private static final String PREFERENCE_KEY_DIRECTORY_APPLICATION_LOGS = "directory.application.logs";
|
||||
private static final String PREFERENCE_KEY_DIRECTORY_EVENT_LOGS = "directory.event.logs";
|
||||
private static final String PREFERENCE_KEY_DIRECTORY_JMBE = "directory.jmbe";
|
||||
private static final String PREFERENCE_KEY_DIRECTORY_PLAYLIST = "directory.playlist";
|
||||
private static final String PREFERENCE_KEY_DIRECTORY_RECORDING = "directory.recording";
|
||||
private static final String PREFERENCE_KEY_DIRECTORY_SCREEN_CAPTURE = "directory.screen.capture";
|
||||
@@ -58,6 +60,7 @@ public class DirectoryPreference extends Preference
|
||||
private Path mDirectoryApplicationRoot;
|
||||
private Path mDirectoryApplicationLogs;
|
||||
private Path mDirectoryEventLogs;
|
||||
private Path mDirectoryJmbe;
|
||||
private Path mDirectoryPlaylist;
|
||||
private Path mDirectoryRecording;
|
||||
private Path mDirectoryScreenCapture;
|
||||
@@ -115,6 +118,7 @@ public class DirectoryPreference extends Preference
|
||||
{
|
||||
mDirectoryApplicationLogs = null;
|
||||
mDirectoryEventLogs = null;
|
||||
mDirectoryJmbe = null;
|
||||
mDirectoryPlaylist = null;
|
||||
mDirectoryRecording = null;
|
||||
mDirectoryScreenCapture = null;
|
||||
@@ -204,6 +208,40 @@ public class DirectoryPreference extends Preference
|
||||
notifyPreferenceUpdated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Path to the folder for storing the JMBE audio library
|
||||
*/
|
||||
public Path getDirectoryJmbe()
|
||||
{
|
||||
if(mDirectoryJmbe == null)
|
||||
{
|
||||
mDirectoryJmbe = getPath(PREFERENCE_KEY_DIRECTORY_JMBE, getDefaultJmbeDirectory());
|
||||
createDirectory(mDirectoryJmbe);
|
||||
}
|
||||
|
||||
return mDirectoryJmbe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the path to the JMBE folder
|
||||
*/
|
||||
public void setDirectoryJmbe(Path path)
|
||||
{
|
||||
mDirectoryJmbe = path;
|
||||
mPreferences.put(PREFERENCE_KEY_DIRECTORY_JMBE, path.toString());
|
||||
notifyPreferenceUpdated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a stored playlist directory preference so that the default path can be used again
|
||||
*/
|
||||
public void resetDirectoryJmbe()
|
||||
{
|
||||
mPreferences.remove(PREFERENCE_KEY_DIRECTORY_JMBE);
|
||||
mDirectoryJmbe = null;
|
||||
notifyPreferenceUpdated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Path to the folder for storing playlist
|
||||
*/
|
||||
@@ -364,6 +402,14 @@ public class DirectoryPreference extends Preference
|
||||
return getDirectoryApplicationRoot().resolve(DIRECTORY_EVENT_LOG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default JMBE directory
|
||||
*/
|
||||
public Path getDefaultJmbeDirectory()
|
||||
{
|
||||
return getDirectoryApplicationRoot().resolve(DIRECTORY_JMBE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default playlist directory
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user