Coalesce passing focus accents to reduce background rendering
This commit is contained in:
parent
25ea43bea7
commit
22a2130563
11 changed files with 199 additions and 14 deletions
|
|
@ -6,8 +6,8 @@ android {
|
|||
applicationId 'tv.luma.launcher'
|
||||
minSdk 26
|
||||
targetSdk 34
|
||||
versionCode 11
|
||||
versionName '1.1.8'
|
||||
versionCode 12
|
||||
versionName '1.1.9'
|
||||
}
|
||||
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8; targetCompatibility JavaVersion.VERSION_1_8 }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="tv.luma.launcher" android:versionCode="11" android:versionName="1.1.8">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="tv.luma.launcher" android:versionCode="12" android:versionName="1.1.9">
|
||||
<uses-sdk android:minSdkVersion="26" android:targetSdkVersion="34" />
|
||||
<uses-feature android:name="android.software.leanback" android:required="true" />
|
||||
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
|
||||
|
|
|
|||
|
|
@ -31,6 +31,13 @@ final class SceneView extends View {
|
|||
private float dim = .24f;
|
||||
private ValueAnimator animator, colorAnimator;
|
||||
private boolean useTintMask;
|
||||
private boolean accentPending;
|
||||
// Let the 160 ms focus lift finish; passing selections need no full-screen transition.
|
||||
private final Runnable accentUpdate =
|
||||
() -> {
|
||||
accentPending = false;
|
||||
applyAccent(targetAccent, true);
|
||||
};
|
||||
|
||||
SceneView(Context c) {
|
||||
super(c);
|
||||
|
|
@ -95,7 +102,10 @@ final class SceneView extends View {
|
|||
|
||||
void setMotion(boolean enabled) {
|
||||
motion = enabled;
|
||||
if (!enabled) stopAnimations();
|
||||
if (!enabled) {
|
||||
stopAnimations();
|
||||
if (dirty) requestRender();
|
||||
}
|
||||
}
|
||||
|
||||
void configure(String s, float darkness) {
|
||||
|
|
@ -106,14 +116,21 @@ final class SceneView extends View {
|
|||
}
|
||||
|
||||
void accent(int color, boolean animate) {
|
||||
if (targetAccent == color) return;
|
||||
targetAccent = color;
|
||||
removeCallbacks(accentUpdate);
|
||||
accentPending = animate && motion && active && frame != null;
|
||||
if (accentPending) postDelayed(accentUpdate, 160);
|
||||
else applyAccent(color, animate);
|
||||
}
|
||||
|
||||
private void applyAccent(int color, boolean animate) {
|
||||
if (!useTintMask) {
|
||||
if (accent == color) return;
|
||||
accent = targetAccent = color;
|
||||
accent = color;
|
||||
requestRender();
|
||||
return;
|
||||
}
|
||||
if (targetAccent == color) return;
|
||||
targetAccent = color;
|
||||
if (colorAnimator != null) colorAnimator.cancel();
|
||||
if (!animate || !motion || frame == null) {
|
||||
accent = color;
|
||||
|
|
@ -340,8 +357,11 @@ final class SceneView extends View {
|
|||
}
|
||||
|
||||
void stopAnimations() {
|
||||
removeCallbacks(accentUpdate);
|
||||
accentPending = false;
|
||||
stopImageAnimation();
|
||||
if (colorAnimator != null) colorAnimator.cancel();
|
||||
if (!useTintMask && accent != targetAccent) dirty = true;
|
||||
accent = targetAccent;
|
||||
invalidate();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue