Search in sources :

Example 91 with ActionBar

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());
}
Also used : SlidingUpPanelLayout(com.sothree.slidinguppanel.SlidingUpPanelLayout) SystemBarTintManager(com.readystatesoftware.systembartint.SystemBarTintManager) QueueFragment(com.simplecity.amp_library.ui.fragments.QueueFragment) View(android.view.View) FolderFragment(com.simplecity.amp_library.ui.fragments.FolderFragment) Fragment(android.support.v4.app.Fragment) QueuePagerFragment(com.simplecity.amp_library.ui.fragments.QueuePagerFragment) PlayerFragment(com.simplecity.amp_library.ui.fragments.PlayerFragment) QueueFragment(com.simplecity.amp_library.ui.fragments.QueueFragment) AlbumArtistFragment(com.simplecity.amp_library.ui.fragments.AlbumArtistFragment) NavigationDrawerFragment(com.simplecity.amp_library.ui.fragments.NavigationDrawerFragment) PlaylistFragment(com.simplecity.amp_library.ui.fragments.PlaylistFragment) GenreFragment(com.simplecity.amp_library.ui.fragments.GenreFragment) DetailFragment(com.simplecity.amp_library.ui.fragments.DetailFragment) SuggestedFragment(com.simplecity.amp_library.ui.fragments.SuggestedFragment) MainFragment(com.simplecity.amp_library.ui.fragments.MainFragment) AlbumFragment(com.simplecity.amp_library.ui.fragments.AlbumFragment) MiniPlayerFragment(com.simplecity.amp_library.ui.fragments.MiniPlayerFragment) SuppressLint(android.annotation.SuppressLint) LinearLayout(android.widget.LinearLayout) ActionBar(android.support.v7.app.ActionBar) PlayerFragment(com.simplecity.amp_library.ui.fragments.PlayerFragment) MiniPlayerFragment(com.simplecity.amp_library.ui.fragments.MiniPlayerFragment) SuppressLint(android.annotation.SuppressLint)

Example 92 with ActionBar

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();
}
Also used : ValueAnimator(android.animation.ValueAnimator) ActionBar(android.support.v7.app.ActionBar) SuppressLint(android.annotation.SuppressLint)

Example 93 with ActionBar

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;
}
Also used : Bitmap(android.graphics.Bitmap) ColorDrawable(android.graphics.drawable.ColorDrawable) FilterableStateListDrawable(com.simplecity.amp_library.ui.views.FilterableStateListDrawable) Drawable(android.graphics.drawable.Drawable) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) MainActivity(com.simplecity.amp_library.ui.activities.MainActivity) ActivityManager(android.app.ActivityManager) ActionBar(android.support.v7.app.ActionBar) SuppressLint(android.annotation.SuppressLint)

Example 94 with ActionBar

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);
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) ActionBar(android.app.ActionBar)

Example 95 with ActionBar

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();
}
Also used : MediaRouteSelector(android.support.v7.media.MediaRouteSelector) ColorDrawable(android.graphics.drawable.ColorDrawable) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) View(android.view.View) ActionBar(android.support.v7.app.ActionBar)

Aggregations

ActionBar (android.support.v7.app.ActionBar)784 View (android.view.View)248 Toolbar (android.support.v7.widget.Toolbar)214 TextView (android.widget.TextView)160 Intent (android.content.Intent)118 ImageView (android.widget.ImageView)76 AppCompatActivity (android.support.v7.app.AppCompatActivity)66 RecyclerView (android.support.v7.widget.RecyclerView)57 AdapterView (android.widget.AdapterView)52 Bundle (android.os.Bundle)49 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)49 ListView (android.widget.ListView)44 ColorDrawable (android.graphics.drawable.ColorDrawable)33 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)32 ViewPager (android.support.v4.view.ViewPager)29 ArrayList (java.util.ArrayList)29 SharedPreferences (android.content.SharedPreferences)28 Fragment (android.support.v4.app.Fragment)28 MenuItem (android.view.MenuItem)28 BindView (butterknife.BindView)28