commit | be07fac0aad3cfc7f0fb8c795363d046826e59f6 | [log] [tgz] |
---|---|---|
author | Ching-Sung Li <chriscsli@google.com> | Mon Jun 28 17:19:27 2021 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Mon Jun 28 17:19:27 2021 +0000 |
tree | bf5c53f7634eef06de9a4b52c4eae39c9dd53009 | |
parent | 852c8dd930d6242d75f10f2981ea133a2388a1f0 [diff] | |
parent | 2b8c716a63c674b599379f7db0519cfb3126d0ab [diff] |
Delay setting night mode to show ripple animation am: e7b91d59f8 am: 8bb4fdc333 am: 2b8c716a63 Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/ThemePicker/+/15093525 Change-Id: If92e1d9f7dd7a470cc6e805b450a4362d36f7633
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() {