commit | 5f96ead12aff82b7d454d9003ddca3545a580a7f | [log] [tgz] |
---|---|---|
author | Ching-Sung Li <chriscsli@google.com> | Mon Jun 28 16:57:30 2021 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Mon Jun 28 16:57:30 2021 +0000 |
tree | bf5c53f7634eef06de9a4b52c4eae39c9dd53009 | |
parent | 6da5a4d9e23fa0e4f25828d8998a44fe38ec7acd [diff] | |
parent | e7b91d59f88b9079ebc30076849aae7f29d56d55 [diff] |
Delay setting night mode to show ripple animation am: e7b91d59f8 Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/ThemePicker/+/15093525 Change-Id: Ie59c3361b82c1c9250e011177ada95140ee47f45
diff --git a/src/com/android/customization/model/mode/DarkModeSectionController.java b/src/com/android/customization/model/mode/DarkModeSectionController.java index de63983..382162e 100644 --- a/src/com/android/customization/model/mode/DarkModeSectionController.java +++ b/src/com/android/customization/model/mode/DarkModeSectionController.java
@@ -25,6 +25,8 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.os.Handler; +import android.os.Looper; import android.os.PowerManager; import android.text.TextUtils; import android.view.LayoutInflater; @@ -124,7 +126,10 @@ return; } UiModeManager uiModeManager = context.getSystemService(UiModeManager.class); - uiModeManager.setNightModeActivated(viewActivated); + int shortDelay = context.getResources().getInteger(android.R.integer.config_shortAnimTime); + new Handler(Looper.getMainLooper()).postDelayed( + () -> uiModeManager.setNightModeActivated(viewActivated), + /* delayMillis= */ shortDelay); } private class BatterySaverStateReceiver extends BroadcastReceiver {
diff --git a/src/com/android/customization/picker/mode/DarkModeSectionView.java b/src/com/android/customization/picker/mode/DarkModeSectionView.java index 64b4622..6fc0a57 100644 --- a/src/com/android/customization/picker/mode/DarkModeSectionView.java +++ b/src/com/android/customization/picker/mode/DarkModeSectionView.java
@@ -45,8 +45,7 @@ switchView.setOnCheckedChangeListener((buttonView, isChecked) -> switchView.setChecked(mIsDarkModeActivated) ); - setOnClickListener( - view -> switchView.postDelayed(() -> modeToggleClicked(), /* delayMillis= */ 100)); + setOnClickListener(view -> modeToggleClicked()); } private void modeToggleClicked() {