mirror of
https://github.com/Matte23/circolapp.git
synced 2025-12-05 23:19:10 +00:00
Format code, add google-services.json as Github secret
This commit is contained in:
@@ -42,7 +42,8 @@ class SettingsActivity : AppCompatActivity() {
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
}
|
||||
|
||||
class SettingsFragment : PreferenceFragmentCompat(),
|
||||
class SettingsFragment :
|
||||
PreferenceFragmentCompat(),
|
||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.root_preferences, rootKey)
|
||||
@@ -104,11 +105,10 @@ class SettingsActivity : AppCompatActivity() {
|
||||
|
||||
activity?.let { PollWork.enqueue(it) }
|
||||
|
||||
if (sharedPreferences.getBoolean(
|
||||
"notify_new_circulars",
|
||||
true
|
||||
) && !sharedPreferences.getBoolean("enable_polling", false)
|
||||
) {
|
||||
val notifyNewCirculars = sharedPreferences.getBoolean("notify_new_circulars", true)
|
||||
val enablePolling = sharedPreferences.getBoolean("enable_polling", false)
|
||||
|
||||
if (notifyNewCirculars && !enablePolling) {
|
||||
val serverID = ServerAPI.getInstance(requireContext()).serverID()
|
||||
val serverToken = ServerAPI.Companion.Servers.values()[serverID].toString()
|
||||
|
||||
|
||||
@@ -74,11 +74,10 @@ class ServerAPI(
|
||||
}
|
||||
|
||||
fun getInstance(context: Context): ServerAPI {
|
||||
val preferenceManager = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
val serverID = sharedPreferences.getString("school", "0")?.toInt() ?: 0
|
||||
|
||||
val server = Servers.values()[
|
||||
preferenceManager.getString("school", "0")?.toInt() ?: 0
|
||||
]
|
||||
val server = Servers.values()[serverID]
|
||||
|
||||
return instance ?: synchronized(this) {
|
||||
instance ?: ServerAPI(createServer(server)).also { instance = it }
|
||||
@@ -89,11 +88,10 @@ class ServerAPI(
|
||||
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
val newServer = Servers.values()[index]
|
||||
|
||||
if (sharedPreferences.getBoolean(
|
||||
"notify_new_circulars",
|
||||
true
|
||||
) && !sharedPreferences.getBoolean("enable_polling", false)
|
||||
)
|
||||
val notifyNewCirculars = sharedPreferences.getBoolean("notify_new_circulars", true)
|
||||
val enablePolling = sharedPreferences.getBoolean("enable_polling", false)
|
||||
|
||||
if (notifyNewCirculars && !enablePolling)
|
||||
FirebaseTopicUtils.selectTopic(newServer.toString(), context)
|
||||
|
||||
instance?.changeServer(createServer(newServer))
|
||||
|
||||
@@ -65,11 +65,10 @@ class PollWork(appContext: Context, workerParams: WorkerParameters) :
|
||||
fun enqueue(context: Context) {
|
||||
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
|
||||
if (sharedPreferences.getBoolean(
|
||||
"notify_new_circulars",
|
||||
true
|
||||
) && sharedPreferences.getBoolean("enable_polling", false)
|
||||
) {
|
||||
val notifyNewCirculars = sharedPreferences.getBoolean("notify_new_circulars", true)
|
||||
val enablePolling = sharedPreferences.getBoolean("enable_polling", false)
|
||||
|
||||
if (notifyNewCirculars && enablePolling) {
|
||||
WorkManager.getInstance(context)
|
||||
.enqueueUniquePeriodicWork(
|
||||
pollWorkName,
|
||||
|
||||
Reference in New Issue
Block a user