Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/VariableDateViewController.kt +19 −10 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import androidx.annotation.VisibleForTesting import com.android.systemui.Dependency import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.shade.ShadeExpansionStateManager import com.android.systemui.shade.ShadeLogger import com.android.systemui.util.ViewController import com.android.systemui.util.time.SystemClock import java.text.FieldPosition Loading Loading @@ -83,6 +84,7 @@ class VariableDateViewController( private val systemClock: SystemClock, private val broadcastDispatcher: BroadcastDispatcher, private val shadeExpansionStateManager: ShadeExpansionStateManager, private val shadeLogger: ShadeLogger, private val timeTickHandler: Handler, view: VariableDateView ) : ViewController<VariableDateView>(view) { Loading Loading @@ -111,24 +113,29 @@ class VariableDateViewController( private val intentReceiver: BroadcastReceiver = object : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { val action = intent.action if ( Intent.ACTION_LOCALE_CHANGED == action || Intent.ACTION_TIMEZONE_CHANGED == action ) { // need to get a fresh date format dateFormat = null shadeLogger.d("VariableDateViewController received intent to refresh date format") } val handler = mView.handler // If the handler is null, it means we received a broadcast while the view has not // finished being attached or in the process of being detached. // In that case, do not post anything. val handler = mView.handler ?: return val action = intent.action if ( if (handler == null) { shadeLogger.d("VariableDateViewController received intent but handler was null") } else if ( Intent.ACTION_TIME_TICK == action || Intent.ACTION_TIME_CHANGED == action || Intent.ACTION_TIMEZONE_CHANGED == action || Intent.ACTION_LOCALE_CHANGED == action ) { if ( Intent.ACTION_LOCALE_CHANGED == action || Intent.ACTION_TIMEZONE_CHANGED == action ) { // need to get a fresh date format handler.post { dateFormat = null } } handler.post(::updateClock) } } Loading Loading @@ -231,6 +238,7 @@ class VariableDateViewController( private val systemClock: SystemClock, private val broadcastDispatcher: BroadcastDispatcher, private val shadeExpansionStateManager: ShadeExpansionStateManager, private val shadeLogger: ShadeLogger, @Named(Dependency.TIME_TICK_HANDLER_NAME) private val handler: Handler ) { fun create(view: VariableDateView): VariableDateViewController { Loading @@ -238,6 +246,7 @@ class VariableDateViewController( systemClock, broadcastDispatcher, shadeExpansionStateManager, shadeLogger, handler, view ) Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/VariableDateViewControllerTest.kt +2 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.shade.ShadeExpansionStateManager import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.capture import com.android.systemui.util.mockito.mock import com.android.systemui.util.time.FakeSystemClock import com.google.common.truth.Truth.assertThat import org.junit.Before Loading Loading @@ -105,6 +106,7 @@ class VariableDateViewControllerTest : SysuiTestCase() { systemClock, broadcastDispatcher, shadeExpansionStateManager, mock(), testableHandler, view ) Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/VariableDateViewController.kt +19 −10 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import androidx.annotation.VisibleForTesting import com.android.systemui.Dependency import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.shade.ShadeExpansionStateManager import com.android.systemui.shade.ShadeLogger import com.android.systemui.util.ViewController import com.android.systemui.util.time.SystemClock import java.text.FieldPosition Loading Loading @@ -83,6 +84,7 @@ class VariableDateViewController( private val systemClock: SystemClock, private val broadcastDispatcher: BroadcastDispatcher, private val shadeExpansionStateManager: ShadeExpansionStateManager, private val shadeLogger: ShadeLogger, private val timeTickHandler: Handler, view: VariableDateView ) : ViewController<VariableDateView>(view) { Loading Loading @@ -111,24 +113,29 @@ class VariableDateViewController( private val intentReceiver: BroadcastReceiver = object : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { val action = intent.action if ( Intent.ACTION_LOCALE_CHANGED == action || Intent.ACTION_TIMEZONE_CHANGED == action ) { // need to get a fresh date format dateFormat = null shadeLogger.d("VariableDateViewController received intent to refresh date format") } val handler = mView.handler // If the handler is null, it means we received a broadcast while the view has not // finished being attached or in the process of being detached. // In that case, do not post anything. val handler = mView.handler ?: return val action = intent.action if ( if (handler == null) { shadeLogger.d("VariableDateViewController received intent but handler was null") } else if ( Intent.ACTION_TIME_TICK == action || Intent.ACTION_TIME_CHANGED == action || Intent.ACTION_TIMEZONE_CHANGED == action || Intent.ACTION_LOCALE_CHANGED == action ) { if ( Intent.ACTION_LOCALE_CHANGED == action || Intent.ACTION_TIMEZONE_CHANGED == action ) { // need to get a fresh date format handler.post { dateFormat = null } } handler.post(::updateClock) } } Loading Loading @@ -231,6 +238,7 @@ class VariableDateViewController( private val systemClock: SystemClock, private val broadcastDispatcher: BroadcastDispatcher, private val shadeExpansionStateManager: ShadeExpansionStateManager, private val shadeLogger: ShadeLogger, @Named(Dependency.TIME_TICK_HANDLER_NAME) private val handler: Handler ) { fun create(view: VariableDateView): VariableDateViewController { Loading @@ -238,6 +246,7 @@ class VariableDateViewController( systemClock, broadcastDispatcher, shadeExpansionStateManager, shadeLogger, handler, view ) Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/VariableDateViewControllerTest.kt +2 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.shade.ShadeExpansionStateManager import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.capture import com.android.systemui.util.mockito.mock import com.android.systemui.util.time.FakeSystemClock import com.google.common.truth.Truth.assertThat import org.junit.Before Loading Loading @@ -105,6 +106,7 @@ class VariableDateViewControllerTest : SysuiTestCase() { systemClock, broadcastDispatcher, shadeExpansionStateManager, mock(), testableHandler, view ) Loading