Example usage for android.content.res Configuration NAVIGATION_DPAD

List of usage examples for android.content.res Configuration NAVIGATION_DPAD

Introduction

In this page you can find the example usage for android.content.res Configuration NAVIGATION_DPAD.

Prototype

int NAVIGATION_DPAD

To view the source code for android.content.res Configuration NAVIGATION_DPAD.

Click Source Link

Document

Constant for #navigation , value corresponding to the dpad resource qualifier.

Usage

From source file:wseemann.media.fmpdemo.activity.MediaPlayerActivity.java

/** Called when the activity is first created. */
@Override/*from   ww  w.j  a  v a2  s  . co m*/
public void onCreate(Bundle icicle) {
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    super.onCreate(icicle);
    setContentView(R.layout.activity_media_player);

    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    mCurrentTime = (TextView) findViewById(R.id.position_text);
    mTotalTime = (TextView) findViewById(R.id.duration_text);
    mProgress = (ProgressBar) findViewById(R.id.seek_bar);

    mPrevButton = (ImageButton) findViewById(R.id.previous_button);
    mPrevButton.setOnClickListener(mPrevListener);
    mPauseButton = (ImageButton) findViewById(R.id.play_pause_button);
    mPauseButton.setOnClickListener(mPauseListener);
    mNextButton = (ImageButton) findViewById(R.id.next_button);
    mNextButton.setOnClickListener(mNextListener);
    seekmethod = 1;

    mDeviceHasDpad = (getResources().getConfiguration().navigation == Configuration.NAVIGATION_DPAD);

    mShuffleButton = (ImageButton) findViewById(R.id.shuffle_button);
    mShuffleButton.setOnClickListener(mShuffleListener);
    mRepeatButton = (ImageButton) findViewById(R.id.repeat_button);
    mRepeatButton.setOnClickListener(mRepeatListener);

    if (mProgress instanceof SeekBar) {
        SeekBar seeker = (SeekBar) mProgress;
        seeker.setOnSeekBarChangeListener(mSeekListener);
    }
    mProgress.setMax(1000);

    mPager = (ViewPager) findViewById(R.id.pager);
}

From source file:com.android.music.MediaPlaybackActivity.java

/** Called when the activity is first created. */
@Override//from www.  j av  a 2 s.c om
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    mAlbumArtWorker = new Worker("album art worker");
    mAlbumArtHandler = new AlbumArtHandler(mAlbumArtWorker.getLooper());

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.audio_player);

    mCurrentTime = (TextView) findViewById(R.id.currenttime);
    mTotalTime = (TextView) findViewById(R.id.totaltime);
    mProgress = (ProgressBar) findViewById(android.R.id.progress);
    mAlbum = (ImageView) findViewById(R.id.album);
    mArtistName = (TextView) findViewById(R.id.artistname);
    mAlbumName = (TextView) findViewById(R.id.albumname);
    mTrackName = (TextView) findViewById(R.id.trackname);

    View v = (View) mArtistName.getParent();
    v.setOnTouchListener(this);
    v.setOnLongClickListener(this);

    v = (View) mAlbumName.getParent();
    v.setOnTouchListener(this);
    v.setOnLongClickListener(this);

    v = (View) mTrackName.getParent();
    v.setOnTouchListener(this);
    v.setOnLongClickListener(this);

    mPrevButton = (RepeatingImageButton) findViewById(R.id.prev);
    mPrevButton.setOnClickListener(mPrevListener);
    mPrevButton.setRepeatListener(mRewListener, 260);
    mPauseButton = (ImageButton) findViewById(R.id.pause);
    mPauseButton.requestFocus();
    mPauseButton.setOnClickListener(mPauseListener);
    mNextButton = (RepeatingImageButton) findViewById(R.id.next);
    mNextButton.setOnClickListener(mNextListener);
    mNextButton.setRepeatListener(mFfwdListener, 260);
    seekmethod = 1;

    mDeviceHasDpad = (getResources().getConfiguration().navigation == Configuration.NAVIGATION_DPAD);

    mQueueButton = (ImageButton) findViewById(R.id.curplaylist);
    mQueueButton.setOnClickListener(mQueueListener);
    mShuffleButton = ((ImageButton) findViewById(R.id.shuffle));
    mShuffleButton.setOnClickListener(mShuffleListener);
    mRepeatButton = ((ImageButton) findViewById(R.id.repeat));
    mRepeatButton.setOnClickListener(mRepeatListener);

    if (mProgress instanceof SeekBar) {
        SeekBar seeker = (SeekBar) mProgress;
        seeker.setOnSeekBarChangeListener(mSeekListener);
    }
    mProgress.setMax(1000);

    mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop();

    badSymptoms = new BadSymptoms(this);
}

From source file:com.android.app.MediaPlaybackActivity.java

/**
 * Called when the activity is first created.
 *//*from  w  ww . j a v a  2  s  .  co m*/
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    mAlbumArtWorker = new Worker("album art worker");
    mAlbumArtHandler = new AlbumArtHandler(mAlbumArtWorker.getLooper());

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.audio_player);

    mCurrentTime = (TextView) findViewById(R.id.currenttime);
    mTotalTime = (TextView) findViewById(R.id.totaltime);
    mProgress = (SeekBar) findViewById(R.id.seekbar_playback);
    mAlbum = (ImageView) findViewById(R.id.album);
    mArtistName = (TextView) findViewById(R.id.artistname);
    mAlbumName = (TextView) findViewById(R.id.albumname);
    mTrackName = (TextView) findViewById(R.id.trackname);

    View v = (View) mArtistName.getParent();
    v.setOnTouchListener(this);
    v.setOnLongClickListener(this);

    v = (View) mAlbumName.getParent();
    v.setOnTouchListener(this);
    v.setOnLongClickListener(this);

    v = (View) mTrackName.getParent();
    v.setOnTouchListener(this);
    v.setOnLongClickListener(this);

    mPrevButton = (RepeatingImageButton) findViewById(R.id.prev);
    mPrevButton.setOnClickListener(mPrevListener);
    mPrevButton.setRepeatListener(mRewListener, 260);
    mPauseButton = (ImageButton) findViewById(R.id.pause);
    mPauseButton.requestFocus();
    mPauseButton.setOnClickListener(mPauseListener);
    mNextButton = (RepeatingImageButton) findViewById(R.id.next);
    mNextButton.setOnClickListener(mNextListener);
    mNextButton.setRepeatListener(mFfwdListener, 260);
    seekmethod = 1;

    mDeviceHasDpad = (getResources().getConfiguration().navigation == Configuration.NAVIGATION_DPAD);

    mQueueButton = (ImageButton) findViewById(R.id.curplaylist);
    mQueueButton.setOnClickListener(mQueueListener);
    mShuffleButton = ((ImageButton) findViewById(R.id.shuffle));
    mShuffleButton.setOnClickListener(mShuffleListener);
    mRepeatButton = ((ImageView) findViewById(R.id.repeat));
    mRepeatButton.setOnClickListener(mRepeatListener);

    mIndicator_left = (ImageView) findViewById(R.id.indicator_circle_1);
    mIndicator_right = (ImageView) findViewById(R.id.indicator_circle_2);
    mIndicator_right.setEnabled(false);
    mTitleBack = (ImageButton) findViewById(R.id.title_back);
    mTitleBack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    mTitlePlaylist = (ImageButton) findViewById(R.id.title_playlist);
    mTitlePlaylist.setOnClickListener(mQueueListener);
    mTitlePlaying = (TextView) findViewById(R.id.title_playing);

    playlistPlayback = (ImageView) findViewById(R.id.playlist_iv_playback);
    playlistPlayback.setOnClickListener(mShowPlaylistListener);

    if (mProgress instanceof SeekBar) {
        SeekBar seeker = (SeekBar) mProgress;
        seeker.setOnSeekBarChangeListener(mSeekListener);
    }
    mProgress.setMax(1000);

    mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop();

    mViewPager = (ViewPager) findViewById(R.id.vp_play_container);
    initViewPagerContent();
    //        mViewPager.setPageTransformer(true, new PlayPageTransformer());
    //        mPagerIndicator.create(mViewPagerContent.size());
    mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            if (position == 0) {
                mIndicator_left.setEnabled(true);
                mIndicator_right.setEnabled(false);
            } else if (position == 1) {
                mIndicator_left.setEnabled(false);
                mIndicator_right.setEnabled(true);
            }
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });
    mViewPager.setAdapter(mPagerAdapter);
}

From source file:net.sourceforge.servestream.activity.MediaPlayerActivity.java

/** Called when the activity is first created. */
@Override/* w w w.j a  v a  2  s.co  m*/
public void onCreate(Bundle icicle) {
    setTheme(UserPreferences.getTheme());
    super.onCreate(icicle);
    setContentView(R.layout.activity_media_player);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    //actionBar.setDisplayShowCustomEnabled(true);
    //actionBar.setDisplayShowTitleEnabled(false);

    LayoutInflater inflater = getLayoutInflater();
    View v = inflater.inflate(R.layout.action_bar_media_player_header, null);

    //actionBar.setCustomView(v);

    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mPreferences.registerOnSharedPreferenceChangeListener(this);

    mCurrentTime = (TextView) findViewById(R.id.position_text);
    mTotalTime = (TextView) findViewById(R.id.duration_text);
    mProgress = (ProgressBar) findViewById(R.id.seek_bar);

    mPrevButton = (RepeatingImageButton) findViewById(R.id.previous_button);
    mPrevButton.setOnClickListener(mPrevListener);
    mPrevButton.setRepeatListener(mRewListener, 260);
    mPauseButton = (ImageButton) findViewById(R.id.play_pause_button);
    mPauseButton.setOnClickListener(mPauseListener);
    mNextButton = (RepeatingImageButton) findViewById(R.id.next_button);
    mNextButton.setOnClickListener(mNextListener);
    mNextButton.setRepeatListener(mFfwdListener, 260);
    seekmethod = 1;

    mDeviceHasDpad = (getResources().getConfiguration().navigation == Configuration.NAVIGATION_DPAD);

    mShuffleButton = (ImageButton) findViewById(R.id.shuffle_button);
    mShuffleButton.setOnClickListener(mShuffleListener);
    mRepeatButton = (ImageButton) findViewById(R.id.repeat_button);
    mRepeatButton.setOnClickListener(mRepeatListener);

    if (mProgress instanceof SeekBar) {
        SeekBar seeker = (SeekBar) mProgress;
        seeker.setOnSeekBarChangeListener(mSeekListener);
    }
    mProgress.setMax(1000);

    mPager = (ViewPager) findViewById(R.id.pager);
}

From source file:org.mariotaku.harmony.activity.MusicPlaybackActivity.java

/** Called when the activity is first created. */
@Override/*from   w  w  w .  j a  v  a2s. com*/
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mImageLoader = HarmonyApplication.getInstance(this).getImageLoaderWrapper();
    mPreferences = new PreferencesEditor(this);
    mRefreshRunnable = new RefreshRunnable(this);
    mHideActionBarRunnable = new HideActionBarRunnable(this);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    setContentView(R.layout.music_playback);
    mActionBar = getActionBar();
    mActionBar.addOnMenuVisibilityListener(this);
    mActionBar.hide();

    mSeekBar.setMax(1000);
    mSeekBar.setOnSeekBarChangeListener(this);

    mPlayPauseButton.setOnClickListener(this);
    mPrevButton.setOnClickListener(this);
    mNextButton.setOnClickListener(this);

    mPrevButton.setRepeatListener(this, 260);
    mNextButton.setRepeatListener(this, 260);

    mDeviceHasDpad = getResources().getConfiguration().navigation == Configuration.NAVIGATION_DPAD;
    mGestureDector = new GestureDetector(this, this);
    mPlaybackContainer.setTouchInterceptor(this);

    mAdapter = new PagerAdapter(this);
    mViewPager.setAdapter(mAdapter);
    mAdapter.addFragment(QueueFragment.class);
    mAdapter.addFragment(Fragment.class);
    mAdapter.addFragment(LyricsFragment.class);
    mViewPager.setOnPageChangeListener(this);
    mViewPager.setOffscreenPageLimit(3);
    mViewPager.setCurrentItem(1, false);
}

From source file:org.musicmod.android.app.MusicPlaybackActivity.java

private void configureActivity() {

    setContentView(R.layout.music_playback);

    ActionBarCompat mActionBar = getActionBarCompat();

    mActionBar.setCustomView(R.layout.actionbar_music_playback);
    mActionBar.setDisplayShowCustomEnabled(true);
    mActionBar.setDisplayShowTitleEnabled(false);

    View mCustomView = mActionBar.getCustomView();

    mProgress = (ProgressBar) mCustomView.findViewById(android.R.id.progress);
    mTouchPaintView = (TouchPaintView) mCustomView.findViewById(R.id.touch_paint);
    mTouchPaintView.setEventListener(mTouchPaintEventListener);

    mTrackName = (TextView) mCustomView.findViewById(R.id.track_name);
    mTrackDetail = (TextView) mCustomView.findViewById(R.id.track_detail);

    mCurrentTime = (TextView) mCustomView.findViewById(R.id.current_time);
    mTotalTime = (TextView) mCustomView.findViewById(R.id.total_time);

    /*//from  w ww  .  j  a  va  2 s.c  om
    mAlbum.setOnClickListener(mQueueListener);
    mAlbum.setOnLongClickListener(mSearchAlbumArtListener);
     */

    mPrevButton = (RepeatingImageButton) findViewById(R.id.prev);
    mPrevButton.setBackgroundDrawable(
            new ButtonStateDrawable(new Drawable[] { getResources().getDrawable(R.drawable.btn_mp_playback) }));
    mPrevButton.setOnClickListener(mPrevListener);
    mPrevButton.setRepeatListener(mRewListener, 260);

    mPauseButton = (ImageButton) findViewById(R.id.pause);
    mPauseButton.setBackgroundDrawable(
            new ButtonStateDrawable(new Drawable[] { getResources().getDrawable(R.drawable.btn_mp_playback) }));
    mPauseButton.requestFocus();
    mPauseButton.setOnClickListener(mPauseListener);

    mNextButton = (RepeatingImageButton) findViewById(R.id.next);
    mNextButton.setBackgroundDrawable(
            new ButtonStateDrawable(new Drawable[] { getResources().getDrawable(R.drawable.btn_mp_playback) }));
    mNextButton.setOnClickListener(mNextListener);
    mNextButton.setRepeatListener(mFfwdListener, 260);

    mDeviceHasDpad = (getResources().getConfiguration().navigation == Configuration.NAVIGATION_DPAD);

    mVisualizerViewFftSpectrum = new VisualizerViewFftSpectrum(this);
    mVisualizerViewWaveForm = new VisualizerViewWaveForm(this);
    mVisualizerView = (FrameLayout) findViewById(R.id.visualizer_view);

    if (mProgress instanceof SeekBar) {
        SeekBar seeker = (SeekBar) mProgress;
        seeker.setOnSeekBarChangeListener(mSeekListener);
    }
    mProgress.setMax(1000);

    if (findViewById(R.id.albumart_frame) != null) {
        getSupportFragmentManager().beginTransaction().replace(R.id.albumart_frame, new AlbumArtFragment())
                .commit();
    }

    mQueueFragment = new TrackFragment();
    Bundle bundle = new Bundle();
    bundle.putString(INTENT_KEY_TYPE, MediaStore.Audio.Playlists.CONTENT_TYPE);
    bundle.putLong(MediaStore.Audio.Playlists._ID, PLAYLIST_QUEUE);
    mQueueFragment.setArguments(bundle);

    mAdapter = new PagerAdapter(getSupportFragmentManager());
    mAdapter.addFragment(new LyricsAndQueueFragment());
    mAdapter.addFragment(mQueueFragment);

    mViewPager = (ViewPager) findViewById(R.id.playback_frame);
    mViewPager.setAdapter(mAdapter);

}

From source file:org.yammp.app.MusicPlaybackActivity.java

private void configureActivity() {

    setContentView(R.layout.music_playback);

    ActionBar mActionBar = getSupportActionBar();

    mActionBar.setCustomView(R.layout.actionbar_music_playback);
    mActionBar.setDisplayShowCustomEnabled(true);
    mActionBar.setDisplayShowTitleEnabled(false);

    View mCustomView = mActionBar.getCustomView();

    mTouchPaintView = (TouchPaintView) mCustomView.findViewById(R.id.touch_paint);
    mTouchPaintView.setEventListener(mTouchPaintEventListener);

    mTrackName = (TextView) mCustomView.findViewById(R.id.track_name);
    mTrackDetail = (TextView) mCustomView.findViewById(R.id.track_detail);

    mCurrentTime = (TextView) mCustomView.findViewById(R.id.current_time);
    mTotalTime = (TextView) mCustomView.findViewById(R.id.total_time);

    /*/*from   ww  w.j ava  2 s  .c  o  m*/
     * mAlbum.setOnClickListener(mQueueListener);
     * mAlbum.setOnLongClickListener(mSearchAlbumArtListener);
     */

    mPrevButton = (RepeatingImageButton) findViewById(R.id.prev);
    mPrevButton.setBackgroundDrawable(
            new ButtonStateDrawable(new Drawable[] { getResources().getDrawable(R.drawable.btn_mp_playback) }));
    mPrevButton.setOnClickListener(mPrevListener);
    mPrevButton.setRepeatListener(mRewListener, 260);

    mPauseButton = (ImageButton) findViewById(R.id.pause);
    mPauseButton.setBackgroundDrawable(
            new ButtonStateDrawable(new Drawable[] { getResources().getDrawable(R.drawable.btn_mp_playback) }));
    mPauseButton.requestFocus();
    mPauseButton.setOnClickListener(mPauseListener);

    mNextButton = (RepeatingImageButton) findViewById(R.id.next);
    mNextButton.setBackgroundDrawable(
            new ButtonStateDrawable(new Drawable[] { getResources().getDrawable(R.drawable.btn_mp_playback) }));
    mNextButton.setOnClickListener(mNextListener);
    mNextButton.setRepeatListener(mFfwdListener, 260);

    mDeviceHasDpad = getResources().getConfiguration().navigation == Configuration.NAVIGATION_DPAD;

    mVisualizerViewFftSpectrum = new VisualizerViewFftSpectrum(this);
    mVisualizerViewWaveForm = new VisualizerViewWaveForm(this);
    mVisualizerView = (FrameLayout) findViewById(R.id.visualizer_view);

    if (findViewById(R.id.albumart_frame) != null) {
        getSupportFragmentManager().beginTransaction().replace(R.id.albumart_frame, new AlbumArtFragment())
                .commit();
    }

    mQueueFragment = new TrackFragment();
    Bundle bundle = new Bundle();
    bundle.putString(INTENT_KEY_TYPE, MediaStore.Audio.Playlists.CONTENT_TYPE);
    bundle.putLong(MediaStore.Audio.Playlists._ID, PLAYLIST_QUEUE);
    mQueueFragment.setArguments(bundle);

    mAdapter = new PagerAdapter(getSupportFragmentManager());
    mAdapter.addFragment(new LyricsAndQueueFragment());
    mAdapter.addFragment(mQueueFragment);

    mViewPager = (ViewPager) findViewById(R.id.playback_frame);
    mViewPager.setAdapter(mAdapter);

}

From source file:com.vuze.android.remote.AndroidUtils.java

public static boolean usesNavigationControl() {
    Configuration configuration = VuzeRemoteApp.getContext().getResources().getConfiguration();
    if (configuration.navigation == Configuration.NAVIGATION_NONAV) {
        return false;
    } else if (configuration.touchscreen == Configuration.TOUCHSCREEN_FINGER) {
        return false;
    } else if (configuration.navigation == Configuration.NAVIGATION_DPAD) {
        return true;
    } else if (configuration.touchscreen == Configuration.TOUCHSCREEN_NOTOUCH) {
        return true;
    } else if (configuration.touchscreen == Configuration.TOUCHSCREEN_UNDEFINED) {
        return true;
    } else if (configuration.navigationHidden == Configuration.NAVIGATIONHIDDEN_YES) {
        return true;
    } else if (configuration.uiMode == Configuration.UI_MODE_TYPE_TELEVISION) {
        return true;
    }// w w w. j  ava2  s . co m
    return false;
}

From source file:es.javocsoft.android.lib.toolbox.ToolBox.java

/**
 * Return TRUE if there is a hardware DPAD navigation button.
 * /*ww w. j  a  v  a2 s .c o  m*/
 * @param context
 * @return
 */
public static boolean device_isHardwareDPAD(Context context) {
    //You can also get some of the features which are not testable by the PackageManager via the Configuration, e.g. the DPAD.
    Configuration c = context.getResources().getConfiguration();
    if (c.navigation == Configuration.NAVIGATION_DPAD) {
        return true;
    } else {
        return false;
    }
}

From source file:com.miz.functions.MizLib.java

/**
 * Determines if the device uses navigation controls as the primary navigation from a number of factors.
 * @param context Application Context/*www.  j av a2  s  .  com*/
 * @return True if the device uses navigation controls, false otherwise.
 */
public static boolean usesNavigationControl(Context context) {
    Configuration configuration = context.getResources().getConfiguration();
    if (configuration.navigation == Configuration.NAVIGATION_NONAV) {
        return false;
    } else if (configuration.touchscreen == Configuration.TOUCHSCREEN_FINGER) {
        return false;
    } else if (configuration.navigation == Configuration.NAVIGATION_DPAD) {
        return true;
    } else if (configuration.touchscreen == Configuration.TOUCHSCREEN_NOTOUCH) {
        return true;
    } else if (configuration.touchscreen == Configuration.TOUCHSCREEN_UNDEFINED) {
        return true;
    } else if (configuration.navigationHidden == Configuration.NAVIGATIONHIDDEN_YES) {
        return true;
    } else if (configuration.uiMode == Configuration.UI_MODE_TYPE_TELEVISION) {
        return true;
    }
    return false;
}