List of usage examples for android.support.v4.app SystemBarTintManager setStatusBarTintResource
public void setStatusBarTintResource(int res)
From source file:com.andreadec.musicplayer.MainActivity.java
@SuppressLint({ "InlinedApi", "NewApi" })
@Override/*from w ww.ja v a 2 s. co m*/
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setVolumeControlStream(AudioManager.STREAM_MUSIC);
preferences = PreferenceManager.getDefaultSharedPreferences(this);
if (preferences.getBoolean(Constants.PREFERENCE_DISABLELOCKSCREEN, Constants.DEFAULT_DISABLELOCKSCREEN)) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); // Disable lock screen for this activity
}
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
if (preferences.getBoolean(Constants.PREFERENCE_SHOWHELPOVERLAYMAINACTIVITY, true)) {
final FrameLayout frameLayout = new FrameLayout(this);
LayoutInflater layoutInflater = getLayoutInflater();
layoutInflater.inflate(R.layout.layout_main, frameLayout);
layoutInflater.inflate(R.layout.layout_helpoverlay_main, frameLayout);
final View overlayView = frameLayout.getChildAt(1);
overlayView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
frameLayout.removeView(overlayView);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean(Constants.PREFERENCE_SHOWHELPOVERLAYMAINACTIVITY, false);
editor.commit();
}
});
setContentView(frameLayout);
} else {
setContentView(R.layout.layout_main);
}
pages = new String[4];
pages[PAGE_BROWSER] = getResources().getString(R.string.browser);
pages[PAGE_PLAYLISTS] = getResources().getString(R.string.playlist);
pages[PAGE_RADIOS] = getResources().getString(R.string.radio);
pages[PAGE_PODCASTS] = getResources().getString(R.string.podcasts);
fragmentManager = getSupportFragmentManager();
setTitle(pages[currentPage]);
/* NAVIGATION DRAWER */
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.drawer_open,
R.string.drawer_close) {
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
setTitle(pages[currentPage]);
}
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
setTitle(getResources().getString(R.string.app_name));
}
};
drawerLayout.setDrawerListener(drawerToggle);
if (Build.VERSION.SDK_INT >= 11)
getActionBar().setDisplayHomeAsUpEnabled(true);
drawerContainer = (RelativeLayout) findViewById(R.id.navigation_container);
drawerList = (ListView) findViewById(R.id.navigation_list);
navigationAdapter = new NavigationDrawerArrayAdapter(this, pages);
drawerList.setAdapter(navigationAdapter);
drawerList.setOnItemClickListener(new ListView.OnItemClickListener() {
@Override
public void onItemClick(@SuppressWarnings("rawtypes") AdapterView parent, View view, int position,
long id) {
openPage(position);
drawerLayout.closeDrawer(drawerContainer);
}
});
buttonQuit = findViewById(R.id.navigation_buttonQuit);
buttonQuit.setOnClickListener(this);
if (Build.VERSION.SDK_INT >= 19) {
// Android 4.4+ only
boolean translucentStatus = preferences.getBoolean(Constants.PREFERENCE_TRANSLUCENTSTATUSBAR,
Constants.DEFAULT_TRANSLUCENTSTATUSBAR);
boolean translucentNavigation = preferences.getBoolean(Constants.PREFERENCE_TRANSLUCENTNAVIGATIONBAR,
Constants.DEFAULT_TRANSLUCENTNAVIGATIONBAR);
if (translucentStatus)
getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
if (translucentNavigation)
getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
SystemBarTintManager tintManager = new SystemBarTintManager(this);
if (translucentStatus) {
tintManager.setStatusBarTintEnabled(true);
tintManager.setStatusBarTintResource(R.color.actionBarBackground);
}
}
textViewArtist = (TextView) findViewById(R.id.textViewArtist);
textViewTitle = (TextView) findViewById(R.id.textViewTitle);
textViewTime = (TextView) findViewById(R.id.textViewTime);
imageViewSongImage = (ImageView) findViewById(R.id.imageViewSongImage);
imageButtonPrevious = (ImageButton) findViewById(R.id.imageButtonPrevious);
imageButtonPlayPause = (ImageButton) findViewById(R.id.imageButtonPlayPause);
imageButtonNext = (ImageButton) findViewById(R.id.imageButtonNext);
seekBar1 = (SeekBar) findViewById(R.id.seekBar1);
seekBar2 = (SeekBar) findViewById(R.id.seekBar2);
imageButtonShowSeekbar2 = (ImageButton) findViewById(R.id.imageButtonShowSeekbar2);
imageButtonShuffle = (ImageButton) findViewById(R.id.imageButtonShuffle);
imageButtonRepeat = (ImageButton) findViewById(R.id.imageButtonRepeat);
imageButtonRepeatAll = (ImageButton) findViewById(R.id.imageButtonRepeatAll);
buttonBassBoost = (Button) findViewById(R.id.buttonBassBoost);
buttonEqualizer = (Button) findViewById(R.id.buttonEqualizer);
buttonShake = (Button) findViewById(R.id.buttonShake);
imageButtonShuffle.setOnClickListener(this);
imageButtonRepeat.setOnClickListener(this);
imageButtonRepeatAll.setOnClickListener(this);
buttonBassBoost.setOnClickListener(this);
buttonEqualizer.setOnClickListener(this);
buttonShake.setOnClickListener(this);
imageButtonShowSeekbar2.setOnClickListener(this);
imageButtonPrevious.setOnClickListener(this);
imageButtonPlayPause.setOnClickListener(this);
imageButtonNext.setOnClickListener(this);
seekBar1.setOnSeekBarChangeListener(this);
seekBar1.setClickable(false);
seekBar2.setOnSeekBarChangeListener(this);
textViewTime.setOnClickListener(this);
showSongImage = preferences.getBoolean(Constants.PREFERENCE_SHOWSONGIMAGE, Constants.DEFAULT_SHOWSONGIMAGE);
imagesCache = new LruCache<String, Bitmap>(Constants.IMAGES_CACHE_SIZE);
serviceIntent = new Intent(this, MusicService.class);
startService(serviceIntent); // Starts the service if it is not running
if (preferences.getBoolean(Constants.PREFERENCE_OPENLASTPAGEONSTART,
Constants.DEFAULT_OPENLASTPAGEONSTART)) {
openPage(preferences.getInt(Constants.PREFERENCE_LASTPAGE, Constants.DEFAULT_LASTPAGE));
} else {
openPage(PAGE_BROWSER);
}
loadSongFromIntent();
layoutPlaybackControls = findViewById(R.id.layoutPlaybackControls);
if (preferences.getBoolean(Constants.PREFERENCE_ENABLEGESTURES, Constants.DEFAULT_ENABLEGESTURES)) {
final GestureDetectorCompat gestureDetector = new GestureDetectorCompat(this,
new PlayerGestureListener());
View layoutTop = findViewById(R.id.layoutTop);
layoutTop.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return gestureDetector.onTouchEvent(event);
}
});
if (preferences.getBoolean(Constants.PREFERENCE_SHOWPLAYBACKCONTROLS,
Constants.DEFAULT_SHOWPLAYBACKCONTROLS)) {
layoutPlaybackControls.setVisibility(View.VISIBLE);
}
} else {
layoutPlaybackControls.setVisibility(View.VISIBLE);
}
}