|
@@ -1,6 +1,7 @@
|
|
/*
|
|
/*
|
|
* Nextcloud - Android Client
|
|
* Nextcloud - Android Client
|
|
*
|
|
*
|
|
|
|
+ * SPDX-FileCopyrightText: 2024 Alper Ozturk <alper.ozturk@nextcloud.com>
|
|
* SPDX-FileCopyrightText: 2020 Chris Narkiewicz <hello@ezaquarii.com>
|
|
* SPDX-FileCopyrightText: 2020 Chris Narkiewicz <hello@ezaquarii.com>
|
|
* SPDX-FileCopyrightText: 2017 Mario Danic <mario@lovelyhq.com>
|
|
* SPDX-FileCopyrightText: 2017 Mario Danic <mario@lovelyhq.com>
|
|
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH
|
|
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH
|
|
@@ -8,17 +9,24 @@
|
|
*/
|
|
*/
|
|
package com.owncloud.android.ui.activity
|
|
package com.owncloud.android.ui.activity
|
|
|
|
|
|
|
|
+import android.os.Build
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
import android.view.Menu
|
|
import android.view.Menu
|
|
import android.view.MenuItem
|
|
import android.view.MenuItem
|
|
import android.view.View
|
|
import android.view.View
|
|
|
|
+import android.view.WindowInsetsController
|
|
import androidx.annotation.VisibleForTesting
|
|
import androidx.annotation.VisibleForTesting
|
|
|
|
+import androidx.appcompat.app.AppCompatActivity
|
|
|
|
+import androidx.core.content.ContextCompat
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
import com.google.android.material.snackbar.Snackbar
|
|
import com.google.android.material.snackbar.Snackbar
|
|
import com.nextcloud.client.account.User
|
|
import com.nextcloud.client.account.User
|
|
import com.nextcloud.client.account.UserAccountManager
|
|
import com.nextcloud.client.account.UserAccountManager
|
|
|
|
+import com.nextcloud.client.di.Injectable
|
|
import com.nextcloud.client.jobs.NotificationWork
|
|
import com.nextcloud.client.jobs.NotificationWork
|
|
|
|
+import com.nextcloud.client.network.ClientFactory
|
|
import com.nextcloud.client.network.ClientFactory.CreationException
|
|
import com.nextcloud.client.network.ClientFactory.CreationException
|
|
|
|
+import com.nextcloud.client.preferences.AppPreferences
|
|
import com.nextcloud.common.NextcloudClient
|
|
import com.nextcloud.common.NextcloudClient
|
|
import com.owncloud.android.R
|
|
import com.owncloud.android.R
|
|
import com.owncloud.android.databinding.NotificationsLayoutBinding
|
|
import com.owncloud.android.databinding.NotificationsLayoutBinding
|
|
@@ -33,12 +41,15 @@ import com.owncloud.android.ui.asynctasks.DeleteAllNotificationsTask
|
|
import com.owncloud.android.ui.notifications.NotificationsContract
|
|
import com.owncloud.android.ui.notifications.NotificationsContract
|
|
import com.owncloud.android.utils.DisplayUtils
|
|
import com.owncloud.android.utils.DisplayUtils
|
|
import com.owncloud.android.utils.PushUtils
|
|
import com.owncloud.android.utils.PushUtils
|
|
|
|
+import com.owncloud.android.utils.theme.ViewThemeUtils
|
|
import java.util.Optional
|
|
import java.util.Optional
|
|
|
|
+import javax.inject.Inject
|
|
|
|
|
|
/**
|
|
/**
|
|
* Activity displaying all server side stored notification items.
|
|
* Activity displaying all server side stored notification items.
|
|
*/
|
|
*/
|
|
-class NotificationsActivity : DrawerActivity(), NotificationsContract.View {
|
|
|
|
|
|
+@Suppress("TooManyFunctions")
|
|
|
|
+class NotificationsActivity : AppCompatActivity(), NotificationsContract.View, Injectable {
|
|
|
|
|
|
lateinit var binding: NotificationsLayoutBinding
|
|
lateinit var binding: NotificationsLayoutBinding
|
|
|
|
|
|
@@ -47,6 +58,18 @@ class NotificationsActivity : DrawerActivity(), NotificationsContract.View {
|
|
private var client: NextcloudClient? = null
|
|
private var client: NextcloudClient? = null
|
|
private var optionalUser: Optional<User>? = null
|
|
private var optionalUser: Optional<User>? = null
|
|
|
|
|
|
|
|
+ @Inject
|
|
|
|
+ lateinit var viewThemeUtils: ViewThemeUtils
|
|
|
|
+
|
|
|
|
+ @Inject
|
|
|
|
+ lateinit var accountManager: UserAccountManager
|
|
|
|
+
|
|
|
|
+ @Inject
|
|
|
|
+ lateinit var clientFactory: ClientFactory
|
|
|
|
+
|
|
|
|
+ @Inject
|
|
|
|
+ lateinit var preferences: AppPreferences
|
|
|
|
+
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
Log_OC.v(TAG, "onCreate() start")
|
|
Log_OC.v(TAG, "onCreate() start")
|
|
|
|
|
|
@@ -54,26 +77,56 @@ class NotificationsActivity : DrawerActivity(), NotificationsContract.View {
|
|
|
|
|
|
binding = NotificationsLayoutBinding.inflate(layoutInflater)
|
|
binding = NotificationsLayoutBinding.inflate(layoutInflater)
|
|
setContentView(binding.root)
|
|
setContentView(binding.root)
|
|
|
|
+ setupActionBar()
|
|
|
|
+ setupStatusBar()
|
|
|
|
+ initUser()
|
|
|
|
+ setupContainingList()
|
|
|
|
+ setupPushWarning()
|
|
|
|
+ setupContent()
|
|
|
|
|
|
- optionalUser = user
|
|
|
|
|
|
+ if (optionalUser?.isPresent == false) {
|
|
|
|
+ showError()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ private fun initUser() {
|
|
|
|
+ optionalUser = Optional.of(accountManager.user)
|
|
intent?.let {
|
|
intent?.let {
|
|
it.extras?.let { bundle ->
|
|
it.extras?.let { bundle ->
|
|
setupUser(bundle)
|
|
setupUser(bundle)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- setupToolbar()
|
|
|
|
- updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_item_notifications))
|
|
|
|
- setupDrawer()
|
|
|
|
-
|
|
|
|
- if (optionalUser?.isPresent == false) {
|
|
|
|
- showError()
|
|
|
|
|
|
+ private fun setupActionBar() {
|
|
|
|
+ setSupportActionBar(findViewById(R.id.toolbar_back_button))
|
|
|
|
+ supportActionBar?.apply {
|
|
|
|
+ setTitle(R.string.drawer_item_notifications)
|
|
|
|
+ setDisplayHomeAsUpEnabled(true)
|
|
|
|
+ setHomeAsUpIndicator(R.drawable.ic_arrow_back_foreground)
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- setupContainingList()
|
|
|
|
- setupPushWarning()
|
|
|
|
- setupContent()
|
|
|
|
|
|
+ private fun setupStatusBar() {
|
|
|
|
+ window.statusBarColor = ContextCompat.getColor(this, R.color.bg_default)
|
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
|
|
+ val appearanceLightStatusBars = if (preferences.isDarkModeEnabled) {
|
|
|
|
+ 0
|
|
|
|
+ } else {
|
|
|
|
+ WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS
|
|
|
|
+ }
|
|
|
|
+ window.insetsController?.setSystemBarsAppearance(
|
|
|
|
+ appearanceLightStatusBars,
|
|
|
|
+ WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS
|
|
|
|
+ )
|
|
|
|
+ } else {
|
|
|
|
+ @Suppress("DEPRECATION")
|
|
|
|
+ window.decorView.systemUiVisibility = if (preferences.isDarkModeEnabled) {
|
|
|
|
+ 0
|
|
|
|
+ } else {
|
|
|
|
+ View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private fun setupContainingList() {
|
|
private fun setupContainingList() {
|
|
@@ -97,8 +150,6 @@ class NotificationsActivity : DrawerActivity(), NotificationsContract.View {
|
|
val user = optionalUser?.get()
|
|
val user = optionalUser?.get()
|
|
if (user?.accountName.equals(accountName, ignoreCase = true)) {
|
|
if (user?.accountName.equals(accountName, ignoreCase = true)) {
|
|
accountManager.setCurrentOwnCloudAccount(accountName)
|
|
accountManager.setCurrentOwnCloudAccount(accountName)
|
|
- setUser(userAccountManager.user)
|
|
|
|
- optionalUser = getUser()
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -167,18 +218,6 @@ class NotificationsActivity : DrawerActivity(), NotificationsContract.View {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- override fun openDrawer() {
|
|
|
|
- super.openDrawer()
|
|
|
|
- if (snackbar != null && snackbar?.isShown == true) {
|
|
|
|
- snackbar?.dismiss()
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- override fun closeDrawer() {
|
|
|
|
- super.closeDrawer()
|
|
|
|
- setupPushWarning()
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* sets up the UI elements and loads all notification items.
|
|
* sets up the UI elements and loads all notification items.
|
|
*/
|
|
*/
|
|
@@ -265,16 +304,16 @@ class NotificationsActivity : DrawerActivity(), NotificationsContract.View {
|
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
var retval = true
|
|
var retval = true
|
|
val itemId = item.itemId
|
|
val itemId = item.itemId
|
|
- if (itemId == android.R.id.home) {
|
|
|
|
- if (isDrawerOpen) {
|
|
|
|
- closeDrawer()
|
|
|
|
- } else {
|
|
|
|
- openDrawer()
|
|
|
|
|
|
+ when (itemId) {
|
|
|
|
+ android.R.id.home -> {
|
|
|
|
+ onBackPressedDispatcher.onBackPressed()
|
|
|
|
+ }
|
|
|
|
+ R.id.action_empty_notifications -> {
|
|
|
|
+ DeleteAllNotificationsTask(client, this).execute()
|
|
|
|
+ }
|
|
|
|
+ else -> {
|
|
|
|
+ retval = super.onOptionsItemSelected(item)
|
|
}
|
|
}
|
|
- } else if (itemId == R.id.action_empty_notifications) {
|
|
|
|
- DeleteAllNotificationsTask(client, this).execute()
|
|
|
|
- } else {
|
|
|
|
- retval = super.onOptionsItemSelected(item)
|
|
|
|
}
|
|
}
|
|
return retval
|
|
return retval
|
|
}
|
|
}
|