|
5 | 5 |
|
6 | 6 | package com.igalia.wolvic.ui.widgets.settings; |
7 | 7 |
|
| 8 | +import android.animation.ValueAnimator; |
8 | 9 | import android.content.Context; |
| 10 | +import android.graphics.Color; |
9 | 11 | import android.graphics.Point; |
10 | 12 | import android.view.LayoutInflater; |
11 | 13 |
|
|
22 | 24 |
|
23 | 25 | class ControllerOptionsView extends SettingsView { |
24 | 26 |
|
| 27 | + private static final int HAND_TRACKING_WARNING_HIGHLIGHT_DURATION = 1000; |
| 28 | + private static final int HAND_TRACKING_WARNING_HIGHLIGHT_START_DELAY = 300; |
25 | 29 | private OptionsControllerBinding mBinding; |
26 | 30 |
|
27 | 31 | public ControllerOptionsView(Context aContext, WidgetManagerDelegate aWidgetManager) { |
@@ -161,10 +165,35 @@ private void setPointerMode(@WidgetManagerDelegate.PointerMode int value, boolea |
161 | 165 | } |
162 | 166 | } |
163 | 167 |
|
| 168 | + private void showHandTrackingWarningIfNeeded(boolean enabled) { |
| 169 | + if (enabled) { |
| 170 | + mBinding.handtrackingSwitchWarning.setVisibility(GONE); |
| 171 | + } else { |
| 172 | + mBinding.handtrackingSwitchWarning.setVisibility(VISIBLE); |
| 173 | + |
| 174 | + int highlightColor = getContext().getResources().getColor(R.color.eggplant); |
| 175 | + int targetColor = highlightColor & 0x00FFFFFF; // clear alpha |
| 176 | + |
| 177 | + mBinding.handtrackingSwitchWarning.setBackgroundColor(highlightColor); |
| 178 | + |
| 179 | + ValueAnimator animator = ValueAnimator.ofArgb(highlightColor, targetColor); |
| 180 | + animator.setDuration(HAND_TRACKING_WARNING_HIGHLIGHT_DURATION); |
| 181 | + animator.setStartDelay(HAND_TRACKING_WARNING_HIGHLIGHT_START_DELAY); |
| 182 | + animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { |
| 183 | + @Override |
| 184 | + public void onAnimationUpdate(ValueAnimator valueAnimator) { |
| 185 | + mBinding.handtrackingSwitchWarning.setBackgroundColor((int) valueAnimator.getAnimatedValue()); |
| 186 | + } |
| 187 | + }); |
| 188 | + animator.start(); |
| 189 | + } |
| 190 | + } |
| 191 | + |
164 | 192 | private void setHandTrackingEnabled(boolean value, boolean doApply) { |
165 | 193 | mBinding.handtrackingSwitch.setOnCheckedChangeListener(null); |
166 | 194 | mBinding.handtrackingSwitch.setValue(value, false); |
167 | 195 | mBinding.handtrackingSwitch.setOnCheckedChangeListener(mHandtrackingListener); |
| 196 | + showHandTrackingWarningIfNeeded(value); |
168 | 197 |
|
169 | 198 | if (doApply) { |
170 | 199 | mWidgetManager.setHandTrackingEnabled(value); |
|
0 commit comments