2424import android .content .Context ;
2525import android .content .Intent ;
2626import android .content .pm .PackageManager ;
27+ import android .content .res .Resources ;
28+ import android .os .Vibrator ;
29+ import android .provider .Settings ;
2730import android .util .AttributeSet ;
2831import android .util .Slog ;
2932import android .view .MotionEvent ;
3235import android .view .ViewTreeObserver ;
3336import android .view .ViewTreeObserver .OnPreDrawListener ;
3437import android .widget .FrameLayout ;
35-
3638import com .android .internal .widget .multiwaveview .MultiWaveView ;
3739import com .android .internal .widget .multiwaveview .MultiWaveView .OnTriggerListener ;
3840import com .android .systemui .R ;
@@ -76,7 +78,7 @@ public boolean isAssistantAvailable() {
7678 Intent intent = getAssistIntent ();
7779 return intent == null ? false
7880 : mContext .getPackageManager ().queryIntentActivities (intent ,
79- PackageManager .MATCH_DEFAULT_ONLY ).size () > 0 ;
81+ PackageManager .MATCH_DEFAULT_ONLY ).size () > 0 ;
8082 }
8183
8284 private Intent getAssistIntent () {
@@ -141,13 +143,14 @@ public void onTrigger(View v, final int target) {
141143 case com .android .internal .R .drawable .ic_lockscreen_search :
142144 mWaitingForLaunch = true ;
143145 startAssistActivity ();
146+ vibrate ();
144147 postDelayed (new Runnable () {
145148 public void run () {
146149 mWaitingForLaunch = false ;
147150 mBar .hideSearchPanel ();
148151 }
149152 }, SEARCH_PANEL_HOLD_DURATION );
150- break ;
153+ break ;
151154 }
152155 }
153156
@@ -193,10 +196,20 @@ public boolean onPreDraw() {
193196 }
194197 };
195198
199+ private void vibrate () {
200+ Context context = getContext ();
201+ if (Settings .System .getInt (context .getContentResolver (),
202+ Settings .System .HAPTIC_FEEDBACK_ENABLED , 1 ) != 0 ) {
203+ Resources res = context .getResources ();
204+ Vibrator vibrator = (Vibrator ) context .getSystemService (Context .VIBRATOR_SERVICE );
205+ vibrator .vibrate (res .getInteger (R .integer .config_search_panel_view_vibration_duration ));
206+ }
207+ }
208+
196209 public void show (final boolean show , boolean animate ) {
197210 if (!show ) {
198211 final LayoutTransition transitioner = animate ? createLayoutTransitioner () : null ;
199- ((ViewGroup )mSearchTargetsContainer ).setLayoutTransition (transitioner );
212+ ((ViewGroup ) mSearchTargetsContainer ).setLayoutTransition (transitioner );
200213 }
201214 mShowing = show ;
202215 if (show ) {
@@ -206,6 +219,7 @@ public void show(final boolean show, boolean animate) {
206219 // right before we are drawn
207220 mMultiWaveView .suspendAnimations ();
208221 getViewTreeObserver ().addOnPreDrawListener (mPreDrawListener );
222+ vibrate ();
209223 }
210224 setFocusable (true );
211225 setFocusableInTouchMode (true );
0 commit comments