|
|
|
@ -61,6 +61,7 @@ import com.keylesspalace.tusky.interfaces.ActionButtonActivity |
|
|
|
|
import com.keylesspalace.tusky.interfaces.ReselectableFragment |
|
|
|
|
import com.keylesspalace.tusky.pager.MainPagerAdapter |
|
|
|
|
import com.keylesspalace.tusky.service.StreamingService |
|
|
|
|
import com.keylesspalace.tusky.settings.PrefKeys |
|
|
|
|
import com.keylesspalace.tusky.util.* |
|
|
|
|
import com.mikepenz.iconics.IconicsDrawable |
|
|
|
|
import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial |
|
|
|
@ -190,19 +191,8 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje |
|
|
|
|
|
|
|
|
|
setupTabs(showNotificationTab) |
|
|
|
|
|
|
|
|
|
// Setup push notifications |
|
|
|
|
if (NotificationHelper.areNotificationsEnabled(this, accountManager)) { |
|
|
|
|
if(accountManager.areNotificationsStreamingEnabled()) { |
|
|
|
|
NotificationHelper.disablePullNotifications(this) |
|
|
|
|
StreamingService.startStreaming(this) |
|
|
|
|
} else { |
|
|
|
|
StreamingService.stopStreaming(this) |
|
|
|
|
NotificationHelper.enablePullNotifications(this) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
StreamingService.stopStreaming(this) |
|
|
|
|
NotificationHelper.disablePullNotifications(this) |
|
|
|
|
} |
|
|
|
|
initPullNotifications() |
|
|
|
|
|
|
|
|
|
eventHub.events |
|
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
|
|
.autoDispose(this, Lifecycle.Event.ON_DESTROY) |
|
|
|
@ -210,6 +200,13 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje |
|
|
|
|
when (event) { |
|
|
|
|
is ProfileEditedEvent -> onFetchUserInfoSuccess(event.newProfileData) |
|
|
|
|
is MainTabsChangedEvent -> setupTabs(false) |
|
|
|
|
is PreferenceChangedEvent -> { |
|
|
|
|
when(event.preferenceKey) { |
|
|
|
|
PrefKeys.LIVE_NOTIFICATIONS -> { |
|
|
|
|
initPullNotifications() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -217,6 +214,21 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje |
|
|
|
|
deleteStaleCachedMedia(applicationContext.getExternalFilesDir("Husky")) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun initPullNotifications() { |
|
|
|
|
if (NotificationHelper.areNotificationsEnabled(this, accountManager)) { |
|
|
|
|
if(accountManager.areNotificationsStreamingEnabled()) { |
|
|
|
|
NotificationHelper.disablePullNotifications(this) |
|
|
|
|
StreamingService.startStreaming(this) |
|
|
|
|
} else { |
|
|
|
|
StreamingService.stopStreaming(this) |
|
|
|
|
NotificationHelper.enablePullNotifications(this) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
StreamingService.stopStreaming(this) |
|
|
|
|
NotificationHelper.disablePullNotifications(this) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onResume() { |
|
|
|
|
super.onResume() |
|
|
|
|
NotificationHelper.clearNotificationsForActiveAccount(this, accountManager) |
|
|
|
|