mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-12-15 13:11:44 +03:00
blink items when opened by notification warning
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
a9ec8c2eed
commit
fa70cffd83
1 changed files with 31 additions and 4 deletions
|
@ -21,6 +21,8 @@ import android.content.Intent
|
|||
import android.content.pm.PackageManager
|
||||
import android.graphics.PorterDuff
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.RippleDrawable
|
||||
import android.media.RingtoneManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
|
@ -89,6 +91,7 @@ import io.reactivex.schedulers.Schedulers
|
|||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
@ -130,7 +133,7 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu
|
|||
private lateinit var phoneBookIntegrationFlow: Flow<Boolean>
|
||||
private var profileQueryDisposable: Disposable? = null
|
||||
private var dbQueryDisposable: Disposable? = null
|
||||
private var scrollToNotificationCategory: Boolean? = false
|
||||
private var openedByNotificationWarning: Boolean = false
|
||||
|
||||
@SuppressLint("StringFormatInvalid")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
@ -167,7 +170,7 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu
|
|||
|
||||
private fun handleIntent(intent: Intent) {
|
||||
val extras: Bundle? = intent.extras
|
||||
scrollToNotificationCategory = extras?.getBoolean(KEY_SCROLL_TO_NOTIFICATION_CATEGORY)
|
||||
openedByNotificationWarning = extras?.getBoolean(KEY_SCROLL_TO_NOTIFICATION_CATEGORY) ?: false
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -219,11 +222,12 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu
|
|||
themeTitles()
|
||||
themeSwitchPreferences()
|
||||
|
||||
if (scrollToNotificationCategory == true) {
|
||||
if (openedByNotificationWarning) {
|
||||
scrollToNotificationCategory()
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
private fun scrollToNotificationCategory() {
|
||||
binding.scrollView.post {
|
||||
val scrollViewLocation = IntArray(2)
|
||||
|
@ -231,7 +235,7 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu
|
|||
binding.scrollView.getLocationOnScreen(scrollViewLocation)
|
||||
binding.settingsNotificationsCategory.getLocationOnScreen(targetLocation)
|
||||
val offset = targetLocation[1] - scrollViewLocation[1]
|
||||
binding.scrollView.smoothScrollBy(0, offset)
|
||||
binding.scrollView.scrollBy(0, offset)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,6 +305,10 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu
|
|||
resources!!.getString(R.string.nc_diagnose_battery_optimization_not_ignored)
|
||||
binding.batteryOptimizationIgnored.setTextColor(resources.getColor(R.color.nc_darkRed, null))
|
||||
|
||||
if (openedByNotificationWarning){
|
||||
blinkRipple(binding.settingsBatteryOptimizationWrapper.background)
|
||||
}
|
||||
|
||||
binding.settingsBatteryOptimizationWrapper.setOnClickListener {
|
||||
val dialogText = String.format(
|
||||
context.resources.getString(R.string.nc_ignore_battery_optimization_dialog_text),
|
||||
|
@ -344,6 +352,10 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu
|
|||
resources.getColor(R.color.nc_darkRed, null)
|
||||
)
|
||||
|
||||
if (openedByNotificationWarning){
|
||||
blinkRipple(binding.settingsNotificationsPermissionWrapper.background)
|
||||
}
|
||||
|
||||
binding.settingsCallSound.isEnabled = false
|
||||
binding.settingsCallSound.alpha = DISABLED_ALPHA
|
||||
binding.settingsMessageSound.isEnabled = false
|
||||
|
@ -1380,6 +1392,21 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
private fun blinkRipple(rippleView: Drawable) {
|
||||
(rippleView as RippleDrawable).let { rippleDrawable ->
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
delay(1000L) // Wait 2 seconds before starting
|
||||
repeat(3) {
|
||||
rippleDrawable.state = intArrayOf(android.R.attr.state_pressed, android.R.attr.state_enabled)
|
||||
delay(250L) // Ripple active duration
|
||||
rippleDrawable.state = intArrayOf() // Reset state
|
||||
delay(250L) // Time between blinks
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val TAG = SettingsActivity::class.java.simpleName
|
||||
private const val DURATION: Long = 2500
|
||||
|
|
Loading…
Reference in a new issue