mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
#1500 Makes Channel Auto-Start timeout a user-preference item to select in range 0-30 seconds. (#1501)
Co-authored-by: Dennis Sheirer <dsheirer@github.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2022 Dennis Sheirer
|
||||
* Copyright (C) 2014-2023 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -24,6 +24,7 @@ package io.github.dsheirer.preference;
|
||||
*/
|
||||
public enum PreferenceType
|
||||
{
|
||||
APPLICATION,
|
||||
CALIBRATION,
|
||||
DECODE_EVENT,
|
||||
DIRECTORY,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2022 Dennis Sheirer
|
||||
* Copyright (C) 2014-2023 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,6 +20,7 @@
|
||||
package io.github.dsheirer.preference;
|
||||
|
||||
import io.github.dsheirer.eventbus.MyEventBus;
|
||||
import io.github.dsheirer.preference.application.ApplicationPreference;
|
||||
import io.github.dsheirer.preference.calibration.VectorCalibrationPreference;
|
||||
import io.github.dsheirer.preference.decoder.JmbeLibraryPreference;
|
||||
import io.github.dsheirer.preference.directory.DirectoryPreference;
|
||||
@@ -55,7 +56,7 @@ import io.github.dsheirer.sample.Listener;
|
||||
*/
|
||||
public class UserPreferences implements Listener<PreferenceType>
|
||||
{
|
||||
private VectorCalibrationPreference mVectorCalibrationPreference;
|
||||
private ApplicationPreference mApplicationPreference;
|
||||
private ChannelMultiFrequencyPreference mChannelMultiFrequencyPreference;
|
||||
private DecodeEventPreference mDecodeEventPreference;
|
||||
private DirectoryPreference mDirectoryPreference;
|
||||
@@ -68,6 +69,7 @@ public class UserPreferences implements Listener<PreferenceType>
|
||||
private RecordPreference mRecordPreference;
|
||||
private TalkgroupFormatPreference mTalkgroupFormatPreference;
|
||||
private TunerPreference mTunerPreference;
|
||||
private VectorCalibrationPreference mVectorCalibrationPreference;
|
||||
|
||||
private SwingPreference mSwingPreference = new SwingPreference();
|
||||
private JavaFxPreferences mJavaFxPreferences = new JavaFxPreferences();
|
||||
@@ -80,6 +82,19 @@ public class UserPreferences implements Listener<PreferenceType>
|
||||
loadPreferenceTypes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Application general/miscellaneous preferences.
|
||||
* @return application preferences.
|
||||
*/
|
||||
public ApplicationPreference getApplicationPreference()
|
||||
{
|
||||
return mApplicationPreference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vector/SIMD calibration preferences.
|
||||
* @return vector calibration preferences.
|
||||
*/
|
||||
public VectorCalibrationPreference getVectorCalibrationPreference()
|
||||
{
|
||||
return mVectorCalibrationPreference;
|
||||
@@ -203,7 +218,7 @@ public class UserPreferences implements Listener<PreferenceType>
|
||||
*/
|
||||
private void loadPreferenceTypes()
|
||||
{
|
||||
mVectorCalibrationPreference = new VectorCalibrationPreference(this::receive);
|
||||
mApplicationPreference = new ApplicationPreference(this::receive);
|
||||
mChannelMultiFrequencyPreference = new ChannelMultiFrequencyPreference(this::receive);
|
||||
mDecodeEventPreference = new DecodeEventPreference(this::receive);
|
||||
mDirectoryPreference = new DirectoryPreference(this::receive);
|
||||
@@ -216,6 +231,7 @@ public class UserPreferences implements Listener<PreferenceType>
|
||||
mRecordPreference = new RecordPreference(this::receive);
|
||||
mTalkgroupFormatPreference = new TalkgroupFormatPreference(this::receive);
|
||||
mTunerPreference = new TunerPreference(this::receive);
|
||||
mVectorCalibrationPreference = new VectorCalibrationPreference(this::receive);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 Dennis Sheirer
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* ****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.preference.application;
|
||||
|
||||
import io.github.dsheirer.preference.Preference;
|
||||
import io.github.dsheirer.preference.PreferenceType;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import java.util.prefs.Preferences;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* General/Miscellaneous preferences
|
||||
*/
|
||||
public class ApplicationPreference extends Preference
|
||||
{
|
||||
private static final String PREFERENCE_KEY_CHANNEL_AUTO_START_TIMEOUT = "channel.auto.start.timeout";
|
||||
|
||||
private final static Logger mLog = LoggerFactory.getLogger(ApplicationPreference.class);
|
||||
private Preferences mPreferences = Preferences.userNodeForPackage(ApplicationPreference.class);
|
||||
private Integer mChannelAutoStartTimeout;
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param updateListener to receive notifications that a preference has been updated
|
||||
*/
|
||||
public ApplicationPreference(Listener<PreferenceType> updateListener)
|
||||
{
|
||||
super(updateListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreferenceType getPreferenceType()
|
||||
{
|
||||
return PreferenceType.APPLICATION;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Channel auto-start timeout. This is the countdown in seconds to allow the user to cancel the channel auto-start.
|
||||
* @return timeout in seconds.
|
||||
*/
|
||||
public int getChannelAutoStartTimeout()
|
||||
{
|
||||
if(mChannelAutoStartTimeout == null)
|
||||
{
|
||||
mChannelAutoStartTimeout = mPreferences.getInt(PREFERENCE_KEY_CHANNEL_AUTO_START_TIMEOUT, 10);
|
||||
}
|
||||
|
||||
return mChannelAutoStartTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the channel auto-start timeout seconds value.
|
||||
* @param timeout in seconds.
|
||||
*/
|
||||
public void setChannelAutoStartTimeout(int timeout)
|
||||
{
|
||||
mChannelAutoStartTimeout = timeout;
|
||||
mPreferences.putInt(PREFERENCE_KEY_CHANNEL_AUTO_START_TIMEOUT, timeout);
|
||||
notifyPreferenceUpdated();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user