Quick Settings FlashLight
72 @Override 73 protected void handleUpdateState(BooleanState state, Object arg) { 74 if (state.value) { 75 mWasLastOn = SystemClock.uptimeMillis(); 76 } 77 78 if (arg instanceof Boolean) { 79 state.value = (Boolean) arg; 80 } 81 82 if (!state.value && mWasLastOn != 0) { 83 if (SystemClock.uptimeMillis() > mWasLastOn + RECENTLY_ON_DURATION_MILLIS) { 84 mWasLastOn = 0; 85 } else { 86 mHandler.removeCallbacks(mRecentlyOnTimeout); 87 mHandler.postAtTime(mRecentlyOnTimeout, mWasLastOn + RECENTLY_ON_DURATION_MILLIS); 88 } 89 } 90 91 // Always show the tile when the flashlight is or was recently on. This is needed because 92 // the camera is not available while it is being used for the flashlight. 93 state.visible = mWasLastOn != 0 || mFlashlightController.isAvailable(); 94 state.label = mHost.getContext().getString(R.string.quick_settings_flashlight_label); 95 state.iconId = state.value 96 ? R.drawable.ic_qs_flashlight_on : R.drawable.ic_qs_flashlight_off; 97 int onOrOffId = state.value 98 ? R.string.accessibility_quick_settings_flashlight_on 99 : R.string.accessibility_quick_settings_flashlight_off; 100 state.contentDescription = mContext.getString(onOrOffId); <="ライトがオフです" 101 }103 @Override 104 protected String composeChangeAnnouncement() { 105 if (mState.value) { 106 return mContext.getString(R.string.accessibility_quick_settings_flashlight_changed_on); 107 } else { 108 return mContext.getString(R.string.accessibility_quick_settings_flashlight_changed_off); 109 } 110 }
164 private void handleStateChanged() { 165 boolean delayAnnouncement = shouldAnnouncementBeDelayed(); 166 if (mCallback != null) { 167 mCallback.onStateChanged(mState); 168 if (mAnnounceNextStateChange && !delayAnnouncement) { [ true && [!(false)=>true] ] => true [ false && [!(false)=>true] ] => false [ true && [!(true)=>false] ] => false [ false && [!(true)=>false] ] => false 169 String announcement = composeChangeAnnouncement(); 170 if (announcement != null) { 171 mCallback.onAnnouncementRequested(announcement); 172 } 173 } 174 } // 1回イベントの通知をずらす 175 mAnnounceNextStateChange = mAnnounceNextStateChange && delayAnnouncement; [true && [false => false ]] => false [false && [false => false ]] => false [true && [true => true ]] => true [false && [true => true ]] => false 176 } 177
Wifiだけ、この関数がある
141 @Override 142 protected boolean shouldAnnouncementBeDelayed() { 発表は遅らせるべき 143 return mStateBeforeClick.enabled == mState.enabled; 144 } ></blockquote>< *1424398929*[android]Quick Settings ><blockquote cite="http://tools.oesf.biz/android-5.0.1_r1.0/xref/frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java#107" title="Cross Reference: /frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java">< >|java| 106 public void refreshState() { 107 mHandler.sendEmptyMessage(H.REFRESH_STATE); 108 }