Ping service now subscribes to Firebase topics every 15 minutes to keep the app alive, courses and rooms are now struck through if the course is cancelled

This commit is contained in:
Deniz Düzgören
2019-08-23 13:13:52 +02:00
parent fce4c949b3
commit e1f091d308
3 changed files with 16 additions and 1 deletions
@@ -64,7 +64,7 @@ class CardAdapter(private var mSubst: List<Subst>) : RecyclerView.Adapter<CardAd
} }
} }
with (currentItem.additional.toLowerCase(Locale.ROOT)) { with (currentItem.additional.toLowerCase(Locale.ROOT)) {
if (contains("eigenverantwortliches arbeiten") || contains("entfall")) { if (contains("eigenverantwortliches arbeiten") || contains("entfall") || contains("fällt aus")) {
strings[2].setSpan(StrikethroughSpan(), 0, strings[2].length, 0) strings[2].setSpan(StrikethroughSpan(), 0, strings[2].length, 0)
strings[3].setSpan(StrikethroughSpan(), 0, strings[3].length, 0) strings[3].setSpan(StrikethroughSpan(), 0, strings[3].length, 0)
} }
@@ -38,6 +38,12 @@ class FBPingService : JobService() {
FirebaseMessaging.getInstance().unsubscribeFromTopic("substitutions-debug") FirebaseMessaging.getInstance().unsubscribeFromTopic("substitutions-debug")
} }
if (prefs.getBoolean("subscribedToiOSChannel", false)) {
FirebaseMessaging.getInstance().subscribeToTopic("substitutions-ios")
} else {
FirebaseMessaging.getInstance().unsubscribeFromTopic("substitutions-ios")
}
FirebaseMessaging.getInstance().subscribeToTopic("substitutions-broadcast") FirebaseMessaging.getInstance().subscribeToTopic("substitutions-broadcast")
prefs.edit().putInt("pingFB", prefs.getInt("pingFB", 0) + 1).apply() prefs.edit().putInt("pingFB", prefs.getInt("pingFB", 0) + 1).apply()
@@ -407,6 +407,15 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
edit.putBoolean("subscribedToFBDebugChannel", !prefs.getBoolean("subscribedToFBDebugChannel", false)).apply() edit.putBoolean("subscribedToFBDebugChannel", !prefs.getBoolean("subscribedToFBDebugChannel", false)).apply()
Toast.makeText(mContext, "$subbed Firebase development channel", Toast.LENGTH_LONG).show() Toast.makeText(mContext, "$subbed Firebase development channel", Toast.LENGTH_LONG).show()
} }
"_IOSCHANNEL" -> {
val subbed = if (prefs.getBoolean("subscribedToiOSChannel", false)) {
"Unsubscribed from"
} else {
"Subscribed to"
}
edit.putBoolean("subscribedToiOSChannel", !prefs.getBoolean("subscribedToiOSChannel", false)).apply()
Toast.makeText(mContext, "$subbed iOS channel", Toast.LENGTH_LONG).show()
}
else -> Toast.makeText(mContext, getString(R.string.invalidCode), Toast.LENGTH_LONG).show() else -> Toast.makeText(mContext, getString(R.string.invalidCode), Toast.LENGTH_LONG).show()
} }
} }