アカウント設定でPush購読をON/OFFしたらそのタイミングで購読の更新を行う

This commit is contained in:
tateisu 2023-02-16 15:32:33 +09:00
parent 6f7340c5d4
commit 63b19940b5
2 changed files with 27 additions and 7 deletions

View File

@ -646,12 +646,27 @@ class ActAccountSetting : AppCompatActivity(),
views.cbLocked -> {
if (!profileBusy) sendLocked(isChecked)
}
views.swNotificationPullEnabled,
views.swNotificationPushEnabled,
-> {
views.swNotificationPullEnabled -> {
saveUIToData()
showPushSetting()
}
views.swNotificationPushEnabled -> launchAndShowError {
val oldChecked = account.notificationPushEnable
try {
if (oldChecked == isChecked) return@launchAndShowError
account.notificationPushEnable = isChecked
updatePushSubscription(force = true)
saveUIToData()
} catch (ex: Throwable) {
account.notificationPushEnable = oldChecked
buttonView.isChecked = oldChecked
throw ex
} finally {
showPushSetting()
}
}
else -> saveUIToData()
}
}

View File

@ -2,31 +2,36 @@ package jp.juggler.subwaytooter.view
import android.content.Context
import android.graphics.Rect
import android.os.SystemClock
import android.util.AttributeSet
import androidx.core.view.ViewCompat
import androidx.drawerlayout.widget.DrawerLayout
import jp.juggler.util.log.LogCategory
class MyDrawerLayout : DrawerLayout {
companion object {
// private val log = LogCategory("MyDrawerLayout")
private val log = LogCategory("MyDrawerLayout")
}
constructor(context: Context) :
super(context)
super(context)
constructor(context: Context, attrs: AttributeSet?) :
super(context, attrs)
super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) :
super(context, attrs, defStyleAttr)
super(context, attrs, defStyleAttr)
private var bottomExclusionWidth: Int = 0
private var bottomExclusionHeight: Int = 0
private val exclusionRects = listOf(Rect(), Rect(), Rect(), Rect())
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
val timeStart = SystemClock.elapsedRealtime()
super.onLayout(changed, l, t, r, b)
val timeEnd = SystemClock.elapsedRealtime()
log.i("onLayout ${timeEnd - timeStart}ms changed=$changed")
// 画面下部の左右にはボタンがあるので、システムジェスチャーナビゲーションの対象外にする
val w = r - l