private void initControllerView(View v) {
    Resources res = mContext.getResources();
    mPlayDescription =
        res.getText(com.android.internal.R.string.lockscreen_transport_play_description);
    mPauseDescription =
        res.getText(com.android.internal.R.string.lockscreen_transport_pause_description);
    mPauseButton = (ImageButton) v.findViewById(com.android.internal.R.id.pause);
    if (mPauseButton != null) {
      mPauseButton.requestFocus();
      mPauseButton.setOnClickListener(mPauseListener);
    }

    mFfwdButton = (ImageButton) v.findViewById(com.android.internal.R.id.ffwd);
    if (mFfwdButton != null) {
      mFfwdButton.setOnClickListener(mFfwdListener);
      if (!mFromXml) {
        mFfwdButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
      }
    }

    mRewButton = (ImageButton) v.findViewById(com.android.internal.R.id.rew);
    if (mRewButton != null) {
      mRewButton.setOnClickListener(mRewListener);
      if (!mFromXml) {
        mRewButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
      }
    }

    // By default these are hidden. They will be enabled when setPrevNextListeners() is called
    mNextButton = (ImageButton) v.findViewById(com.android.internal.R.id.next);
    if (mNextButton != null && !mFromXml && !mListenersSet) {
      mNextButton.setVisibility(View.GONE);
    }
    mPrevButton = (ImageButton) v.findViewById(com.android.internal.R.id.prev);
    if (mPrevButton != null && !mFromXml && !mListenersSet) {
      mPrevButton.setVisibility(View.GONE);
    }

    mProgress = (ProgressBar) v.findViewById(com.android.internal.R.id.mediacontroller_progress);
    if (mProgress != null) {
      if (mProgress instanceof SeekBar) {
        SeekBar seeker = (SeekBar) mProgress;
        seeker.setOnSeekBarChangeListener(mSeekListener);
      }
      mProgress.setMax(1000);
    }

    mEndTime = (TextView) v.findViewById(com.android.internal.R.id.time);
    mCurrentTime = (TextView) v.findViewById(com.android.internal.R.id.time_current);
    mFormatBuilder = new StringBuilder();
    mFormatter = new Formatter(mFormatBuilder, Locale.getDefault());

    installPrevNextListeners();
  }
Пример #2
0
  public void setPrevNextListeners(View.OnClickListener next, View.OnClickListener prev) {
    mNextListener = next;
    mPrevListener = prev;
    mListenersSet = true;

    if (mRoot != null) {
      installPrevNextListeners();

      if (mNextButton != null && !mFromXml) {
        mNextButton.setVisibility(View.VISIBLE);
      }
      if (mPrevButton != null && !mFromXml) {
        mPrevButton.setVisibility(View.VISIBLE);
      }
    }
  }
Пример #3
0
  private void initControllerView(View v) {
    mPauseButton = (ImageButton) v.findViewById(com.android.internal.R.id.pause);
    if (mPauseButton != null) {
      mPauseButton.requestFocus();
      mPauseButton.setOnClickListener(mPauseListener);
    }

    // add by unic 2010-09-19
    mVolumeDownButton = (ImageButton) v.findViewById(com.android.internal.R.id.volumedown);
    if (mVolumeDownButton != null) {
      mVolumeDownButton.setOnClickListener(
          new OnClickListener() {

            public void onClick(View v) {
              AudioManager audioManager =
                  (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
              if (audioManager != null) {
                audioManager.adjustSuggestedStreamVolume(
                    AudioManager.ADJUST_LOWER,
                    AudioManager.STREAM_SYSTEM,
                    AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_VIBRATE);
              }
            }
          });
    }

    mVolumeUpButton = (ImageButton) v.findViewById(com.android.internal.R.id.volumeup);
    if (mVolumeUpButton != null) {
      mVolumeUpButton.setOnClickListener(
          new OnClickListener() {

            public void onClick(View v) {
              AudioManager audioManager =
                  (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
              if (audioManager != null) {
                audioManager.adjustSuggestedStreamVolume(
                    AudioManager.ADJUST_RAISE,
                    AudioManager.STREAM_SYSTEM,
                    AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_VIBRATE);
              }
            }
          });
    }

    mFfwdButton = (ImageButton) v.findViewById(com.android.internal.R.id.ffwd);
    if (mFfwdButton != null) {
      mFfwdButton.setOnClickListener(mFfwdListener);
      if (!mFromXml) {
        mFfwdButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
      }
    }

    mRewButton = (ImageButton) v.findViewById(com.android.internal.R.id.rew);
    if (mRewButton != null) {
      mRewButton.setOnClickListener(mRewListener);
      if (!mFromXml) {
        mRewButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
      }
    }

    // By default these are hidden. They will be enabled when setPrevNextListeners() is called
    mNextButton = (ImageButton) v.findViewById(com.android.internal.R.id.next);
    if (mNextButton != null && !mFromXml && !mListenersSet) {
      mNextButton.setVisibility(View.GONE);
    }
    mPrevButton = (ImageButton) v.findViewById(com.android.internal.R.id.prev);
    if (mPrevButton != null && !mFromXml && !mListenersSet) {
      mPrevButton.setVisibility(View.GONE);
    }

    mProgress = (ProgressBar) v.findViewById(com.android.internal.R.id.mediacontroller_progress);
    if (mProgress != null) {
      if (mProgress instanceof SeekBar) {
        SeekBar seeker = (SeekBar) mProgress;
        seeker.setOnSeekBarChangeListener(mSeekListener);
      }
      mProgress.setMax(1000);
    }

    mEndTime = (TextView) v.findViewById(com.android.internal.R.id.time);
    mCurrentTime = (TextView) v.findViewById(com.android.internal.R.id.time_current);
    mFormatBuilder = new StringBuilder();
    mFormatter = new Formatter(mFormatBuilder, Locale.getDefault());

    installPrevNextListeners();
  }