|
|
@ -61,6 +61,7 @@ import com.keylesspalace.tusky.interfaces.ActionButtonActivity |
|
|
|
import com.keylesspalace.tusky.interfaces.ReselectableFragment |
|
|
|
import com.keylesspalace.tusky.interfaces.ReselectableFragment |
|
|
|
import com.keylesspalace.tusky.pager.MainPagerAdapter |
|
|
|
import com.keylesspalace.tusky.pager.MainPagerAdapter |
|
|
|
import com.keylesspalace.tusky.service.StreamingService |
|
|
|
import com.keylesspalace.tusky.service.StreamingService |
|
|
|
|
|
|
|
import com.keylesspalace.tusky.settings.PrefKeys |
|
|
|
import com.keylesspalace.tusky.util.* |
|
|
|
import com.keylesspalace.tusky.util.* |
|
|
|
import com.mikepenz.iconics.IconicsDrawable |
|
|
|
import com.mikepenz.iconics.IconicsDrawable |
|
|
|
import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial |
|
|
|
import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial |
|
|
@ -190,19 +191,8 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje |
|
|
|
|
|
|
|
|
|
|
|
setupTabs(showNotificationTab) |
|
|
|
setupTabs(showNotificationTab) |
|
|
|
|
|
|
|
|
|
|
|
// Setup push notifications |
|
|
|
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) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
eventHub.events |
|
|
|
eventHub.events |
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
|
.autoDispose(this, Lifecycle.Event.ON_DESTROY) |
|
|
|
.autoDispose(this, Lifecycle.Event.ON_DESTROY) |
|
|
@ -210,6 +200,13 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje |
|
|
|
when (event) { |
|
|
|
when (event) { |
|
|
|
is ProfileEditedEvent -> onFetchUserInfoSuccess(event.newProfileData) |
|
|
|
is ProfileEditedEvent -> onFetchUserInfoSuccess(event.newProfileData) |
|
|
|
is MainTabsChangedEvent -> setupTabs(false) |
|
|
|
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")) |
|
|
|
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() { |
|
|
|
override fun onResume() { |
|
|
|
super.onResume() |
|
|
|
super.onResume() |
|
|
|
NotificationHelper.clearNotificationsForActiveAccount(this, accountManager) |
|
|
|
NotificationHelper.clearNotificationsForActiveAccount(this, accountManager) |
|
|
|