public void initialize(
     Context context,
     PreferenceGroup group,
     boolean isZoomSupported,
     String[] keys,
     String[] otherSettingKeys) {
   mIndicatorControlWheel.initialize(context, group, isZoomSupported, keys, otherSettingKeys);
   mIndicatorControlWheel.setOnIndicatorEventListener(this);
 }
  public void onIndicatorEvent(int event) {
    switch (event) {
      case OnIndicatorEventListener.EVENT_ENTER_ZOOM_CONTROL:
        mIndicatorControlWheel.setVisibility(View.GONE);
        mZoomControlWheel.setVisibility(View.VISIBLE);
        mZoomControlWheel.startZoomControl();
        break;

      case OnIndicatorEventListener.EVENT_LEAVE_ZOOM_CONTROL:
        mZoomControlWheel.setVisibility(View.GONE);
        mIndicatorControlWheel.setVisibility(View.VISIBLE);
        break;
    }
  }
  @Override
  protected void onMeasure(int widthSpec, int heightSpec) {
    // Measure all children.
    int freeSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    mShutterButton.measure(freeSpec, freeSpec);
    mIndicatorControlWheel.measure(freeSpec, freeSpec);
    mZoomControlWheel.measure(freeSpec, freeSpec);

    // Measure myself. Add some buffer for highlight arc.
    int desiredWidth =
        mShutterButton.getMeasuredWidth() + IndicatorControlWheel.HIGHLIGHT_WIDTH * 4;
    int desiredHeight =
        mShutterButton.getMeasuredHeight() + IndicatorControlWheel.HIGHLIGHT_WIDTH * 4;
    int widthMode = MeasureSpec.getMode(widthSpec);
    int heightMode = MeasureSpec.getMode(heightSpec);
    int measuredWidth, measuredHeight;
    if (widthMode == MeasureSpec.UNSPECIFIED) {
      measuredWidth = desiredWidth;
    } else if (widthMode == MeasureSpec.AT_MOST) {
      measuredWidth = Math.min(desiredWidth, MeasureSpec.getSize(widthSpec));
    } else { // MeasureSpec.EXACTLY
      measuredWidth = MeasureSpec.getSize(widthSpec);
    }
    if (heightMode == MeasureSpec.UNSPECIFIED) {
      measuredHeight = desiredHeight;
    } else if (heightMode == MeasureSpec.AT_MOST) {
      measuredHeight = Math.min(desiredHeight, MeasureSpec.getSize(heightSpec));
    } else { // MeasureSpec.EXACTLY
      measuredHeight = MeasureSpec.getSize(heightSpec);
    }
    setMeasuredDimension(measuredWidth, measuredHeight);
  }
  @Override
  public boolean dispatchTouchEvent(MotionEvent event) {
    if (!onFilterTouchEventForSecurity(event)) return false;

    int action = event.getAction();

    double dx = event.getX() - mCenterX;
    double dy = mCenterY - event.getY();
    double radius = Math.sqrt(dx * dx + dy * dy);

    // Check if the event should be dispatched to the shutter button.
    if (radius <= mShutterButtonRadius) {
      if (mIndicatorControlWheel.getVisibility() == View.VISIBLE) {
        mIndicatorControlWheel.onTouchOutBound();
      } else {
        return mZoomControlWheel.dispatchTouchEvent(event);
      }
      if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP) {
        return mShutterButton.dispatchTouchEvent(event);
      }
      return false;
    }

    if (mShutterButton.isPressed()) {
      // Send cancel to the shutter button if it was pressed.
      event.setAction(MotionEvent.ACTION_CANCEL);
      mShutterButton.dispatchTouchEvent(event);
      return true;
    }

    if (mIndicatorControlWheel.getVisibility() == View.VISIBLE) {
      return mIndicatorControlWheel.dispatchTouchEvent(event);
    } else {
      return mZoomControlWheel.dispatchTouchEvent(event);
    }
  }
  @Override
  protected void onLayout(boolean changed, int left, int top, int right, int bottom) {

    // Layout the shutter button.
    int shutterButtonWidth = mShutterButton.getMeasuredWidth();
    int shutterButtonHeight = mShutterButton.getMeasuredHeight();
    mCenterX = right - left - Util.dpToPixel(FULL_WHEEL_RADIUS);
    mCenterY = (bottom - top) / 2;
    mShutterButton.layout(
        right - left - shutterButtonWidth,
        mCenterY - shutterButtonHeight / 2,
        right - left,
        mCenterY + shutterButtonHeight - shutterButtonHeight / 2);
    // Layout the control wheel.
    mIndicatorControlWheel.layout(0, 0, right - left, bottom - top);
    mZoomControlWheel.layout(0, 0, right - left, bottom - top);
  }
 @Override
 public void overrideSettings(final String... keyvalues) {
   mIndicatorControlWheel.overrideSettings(keyvalues);
 }
 @Override
 public void enableZoom(boolean enabled) {
   mIndicatorControlWheel.enableZoom(enabled);
 }
 @Override
 public void setEnabled(boolean enabled) {
   mIndicatorControlWheel.setEnabled(enabled);
   mZoomControlWheel.setEnabled(enabled);
 }
 public void stopTimeLapseAnimation() {
   mIndicatorControlWheel.stopTimeLapseAnimation();
 }
 public void startTimeLapseAnimation(int timeLapseInterval, long startTime) {
   mIndicatorControlWheel.startTimeLapseAnimation(timeLapseInterval, startTime);
 }
 @Override
 public void setDegree(int degree) {
   mIndicatorControlWheel.setDegree(degree);
   mZoomControlWheel.setDegree(degree);
 }
 @Override
 public boolean dismissSettingPopup() {
   return mIndicatorControlWheel.dismissSettingPopup();
 }
 @Override
 public View getActiveSettingPopup() {
   return mIndicatorControlWheel.getActiveSettingPopup();
 }
 @Override
 public void reloadPreferences() {
   mIndicatorControlWheel.reloadPreferences();
 }
 @Override
 public void setListener(OnPreferenceChangedListener listener) {
   mIndicatorControlWheel.setListener(listener);
 }