kopia lustrzana https://github.com/ge0rg/aprsdroid
Even more IGate updates
rodzic
ea960a48a1
commit
a2fe1c8ce1
|
@ -178,7 +178,9 @@ class AprsService extends Service {
|
|||
poster = AprsBackend.instanciateUploader(this, prefs)
|
||||
if (poster.start())
|
||||
onPosterStarted()
|
||||
igateService.start()
|
||||
if (prefs.isIgateEnabled() && (prefs.getBackendName().contains("KISS") || prefs.getBackendName().contains("AFSK"))) {
|
||||
igateService.start()
|
||||
}
|
||||
}
|
||||
|
||||
def onPosterStarted() {
|
||||
|
@ -216,7 +218,9 @@ class AprsService extends Service {
|
|||
// catch FC when service is killed from outside
|
||||
if (poster != null) {
|
||||
poster.stop()
|
||||
igateService.stop()
|
||||
if (prefs.isIgateEnabled() && (prefs.getBackendName().contains("KISS") || prefs.getBackendName().contains("AFSK"))) {
|
||||
igateService.stop()
|
||||
}
|
||||
showToast(getString(R.string.service_stop))
|
||||
|
||||
sendBroadcast(new Intent(SERVICE_STOPPED))
|
||||
|
@ -530,7 +534,10 @@ class AprsService extends Service {
|
|||
|
||||
// Process the incoming post
|
||||
digipeaterService.processIncomingPost(post)
|
||||
igateService.checkAprsisService(post)
|
||||
|
||||
if (prefs.isIgateEnabled() && (prefs.getBackendName().contains("KISS") || prefs.getBackendName().contains("AFSK"))) {
|
||||
igateService.handlePostSubmitData(post)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -3,31 +3,32 @@ package org.aprsdroid.app
|
|||
import _root_.android.content.SharedPreferences
|
||||
import _root_.android.os.Bundle
|
||||
import _root_.android.preference.{PreferenceActivity, CheckBoxPreference}
|
||||
import android.util.Log
|
||||
|
||||
class IgatePrefs extends PreferenceActivity with SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
lazy val prefs = new PrefsWrapper(this)
|
||||
|
||||
def loadXml() {
|
||||
def loadXml(): Unit = {
|
||||
// Load only the p.igating preference
|
||||
addPreferencesFromResource(R.xml.igate) // Ensure this XML only contains p.igating
|
||||
addPreferencesFromResource(R.xml.igate) // Ensure this XML only contains p.igating
|
||||
}
|
||||
|
||||
override def onCreate(savedInstanceState: Bundle) {
|
||||
override def onCreate(savedInstanceState: Bundle): Unit = {
|
||||
super.onCreate(savedInstanceState)
|
||||
loadXml()
|
||||
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this)
|
||||
getPreferenceScreen().getSharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
||||
|
||||
// Update preferences state on activity creation
|
||||
updateCheckBoxState()
|
||||
}
|
||||
|
||||
override def onDestroy() {
|
||||
override def onDestroy(): Unit = {
|
||||
super.onDestroy()
|
||||
getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this)
|
||||
getPreferenceScreen().getSharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
||||
}
|
||||
|
||||
override def onSharedPreferenceChanged(sp: SharedPreferences, key: String) {
|
||||
override def onSharedPreferenceChanged(sp: SharedPreferences, key: String): Unit = {
|
||||
key match {
|
||||
case "p.igating" =>
|
||||
// Handle changes to "p.igating" preference (if necessary)
|
||||
|
@ -37,10 +38,19 @@ class IgatePrefs extends PreferenceActivity with SharedPreferences.OnSharedPrefe
|
|||
}
|
||||
|
||||
// This method will enable/disable the checkboxes based on their current state
|
||||
private def updateCheckBoxState(): Unit = {
|
||||
val igatingPref = findPreference("p.igating").asInstanceOf[CheckBoxPreference]
|
||||
|
||||
// Add logic if needed to handle the "p.igating" preference state
|
||||
// For example, enabling or disabling other preferences based on this preference.
|
||||
}
|
||||
private def updateCheckBoxState(): Unit = {
|
||||
val igatingPref = findPreference("p.igating").asInstanceOf[CheckBoxPreference]
|
||||
|
||||
// Check if the service is running using your logic
|
||||
val isServiceRunning = prefs.getBoolean("service_running", false)
|
||||
|
||||
if (isServiceRunning) {
|
||||
// Disable the checkbox and update the summary
|
||||
igatingPref.setEnabled(false)
|
||||
igatingPref.setSummary("Setting disabled while the service is running.")
|
||||
} else {
|
||||
// Enable the checkbox and restore the default summary
|
||||
igatingPref.setEnabled(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ class IgateService(service : AprsService, prefs: PrefsWrapper) {
|
|||
// Send login information to the server
|
||||
sendLogin()
|
||||
|
||||
Log.d(TAG, "init_socket() - Connection established")
|
||||
Log.d(TAG, "init_socket() - Connection established to APRS-IS")
|
||||
service.addPost(StorageDatabase.Post.TYPE_DIGI, "APRS-IS", "Connection Established")
|
||||
return // If connection is successful, exit the loop
|
||||
} catch {
|
||||
|
@ -325,22 +325,6 @@ class IgateService(service : AprsService, prefs: PrefsWrapper) {
|
|||
}
|
||||
}
|
||||
|
||||
def checkAprsisService(data: String): Unit = {
|
||||
// Check if IGating is enabled
|
||||
if (!prefs.isIgateEnabled()) {
|
||||
Log.d("IgateService", "IGating is disabled")
|
||||
return
|
||||
}
|
||||
|
||||
// Check if one of the backend names is active ("KISS" or "AFSK")
|
||||
if (prefs.getBackendName().contains("KISS") || prefs.getBackendName().contains("AFSK")) {
|
||||
handlePostSubmitData(data)
|
||||
} else {
|
||||
Log.d("IgateService", "Not KISS or AFSK for IGating")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
def modifyData(data: String): String = {
|
||||
// Check if data contains "RFONLY" or "TCPIP"
|
||||
if (data.contains("RFONLY") || data.contains("TCPIP")) {
|
||||
|
|
Ładowanie…
Reference in New Issue