Search in sources :

Example 11 with Toolbar

use of android.widget.Toolbar in project android_frameworks_base by ResurrectionRemix.

the class DrawerController method create.

/**
     * Returns a controller suitable for {@code Layout}.
     */
static DrawerController create(Activity activity) {
    DrawerLayout layout = (DrawerLayout) activity.findViewById(R.id.drawer_layout);
    if (layout == null) {
        return new DummyDrawerController();
    }
    View drawer = activity.findViewById(R.id.drawer_roots);
    Toolbar toolbar = (Toolbar) activity.findViewById(R.id.roots_toolbar);
    drawer.getLayoutParams().width = calculateDrawerWidth(activity);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(activity, layout, R.drawable.ic_hamburger, R.string.drawer_open, R.string.drawer_close);
    return new RuntimeDrawerController(layout, drawer, toggle, toolbar);
}
Also used : ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) View(android.view.View) Toolbar(android.widget.Toolbar)

Example 12 with Toolbar

use of android.widget.Toolbar in project android_frameworks_base by ResurrectionRemix.

the class SettingsDrawerActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    long startTime = System.currentTimeMillis();
    TypedArray theme = getTheme().obtainStyledAttributes(android.R.styleable.Theme);
    if (!theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
        getWindow().addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
    }
    super.setContentView(R.layout.settings_with_drawer);
    mContentHeaderContainer = (FrameLayout) findViewById(R.id.content_header_container);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (mDrawerLayout == null) {
        return;
    }
    Toolbar toolbar = (Toolbar) findViewById(R.id.action_bar);
    if (theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
        toolbar.setVisibility(View.GONE);
        if (isDrawerEnabled()) {
            mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
            mDrawerLayout = null;
            return;
        }
    }
    getDashboardCategories();
    setActionBar(toolbar);
    mDrawerAdapter = new SettingsDrawerAdapter(this);
    ListView listView = (ListView) findViewById(R.id.left_drawer);
    if (isHeaderEnabled()) {
        View header = getLayoutInflater().inflate(R.layout.header, null);
        listView.addHeaderView(header, null, false);
    }
    listView.setAdapter(mDrawerAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        public void onItemClick(android.widget.AdapterView<?> parent, View view, int position, long id) {
            if (isHeaderEnabled()) {
                position = position - 1;
                mOpenTileFromLeftDrawer = true;
            }
            onTileClicked(mDrawerAdapter.getTile(position));
        }
    });
    mUserManager = UserManager.get(this);
    if (DEBUG_TIMING)
        Log.d(TAG, "onCreate took " + (System.currentTimeMillis() - startTime) + " ms");
}
Also used : ListView(android.widget.ListView) TypedArray(android.content.res.TypedArray) AdapterView(android.widget.AdapterView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Toolbar(android.widget.Toolbar)

Example 13 with Toolbar

use of android.widget.Toolbar in project android_frameworks_base by crdroidandroid.

the class SettingsDrawerActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    long startTime = System.currentTimeMillis();
    TypedArray theme = getTheme().obtainStyledAttributes(android.R.styleable.Theme);
    if (!theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
        getWindow().addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
    }
    super.setContentView(R.layout.settings_with_drawer);
    mContentHeaderContainer = (FrameLayout) findViewById(R.id.content_header_container);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (mDrawerLayout == null) {
        return;
    }
    Toolbar toolbar = (Toolbar) findViewById(R.id.action_bar);
    if (theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
        toolbar.setVisibility(View.GONE);
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
        mDrawerLayout = null;
        return;
    }
    getDashboardCategories();
    setActionBar(toolbar);
    mDrawerAdapter = new SettingsDrawerAdapter(this);
    ListView listView = (ListView) findViewById(R.id.left_drawer);
    listView.setAdapter(mDrawerAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        public void onItemClick(android.widget.AdapterView<?> parent, View view, int position, long id) {
            mOpenTileFromLeftDrawer = true;
            onTileClicked(mDrawerAdapter.getTile(position));
        }
    });
    mUserManager = UserManager.get(this);
    if (DEBUG_TIMING)
        Log.d(TAG, "onCreate took " + (System.currentTimeMillis() - startTime) + " ms");
}
Also used : ListView(android.widget.ListView) TypedArray(android.content.res.TypedArray) AdapterView(android.widget.AdapterView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Toolbar(android.widget.Toolbar)

Example 14 with Toolbar

use of android.widget.Toolbar in project android_frameworks_base by crdroidandroid.

the class DrawerController method create.

/**
     * Returns a controller suitable for {@code Layout}.
     */
static DrawerController create(Activity activity) {
    DrawerLayout layout = (DrawerLayout) activity.findViewById(R.id.drawer_layout);
    if (layout == null) {
        return new DummyDrawerController();
    }
    View drawer = activity.findViewById(R.id.drawer_roots);
    Toolbar toolbar = (Toolbar) activity.findViewById(R.id.roots_toolbar);
    drawer.getLayoutParams().width = calculateDrawerWidth(activity);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(activity, layout, R.drawable.ic_hamburger, R.string.drawer_open, R.string.drawer_close);
    return new RuntimeDrawerController(layout, drawer, toggle, toolbar);
}
Also used : ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) View(android.view.View) Toolbar(android.widget.Toolbar)

Aggregations

Toolbar (android.widget.Toolbar)14 View (android.view.View)11 TypedArray (android.content.res.TypedArray)5 ActionBarDrawerToggle (android.support.v4.app.ActionBarDrawerToggle)5 DrawerLayout (android.support.v4.widget.DrawerLayout)5 AdapterView (android.widget.AdapterView)5 ListView (android.widget.ListView)5 TextView (android.widget.TextView)2 Activity (android.app.Activity)1 ActivityOptions (android.app.ActivityOptions)1 SharedElementCallback (android.app.SharedElementCallback)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 SpannableString (android.text.SpannableString)1 DisplayMetrics (android.util.DisplayMetrics)1 MenuItem (android.view.MenuItem)1 LayoutParams (android.view.ViewGroup.LayoutParams)1 ImageView (android.widget.ImageView)1 BindView (butterknife.BindView)1 SettingsActivity (com.android.settings.SettingsActivity)1