use of android.support.v7.app.ActionBar in project Shuttle by timusus.
the class MainActivity method onCreate.
@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
if (!ShuttleUtils.isUpgraded() && !ShuttleUtils.isAmazonBuild()) {
IabManager.getInstance();
}
ThemeUtils.setTheme(this);
if (!ShuttleUtils.hasLollipop() && ShuttleUtils.hasKitKat()) {
getWindow().setFlags(FLAG_TRANSLUCENT_STATUS, FLAG_TRANSLUCENT_STATUS);
mTintManager = new SystemBarTintManager(this);
}
if (ShuttleUtils.hasLollipop()) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
getWindow().setStatusBarColor(Color.TRANSPARENT);
}
if (SettingsManager.getInstance().canTintNavBar()) {
getWindow().setNavigationBarColor(ColorUtils.getPrimaryColorDark(this));
}
supportRequestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
// Now call super to ensure the theme was properly set
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mIsSlidingEnabled = getResources().getBoolean(R.bool.isSlidingEnabled);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mDummyStatusBar = (FrameLayout) findViewById(R.id.dummyStatusBar);
if (ShuttleUtils.hasKitKat()) {
mDummyStatusBar.setVisibility(View.VISIBLE);
mDummyStatusBar.setBackgroundColor(ColorUtils.getPrimaryColorDark(this));
LinearLayout.LayoutParams statusBarParams = new LinearLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, (int) ActionBarUtils.getStatusBarHeight(this));
mDummyStatusBar.setLayoutParams(statusBarParams);
}
setSupportActionBar(mToolbar);
ThemeUtils.themeStatusBar(this, mTintManager);
mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
mTitle = getString(R.string.library_title);
mDrawerLayout = (CustomDrawerLayout) findViewById(R.id.drawer_layout);
if (ShuttleUtils.hasLollipop() && ShuttleUtils.hasKitKat()) {
getWindow().setStatusBarColor(Color.TRANSPARENT);
}
mDrawerLayout.setStatusBarBackgroundColor(ShuttleUtils.hasLollipop() ? ColorUtils.getPrimaryColorDark(this) : ColorUtils.getPrimaryColor());
mNavigationDrawerFragment.setup((DrawerLayout) findViewById(R.id.drawer_layout));
if (mIsSlidingEnabled) {
mSlidingUpPanelLayout = (SlidingUpPanelLayout) findViewById(R.id.container);
setDragView(null, false);
//The second panel slide offset is mini player height + toolbar height + status bar height.
//This gets our 'up next' sitting snugly underneath the toolbar
int offset = (int) (ActionBarUtils.getActionBarHeight(this) + (ShuttleUtils.hasKitKat() ? ActionBarUtils.getStatusBarHeight(this) : 0) - getResources().getDimension(R.dimen.mini_player_height));
mSlidingUpPanelLayout.setSlidePanelOffset(-offset);
mSlidingUpPanelLayout.hidePanel();
mSlidingUpPanelLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View panel, float slideOffset) {
setActionBarAlpha(slideOffset, false);
boolean canChangeElevation = true;
Fragment playingFragment = getSupportFragmentManager().findFragmentById(R.id.player_container);
if (playingFragment != null) {
Fragment childFragment = playingFragment.getChildFragmentManager().findFragmentById(R.id.queue_container);
if (childFragment != null && childFragment instanceof QueueFragment) {
canChangeElevation = false;
}
}
if (canChangeElevation) {
getSupportActionBar().setElevation(ResourceUtils.toPixels(4) * slideOffset);
}
mNavigationDrawerFragment.animateDrawerToggle(slideOffset);
}
@Override
public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) {
switch(newState) {
case COLLAPSED:
{
setDragView(null, false);
mTitle = getString(R.string.library_title);
supportInvalidateOptionsMenu();
toggleQueue(false);
mNavigationDrawerFragment.toggleDrawerLock(false);
break;
}
case EXPANDED:
{
Fragment playerFragment = getSupportFragmentManager().findFragmentById(R.id.player_container);
if (playerFragment != null && playerFragment instanceof PlayerFragment) {
setDragView(((PlayerFragment) playerFragment).getDragView(), true);
if (((PlayerFragment) playerFragment).isQueueShowing()) {
toggleQueue(true);
}
}
mTitle = getString(R.string.nowplaying_title);
supportInvalidateOptionsMenu();
mNavigationDrawerFragment.toggleDrawerLock(true);
break;
}
}
}
});
}
if (savedInstanceState != null && mIsSlidingEnabled) {
if (savedInstanceState.getBoolean(ARG_EXPANDED, false)) {
final ActionBar actionBar = getSupportActionBar();
//If the sliding panel was previously expanded, expand it again.
mSlidingUpPanelLayout.post(() -> {
mSlidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED, false);
setActionBarAlpha(1f, false);
});
mTitle = getString(R.string.nowplaying_title);
if (actionBar != null) {
actionBar.setTitle(mTitle);
}
Fragment playingFragment = getSupportFragmentManager().findFragmentById(R.id.player_container);
if (playingFragment != null) {
Fragment childFragment = playingFragment.getChildFragmentManager().findFragmentById(R.id.queue_container);
if (childFragment != null && childFragment instanceof QueueFragment) {
toggleQueue(true);
}
}
}
}
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction().add(R.id.main_container, MainFragment.newInstance()).commit();
getSupportFragmentManager().beginTransaction().add(R.id.mini_player_container, MiniPlayerFragment.newInstance()).commit();
if (mIsSlidingEnabled) {
getSupportFragmentManager().beginTransaction().add(R.id.player_container, PlayerFragment.newInstance()).commit();
}
}
themeTaskDescription();
handleIntent(getIntent());
}
use of android.support.v7.app.ActionBar in project Shuttle by timusus.
the class MainActivity method animateElevationChange.
private void animateElevationChange(int currentElevationDips, int targetElevationDips) {
currentElevationDips = ResourceUtils.toPixels(currentElevationDips);
targetElevationDips = ResourceUtils.toPixels(targetElevationDips);
final ActionBar actionBar = getSupportActionBar();
if (actionBar == null) {
return;
}
ValueAnimator valueAnimator = ValueAnimator.ofInt(currentElevationDips, targetElevationDips);
valueAnimator.setIntValues(currentElevationDips, targetElevationDips);
valueAnimator.addUpdateListener(animation -> {
int value = (Integer) animation.getAnimatedValue();
actionBar.setElevation(value);
});
valueAnimator.setDuration(250);
valueAnimator.start();
}
use of android.support.v7.app.ActionBar in project Shuttle by timusus.
the class ThemeUtils method themeActionBar.
@SuppressLint("NewApi")
public static Drawable themeActionBar(AppCompatActivity activity) {
if (activity == null) {
return null;
}
if (ShuttleUtils.hasLollipop()) {
Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(), R.mipmap.ic_launcher);
if (bitmap != null) {
ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(null, bitmap, ColorUtils.getPrimaryColor());
activity.setTaskDescription(td);
bitmap.recycle();
}
}
if (ThemeUtils.getInstance().themeType == ThemeType.TYPE_LIGHT || ThemeUtils.getInstance().themeType == ThemeType.TYPE_DARK) {
activity.getSupportActionBar().setBackgroundDrawable(DrawableUtils.getColoredDrawable(activity, CompatUtils.getDrawableCompat(activity, R.drawable.ab_transparent)));
}
if (activity instanceof MainActivity || isActionBarSolid(activity)) {
ActionBar actionBar = activity.getSupportActionBar();
Drawable actionBarDrawable = DrawableUtils.getColoredDrawable(activity, CompatUtils.getDrawableCompat(activity, R.drawable.action_bar_bg));
actionBar.setBackgroundDrawable(actionBarDrawable);
return actionBarDrawable;
}
return null;
}
use of android.support.v7.app.ActionBar in project platform_frameworks_base by android.
the class NekoLand method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.neko_activity);
final ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setLogo(Cat.create(this));
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayShowHomeEnabled(true);
}
mPrefs = new PrefState(this);
mPrefs.setListener(this);
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.holder);
mAdapter = new CatAdapter();
recyclerView.setAdapter(mAdapter);
recyclerView.setLayoutManager(new GridLayoutManager(this, 3));
int numCats = updateCats();
MetricsLogger.histogram(this, "egg_neko_visit_gallery", numCats);
}
use of android.support.v7.app.ActionBar in project CastHelloText-android-v2 by googlecast.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ActionBar actionBar = getSupportActionBar();
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
// When the user clicks on the button, use Android voice recognition to
// get text
Button voiceButton = (Button) findViewById(R.id.voiceButton);
voiceButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startVoiceRecognitionActivity();
}
});
// Configure Cast device discovery
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
mMediaRouteSelector = new MediaRouteSelector.Builder().addControlCategory(CastMediaControlIntent.categoryForCast(getResources().getString(R.string.app_id))).build();
mMediaRouterCallback = new MyMediaRouterCallback();
}
Aggregations