Search in sources :

Example 36 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project Gadgetbridge by Freeyourgadget.

the class ControlCenterv2 method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (GBApplication.isDarkThemeEnabled()) {
        setTheme(R.style.GadgetbridgeThemeDark_NoActionBar);
    } else {
        setTheme(R.style.GadgetbridgeTheme_NoActionBar);
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_controlcenterv2);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            launchDiscoveryActivity();
        }
    });
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.controlcenter_navigation_drawer_open, R.string.controlcenter_navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    //end of material design boilerplate
    deviceManager = ((GBApplication) getApplication()).getDeviceManager();
    deviceListView = (RecyclerView) findViewById(R.id.deviceListView);
    deviceListView.setHasFixedSize(true);
    deviceListView.setLayoutManager(new LinearLayoutManager(this));
    background = (ImageView) findViewById(R.id.no_items_bg);
    deviceList = deviceManager.getDevices();
    mGBDeviceAdapter = new GBDeviceAdapterv2(this, deviceList);
    deviceListView.setAdapter(this.mGBDeviceAdapter);
    ItemTouchHelper swipeToDismissTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(ItemTouchHelper.LEFT, ItemTouchHelper.RIGHT) {

        @Override
        public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
            if (dX > 50)
                dX = 50;
            super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
        }

        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
            GB.toast(getBaseContext(), "onMove", Toast.LENGTH_LONG, GB.ERROR);
            return false;
        }

        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
            GB.toast(getBaseContext(), "onSwiped", Toast.LENGTH_LONG, GB.ERROR);
        }

        @Override
        public void onChildDrawOver(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
        }
    });
    //uncomment to enable fixed-swipe to reveal more actions
    //swipeToDismissTouchHelper.attachToRecyclerView(deviceListView);
    registerForContextMenu(deviceListView);
    IntentFilter filterLocal = new IntentFilter();
    filterLocal.addAction(GBApplication.ACTION_QUIT);
    filterLocal.addAction(DeviceManager.ACTION_DEVICES_CHANGED);
    LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filterLocal);
    refreshPairedDevices();
    /*
         * Ask for permission to intercept notifications on first run.
         */
    Prefs prefs = GBApplication.getPrefs();
    if (prefs.getBoolean("firstrun", true)) {
        prefs.getPreferences().edit().putBoolean("firstrun", false).apply();
        Intent enableIntent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
        startActivity(enableIntent);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        checkAndRequestPermissions();
    }
    ChangeLog cl = new ChangeLog(this);
    if (cl.isFirstRun()) {
        cl.getLogDialog().show();
    }
    GBApplication.deviceService().start();
    if (GB.isBluetoothEnabled() && deviceList.isEmpty() && Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        startActivity(new Intent(this, DiscoveryActivity.class));
    } else {
        GBApplication.deviceService().requestDeviceInfo();
    }
}
Also used : IntentFilter(android.content.IntentFilter) NavigationView(android.support.design.widget.NavigationView) Canvas(android.graphics.Canvas) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) GBDeviceAdapterv2(nodomain.freeyourgadget.gadgetbridge.adapter.GBDeviceAdapterv2) Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Prefs(nodomain.freeyourgadget.gadgetbridge.util.Prefs) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) FloatingActionButton(android.support.design.widget.FloatingActionButton) RecyclerView(android.support.v7.widget.RecyclerView) ChangeLog(de.cketti.library.changelog.ChangeLog) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 37 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project AndroidChromium by JackyAndroid.

the class SelectionToolbar method initActionBarDrawerToggle.

/**
     * Set up ActionBarDrawerToggle, a.k.a. hamburger button.
     */
private void initActionBarDrawerToggle() {
    // Sadly, the only way to set correct toolbar button listener for ActionBarDrawerToggle
    // is constructing, so we will need to construct every time we re-show this button.
    mActionBarDrawerToggle = new ActionBarDrawerToggle((Activity) getContext(), mDrawerLayout, this, R.string.accessibility_drawer_toggle_btn_open, R.string.accessibility_drawer_toggle_btn_close);
    mDrawerLayout.addDrawerListener(mActionBarDrawerToggle);
    mActionBarDrawerToggle.syncState();
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Activity(android.app.Activity)

Example 38 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project LeafPic by HoraApps.

the class MainActivity method initUI.

private void initUI() {
    /**** TOOLBAR ****/
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    /**** RECYCLER VIEW ****/
    rvAlbums = (RecyclerView) findViewById(R.id.grid_albums);
    rvMedia = ((RecyclerView) findViewById(R.id.grid_photos));
    rvAlbums.setHasFixedSize(true);
    rvAlbums.setItemAnimator(new DefaultItemAnimator());
    rvMedia.setHasFixedSize(true);
    rvMedia.setItemAnimator(new DefaultItemAnimator());
    albumsAdapter = new AlbumsAdapter(getAlbums().dispAlbums, MainActivity.this);
    albumsAdapter.setOnClickListener(albumOnClickListener);
    albumsAdapter.setOnLongClickListener(albumOnLongCLickListener);
    rvAlbums.setAdapter(albumsAdapter);
    mediaAdapter = new MediaAdapter(getAlbum().getMedia(), MainActivity.this);
    mediaAdapter.setOnClickListener(photosOnClickListener);
    mediaAdapter.setOnLongClickListener(photosOnLongClickListener);
    rvMedia.setAdapter(mediaAdapter);
    int spanCount = SP.getInt("n_columns_folders", 2);
    rvAlbumsDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getApplicationContext()), true);
    rvAlbums.addItemDecoration(rvAlbumsDecoration);
    rvAlbums.setLayoutManager(new GridLayoutManager(this, spanCount));
    spanCount = SP.getInt("n_columns_media", 3);
    rvMediaDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getApplicationContext()), true);
    rvMedia.setLayoutManager(new GridLayoutManager(getApplicationContext(), spanCount));
    rvMedia.addItemDecoration(rvMediaDecoration);
    /**** SWIPE TO REFRESH ****/
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setColorSchemeColors(getAccentColor());
    swipeRefreshLayout.setProgressBackgroundColorSchemeColor(getBackgroundColor());
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            if (albumsMode) {
                getAlbums().clearSelectedAlbums();
                new PrepareAlbumTask().execute();
            } else {
                getAlbum().clearSelectedPhotos();
                new PreparePhotosTask().execute();
            }
        }
    });
    /**** DRAWER ****/
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.addDrawerListener(new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) {

        public void onDrawerClosed(View view) {
        //Put your code here
        // materialMenu.animateIconState(MaterialMenuDrawable.IconState.BURGER);
        }

        public void onDrawerOpened(View drawerView) {
        //Put your code here
        //materialMenu.animateIconState(MaterialMenuDrawable.IconState.ARROW);
        }
    });
    /**** FAB ***/
    fabCamera = (FloatingActionButton) findViewById(R.id.fab_camera);
    fabCamera.setImageDrawable(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_camera_alt).color(Color.WHITE));
    fabCamera.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA));
        }
    });
    //region TESTING
    fabCamera.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            // NOTE: this is used to acquire write permission on sd with api 21
            // TODO call this one when unable to write on sd
            requestSdCardPermissions();
            return false;
        }
    });
    //endregion
    setRecentApp(getString(R.string.app_name));
    setupUI();
}
Also used : AlbumsAdapter(org.horaapps.leafpic.adapters.AlbumsAdapter) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) MediaAdapter(org.horaapps.leafpic.adapters.MediaAdapter) Intent(android.content.Intent) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) SearchView(android.support.v7.widget.SearchView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) ScrollView(android.widget.ScrollView) IconicsImageView(com.mikepenz.iconics.view.IconicsImageView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) GridSpacingItemDecoration(org.horaapps.leafpic.views.GridSpacingItemDecoration)

Example 39 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project UltimateAndroid by cymcsg.

the class DemoOfUiActivity method initViews.

private void initViews() {
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    // actionBar.setHomeAsUpIndicator(R.drawable.ic_drawer);
    actionBar.setHomeButtonEnabled(true);
    //        actionBar.setDisplayShowHomeEnabled(false);
    mPlanetTitles = getResources().getStringArray(R.array.items_name);
    mTitle = mDrawerTitle = getTitle();
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            getSupportActionBar().setTitle(mTitle);
            // creates call to onPrepareOptionsMenu()
            invalidateOptionsMenu();
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            getSupportActionBar().setTitle(mDrawerTitle);
            // creates call to onPrepareOptionsMenu()
            invalidateOptionsMenu();
        }
    };
    // Set the drawer toggle as the DrawerListener
    Logs.d("mDrawerLayout  " + (mDrawerLayout != null) + "    " + "mDrawerToggle  " + (mDrawerToggle != null));
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    //mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.CLIP_VERTICAL);
    //mDrawerLayout.setScrimColor(getResources().getColor(R.color.babyBlueColor));
    //        mDrawerList.setAdapter(new ArrayAdapter<String>(this,
    //                R.layout.left_menu, mPlanetTitles));
    //mDrawerList.setAdapter(new SimpleAdapter(this,null,R.layout.left_menu_layout,null,null));
    mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.left_menu_layout, mPlanetTitles));
    // Set the list's click listener
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
// getSupportParentActivityIntent();
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) SearchView(android.support.v7.widget.SearchView) InjectView(butterknife.InjectView) View(android.view.View) AdapterView(android.widget.AdapterView) ShimmerTextView(com.marshalchen.common.uimodule.shimmer.ShimmerTextView) ListView(android.widget.ListView) ActionBar(android.support.v7.app.ActionBar)

Example 40 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project UltimateAndroid by cymcsg.

the class FoldingDrawerLayoutActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.folding_drawer_activity_drawer);
    mTitle = mDrawerTitle = getTitle();
    mAnimalTitles = getResources().getStringArray(R.array.items_name);
    mDrawerLayout = (FoldingDrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);
    // mFoldLayout = (FoldingNavigationLayout)findViewById(R.id.fold_view);
    // mFoldLayout.setBackgroundColor(Color.BLACK);
    // set a custom shadow that overlays the main content when the drawer
    // opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener
    mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.left_menu_layout, mAnimalTitles));
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
    mItemSelectedListener = new ItemSelectedListener();
    // enable ActionBar app icon to behave as action to toggle nav drawer
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
    mDrawerLayout, /* DrawerLayout object */
    R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
    R.string.drawer_open, /* "open drawer" description for accessibility */
    R.string.drawer_close) {

        /* "close drawer" description for accessibility */
        @SuppressLint("NewApi")
        public void onDrawerClosed(View view) {
            getSupportActionBar().setTitle(mTitle);
            if (IS_HONEYCOMB) {
                // creates call to
                invalidateOptionsMenu();
            // onPrepareOptionsMenu()
            }
        }

        public void onDrawerSlide(View drawerView, float slideOffset) {
        }

        @SuppressLint("NewApi")
        public void onDrawerOpened(View drawerView) {
            getSupportActionBar().setTitle(mDrawerTitle);
            if (IS_HONEYCOMB) {
                // creates call to
                invalidateOptionsMenu();
            // onPrepareOptionsMenu()
            }
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    if (savedInstanceState == null) {
        selectItem(0);
    }
    //        try {
    //            mDrawerLayout.getFoldingLayout(mDrawerList).setNumberOfFolds(
    //                    numOfFolder);
    //        } catch (Exception e) {
    //            e.printStackTrace();
    //            Logs.e(e, "" + (mDrawerLayout != null) + "   " + (mDrawerList != null)
    //                    + "  " + (mDrawerLayout.getFoldingLayout(mDrawerList) != null));
    //        }
    HandlerUtils.sendMessageHandlerDelay(getNumHandler, 0, 1000);
}
Also used : OnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) SuppressLint(android.annotation.SuppressLint) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Aggregations

ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)91 View (android.view.View)81 NavigationView (android.support.design.widget.NavigationView)34 ActionBarDrawerToggle (android.support.v4.app.ActionBarDrawerToggle)34 TextView (android.widget.TextView)32 Toolbar (android.support.v7.widget.Toolbar)31 AdapterView (android.widget.AdapterView)30 DrawerLayout (android.support.v4.widget.DrawerLayout)29 ListView (android.widget.ListView)29 ActionBar (android.support.v7.app.ActionBar)20 ImageView (android.widget.ImageView)18 Intent (android.content.Intent)15 SharedPreferences (android.content.SharedPreferences)15 RecyclerView (android.support.v7.widget.RecyclerView)10 SearchView (android.support.v7.widget.SearchView)8 MenuItem (android.view.MenuItem)7 Handler (android.os.Handler)6 PackageManager (android.content.pm.PackageManager)5 InjectView (butterknife.InjectView)5 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)5