Skip to content

Conversation

@sockeqwe
Copy link

This adds the possibility to the replace the default up indicator with a slideable drawable. This will bring the same user experience like Google ActionBarDrawerToggle (http://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle.html) implemtation.

It works with the native ActionBar as well as with ActionBarSherlock (without adding dependency to ActionBarSherlock). It's implemented by using reflections to provide a common interface for native ActionBar and ActionBarSherlock. It can be setup with both java code and xml (added example code to README).

public class SlidingExample extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitle(R.string.attach);
        // set the content view
        setContentView(R.layout.content);
        // configure the SlidingMenu
        SlidingMenu menu = new SlidingMenu(this);
                menu.setMode(SlidingMenu.LEFT);

                ...

       // Set the ActionBarSlideIcon, that will replace the up indicator of the ActionBar
       slidingMenu.setActionBarSlideIcon(new ActionBarSlideIcon(this,
           R.drawable.ic_navigation_drawer, 
           R.string.open_content_desc, 
           R.string.close_content_desc);
    }

}

The code has been documented with javadoc. The code of the SlideDrawable has been extracted from the android support library revision 18 (july 2013). ActionBarSlideIcon should also work with ActionBarCompat (not tested with every version of Android).

@sarabsethi
Copy link

Hi, love this been looking for this functionality for ages. In case this isn't incorporated into the main library, or in the meanwhile is there a way I can implement it now?

Thanks

@sockeqwe
Copy link
Author

its already implemented by me ;) It don't looks like my pull request will be merge to the main project in the near feature. However you can use the code right now by simply checkout https://github.com/sockeqwe/SlidingMenu

@sarabsethi
Copy link

Great, will give it a go. Thanks
On 14 Sep 2013 22:23, "sockeqwe" [email protected] wrote:

its already implemented by me ;) It don't looks like my pull request will
be merge to the main project in the near feature. However you can use the
code right now by simply checkout https://github.com/sockeqwe/SlidingMenu


Reply to this email directly or view it on GitHubhttps://github.com//pull/516#issuecomment-24450817
.

@varunest
Copy link

This is some cool stuff, thanks a ton

On 14-Sep-2013, at 11:28 PM, sarabsethi [email protected] wrote:

Great, will give it a go. Thanks
On 14 Sep 2013 22:23, "sockeqwe" [email protected] wrote:

its already implemented by me ;) It don't looks like my pull request will
be merge to the main project in the near feature. However you can use the
code right now by simply checkout https://github.com/sockeqwe/SlidingMenu


Reply to this email directly or view it on GitHubhttps://github.com//pull/516#issuecomment-24450817
.


Reply to this email directly or view it on GitHub.

@sarabsethi
Copy link

Works an absolute treat - thanks!

@sarabsethi
Copy link

So prepare for the worst bug report ever.

Sometimes (testing nexus 4 and nexus 7) when opening the app the sliding
icon doesn't show at all - just a blank space where it should be. But if I
restart the app then it works fine. I haven't been able to narrow down any
details yet because it happens on such a random basis. Any ideas as to what
this might be caused by?
On 15 Sep 2013 01:39, "Varun" [email protected] wrote:

This is some cool stuff, thanks a ton

On 14-Sep-2013, at 11:28 PM, sarabsethi [email protected] wrote:

Great, will give it a go. Thanks
On 14 Sep 2013 22:23, "sockeqwe" [email protected] wrote:

its already implemented by me ;) It don't looks like my pull request
will
be merge to the main project in the near feature. However you can use
the
code right now by simply checkout
https://github.com/sockeqwe/SlidingMenu


Reply to this email directly or view it on GitHub<
https://github.com/jfeinstein10/SlidingMenu/pull/516#issuecomment-24450817>

.


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHubhttps://github.com//pull/516#issuecomment-24461956
.

@sockeqwe
Copy link
Author

No idea! Never seen such a behavior. Could you post some code, how you setup the icon?

@sarabsethi
Copy link

Here's the relevant part of my onCreate:

this.setSlidingActionBarEnabled(false);
getSlidingMenu().setShadowWidthRes(R.dimen.shadow_width);
getSlidingMenu().setShadowDrawable(R.drawable.shadow);
getSlidingMenu().setBehindWidthRes(R.dimen.sliding_menu_width);
getSlidingMenu().setFadeDegree(0.35f);

if (this.findViewById(R.id.menu_frame) == null) { // normal phone layout
setBehindContentView(R.layout.menu_frame);
getSlidingMenu().setSlidingEnabled(true);
getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
getSlidingMenu().setActionBarSlideIcon(new ActionBarSlideIcon(this,
R.drawable.ic_navigation_drawer, R.string.app_name,
R.string.app_name));

} else { // tablet layout
tabletLayout = true;
View v = new View(this);
setBehindContentView(v);
getSlidingMenu().setSlidingEnabled(false);
getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);
}

On Wed, Sep 18, 2013 at 9:58 AM, sockeqwe [email protected] wrote:

No idea! Never seen such a behavior. Could you post some code, how you
setup the icon?


Reply to this email directly or view it on GitHubhttps://github.com//pull/516#issuecomment-24650180
.

@sockeqwe
Copy link
Author

Do you use ActionBarSherlock or ActionBarCompat or the native ActionBar? The code seems ok!
Does changing the darwable resource resolve this problem?

@sarabsethi
Copy link

Action bar Sherlock, tried changing the drawable no luck though
On 19 Sep 2013 13:43, "sockeqwe" [email protected] wrote:

Do you use ActionBarSherlock or ActionBarCompat or the native ActionBar?
The code seems ok!
Does changing the darwable resource resolve this problem?


Reply to this email directly or view it on GitHubhttps://github.com//pull/516#issuecomment-24735709
.

@sockeqwe
Copy link
Author

I Could not reproduce this issue. I have tested on many real devices (incl. Nexus 4, Nexus 7, Nexus 10, new Nexus 7, Galaxy S2, Galaxy S3, Galaxy S4, Galaxy Nexus, HTC One) and everything has worked. I have also testet things on Emulators beginning from Android 2.2.

Btw. The code for the drawable of the Slideable Icon is copy & paste from the official Android NavigationDrawer implementation

@sarabsethi
Copy link

OK thanks for your efforts, if I ever find the issue I'll let you know
On 30 Sep 2013 09:57, "sockeqwe" [email protected] wrote:

Could not bring reproduce this issue. I have tested on many real devices
(incl. Nexus 4, Nexus 7, Nexus 10, new Nexus 7, Galaxy S2, Galaxy S3,
Galaxy S4, Galaxy Nexus, HTC One) and everything has worked. I have also
testet things on Emulators beginning from Android 2.2


Reply to this email directly or view it on GitHubhttps://github.com//pull/516#issuecomment-25345900
.

@codeversed
Copy link

@sockeqwe
I am currently using your Fork and it is working wondering. I also added this mod into my project: maciekczwa/SlidingMenu@jfeinstein10:master...master

Together the two create the most Android design-like look (like gmail and gplus).

Thank you!

@sockeqwe
Copy link
Author

sockeqwe commented Oct 1, 2013

cool! Would you like to make a pull request to my SlidingMenu Repository, so we could merge them together in this one pull request.
Im curious, where have you added a shadow?

I hope that @jfeinstein10 will find some time to merge this pull request in the near future

@sockeqwe
Copy link
Author

sockeqwe commented Oct 1, 2013

Ah, i see ...

Thought your shadow mod belongs somewhere to my the actionbar / sliding icon changes.

So simply forget about making a pull request my SlidingMenu repository.

@codeversed
Copy link

Understood. I am using the shadow outside but am looking to modify it to be more like gmail/gplus. As you open the drawer it fades the content area with a black overlay.

@sockeqwe
Copy link
Author

sockeqwe commented Oct 3, 2013

Well but why should I not use the official Android ActionBarDrawerToggle implementation in this case?

@codeversed
Copy link

@sockeqwe, Good point. I will have to test that out real quick. I just was using this and not ActionBarDrawerToggle just because I already had time invested.

@sockeqwe
Copy link
Author

@jfeinstein10 Do you want to merge this pull-request in the near future or do you think this will go in the wrong direction?

@zeroarst
Copy link

Hi I am trying to use this but still can't get it working.
This is my code. I call initSlidingMenu after setContentView in onCreate
Did I miss something?

void initSlidingMenu() {

    setBehindContentView(R.layout.sliding_menu);

    SlidingMenu menu = getSlidingMenu();

    menu.setMode(SlidingMenu.LEFT);

    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
    menu.setShadowWidthRes(R.dimen.slidingmenu_shadow_width);
    menu.setShadowDrawable(R.drawable.sliding_menu_shadow);
    menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    menu.setFadeDegree(0.35f);

    menu.setActionBarSlideIcon(new ActionBarSlideIcon(this, R.drawable.ic_drawer, R.string.msg_1,
            R.string.msg_2));       
}

@sockeqwe
Copy link
Author

It seems to be correct, only menu.attachToActivity(this, SlidingMenu.SLIDING_WINDOW); is missing.
Do you use ActionBarSherlock (which version?) or the native ActionBar (Android 4.+)? Whats the current behavior?

@zeroarst
Copy link

I have added this line of code setBehindContentView so I don't think I need add menu.attachToActivity, actually I got exception when I added it.

I am using ActionBarSherlock version 4.2.0.

It currently display default indicator (small left arrow icon)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants