Android Question Material Drawer V0.5 beta

DonManfred

Expert
Licensed User
Longtime User
This thread is about the beta phase of my newest wrap. It is a wrap for this Github project: Material Drawer by Mike Penz

At present the library is based on Version 5.8.1 of the Github project

The Library and download can be found HERE

MaterialDrawer
Author:
Mike Penz (Github) / DonManfred (wrapper)
Version: 0.9 beta

Attachments:
MaterialDrawerEx1.zip
this contains the (most probably a bit chaotic) code for the example i build so far.
So i just tried out how work this, and this and the code came up chaotic....
I´m sure more examples will follow in future. Maybe made from one of the beatestes? (grins)

MaterialDrawerResources.zip
this zip contains the folder "resource"
copy this folder to your Project or maybe to your additional libraries folder.
you need to adapt the #additionalres directive to match your folder

MaterialDrawerFONTS1.zip and MaterialDrawerFONTS2.zip
Copy all files to your additional libs folder

MaterialDrawerAAR.zip
Contains all needed AAR files. Copy them all to your additional libs folder

The library depends on some other JARs from the google Maven repository.

Post any questions regarding this librarywrap in this Thread please.

Note that this library wrap is in development and subject to be changed before releasing the library.

The example at present state shows all i have tried so far.
Some features are not tested at all.
Some features does not work as yet. The profile and everything about the profileheaderdraweritem for example.


The Library and download can be found HERE
 
Last edited:

itgirl

Active Member
Licensed User
Longtime User
first thing come to mind is
when i try to add a menu item as follows
B4X:
Menu.Add2(1,1,"test1",Null).SHOW_AS_ACTION_ALWAYS =ACMenuItem1.SHOW_AS_ACTION_IF_ROOM

the SHOW_AS_ACTION_IF_ROOM and other ints are missing from ACMenuItem1 or maybe you have implemented it in another way im not sure

also i cant see the ACMenuItem1.SearchView ??
 
Upvote 0

itgirl

Active Member
Licensed User
Longtime User
its ACMenu part of appcompact i think its the different bettwen version of appcompact
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
ACMenu is part of the AppCompat.

The Drawer needs to have a AppCompat compatible "base-app" to be used in.
the example only uses some basic appcompat layout... But they are not part of the drawer.

The focus should be the drawer itself and it look, behaviour, features, bugs ;)
 
Upvote 0

itgirl

Active Member
Licensed User
Longtime User
ACMenu is part of the AppCompat.

The Drawer needs to have a AppCompat compatible "base-app" to be used in.
the example only uses some basic appcompat layout... But they are not part of the drawer.

The focus should be the drawer itself and it look, behaviour, features, bugs ;)
Yup your right lol sorry about that.... looks amazing so far
 

Attachments

  • 1.png
    1.png
    85.1 KB · Views: 745
Upvote 0

itgirl

Active Member
Licensed User
Longtime User
Can you share the code that creates this look? Especially the headeritem with the image
its not based on profiles come with Lib it's just a panel i created manually with 1 image and 3 label ... because the profiles thingy was so messed up and i didnt like it so i decided to make it manually, this way i can take control of all views in the header with their status(left,width,top....) and access them whenever i need to :)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
but you added it somehow to the drawer? How did you do this? I wrote the wrapper but does not have used the drawer itself much.
I would like to see the code you used to add your own layout to the drawer. ;)
probably it is a panel you loaded a layout to or so?
 
Upvote 0

itgirl

Active Member
Licensed User
Longtime User
Sure , the only tricky part was how to get the drawer width in both states landscape andportrait .... i don't know why but the drawer width is different on each device not as google mentioned here thats why i had to use withDrawerWidthDp ,,,, here you go :
for the drawer it self
B4X:
    pnlHdr.Initialize("")
    pnlHdr.Color = AppColors
    pnlHdr.Tag = "Header"
 
 
    MDB.Initialize("MD")
    MDB.withHeaderClickable(False)
    MDB.withHeader(pnlHdr, drawerwidth, 35%y)
    MDB.withToolbar(ActionBar)
    MDB.withActionbarToggle(True)
    MDB.withActionbarToggleAnimated(True)
    MDB.withTransluscentStatusbar(True)
    MDB.withDrawerWidthDp(MyClasses.DipToINT(drawerwidth))
    MDB.withFooter(footer,drawerwidth, 50dip)
    ABHelper.ShowUpIndicator = True

the panel goes right here after update the header which the bitmap comes from http
B4X:
Sub updateheader (bt As Bitmap)
        pnlHdr.RemoveAllViews
        pnlHdr.AddView(profilepic,16dip,5%y,80dip,80dip)
     
        profilename.Initialize("profilename")
        profileFullname.Initialize("profileFullname")
     
        profilename.TextColor = Colors.White
        profilename.TextSize = 12
        profilename.Gravity = Gravity.LEFT
     
        profileFullname.TextColor = Colors.White
        profileFullname.TextSize = 12
        profileFullname.Gravity = Gravity.LEFT

        If  manager.GetString("Fullname") <> "0" Then
              profilename.Text = manager.GetString("User")
              profileFullname.Text = manager.GetString("Fullname")
        Else
              profilename.Text = GetLang.GetResourceString("mymenu2")
              profileFullname.Text = GetLang.GetResourceString("mymenu3")
        End If
 
 
         Dim profiletagdown As Label
         profiletagdown.Initialize("profiletagdown")
         profiletagdown.TextColor = Colors.White
         profiletagdown.TextSize = 16
         profiletagdown.Typeface = fontawsome.FontAwesomeTypeface
         profiletagdown.Text = fontawsome.GetFontAwesomeIconByName("fa-chevron-circle-down")
         profiletagdown.Gravity = Gravity.RIGHT
       
 

         pnlHdr.AddView(profilename,16dip,profilepic.Top + profilepic.Height + 10dip,pnlHdr.Width /2 ,20dip)
         pnlHdr.AddView(profileFullname,16dip,profilename.Top  + profilename.Height + 10dip,pnlHdr.Width /2,20dip)
         pnlHdr.AddView(profiletagdown,drawerwidth - 35dip  ,profileFullname.Top + profileFullname.Height + 10dip,20dip,20dip)

 
 
        profilepic.ImageBitmap = bt
           profilepic.ScaleType=profilepic.SCALETYPE_CENTER_CROP
        profilepic.Oval=False
        profilepic.CornerRadius=0
        Dim xImgSize As Int = 25%x * 100%y/100%x
        Dim States(3,1) As Int
        States(0,0) = 16842919
        States(1,0) = 16842910
        States(2,0) = -16842910
        Dim Color(3) As Int = Array As Int(AppColors,Colors.White, AppColors)
        profilepic.setBorderColors(States,Color)
        profilepic.BorderWidth=4dip


        pnlHdr.Height =profiletagdown.Top + 30dip
        headerloader.Visible = False
end sub
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Hi Don. After compiling I have this error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{de.donmanfred.MaterialDrawer/de.donmanfred.MaterialDrawer.main}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3168)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3278)
at android.app.ActivityThread.access$1000(ActivityThread.java:211)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1705)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6912)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:374)
at de.donmanfred.MaterialDrawer.main.onCreate(main.java:50)
at android.app.Activity.performCreate(Activity.java:6575)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1134)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3121)
... 10 more
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
I dont get this with the examplecode i posted.

Try to build your own example and see what happens there...

Also if i compile withour code, only with library, example only Activity_create that open layout i have same error.

Here example:
B4X:
#Region  Project Attributes
    #ApplicationLabel: Test
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

'#AdditionalRes: ..\resource
'
'#AdditionalRes: ..\res.materialize
'#AdditionalRes: ..\res.fastadapter
'
'#AdditionalRes: $AdditionalLibs$\b4a_appcompat, de.amberhome.objects.appcompat
'#AdditionalRes: $AndroidSDK$\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
'#AdditionalRes: $AndroidSDK$\extras\android\support\v7\recyclerview\res, android.support.v7.recyclerview
''#AdditionalRes: $AndroidSDK$\extras\android\support\design\res, android.support.design
'
'#AdditionalRes: ..\res.materialdrawer
'
'#Extends: android.support.v7.app.ActionBarActivity

#AdditionalRes:..\resource

#AdditionalRes: C:\AnywhereSoftware\msmaterialDON-drawneresource\res.materialize
#AdditionalRes: C:\AnywhereSoftware\msmaterialDON-drawneresource\res.fastadapter

#AdditionalRes: C:\AnywhereSoftware\b4a_appcompat, de.amberhome.objects.appcompat
#AdditionalRes: $AndroidSDK$\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
#AdditionalRes: $AndroidSDK$\extras\android\support\v7\recyclerview\res, android.support.v7.recyclerview
'#AdditionalRes: $AndroidSDK$\extras\android\support\design\res, android.support.design

#AdditionalRes: C:\AnywhereSoftware\msmaterialDON-drawneresource\res.materialdrawer

#Extends: android.support.v7.app.ActionBarActivity






#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: false
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
''    Private Spinner1 As Spinner
''    Private EditText1 As EditText
    Private mdb As DrawerBuilder
    Private md As Drawer
    Private mnu1,mnu2,mnu3 As PrimaryDrawerItem
    Private submnu1 As SecondaryDrawerItem
'    Private p1, p2 As IProfile
    Private icon, ic2 As IconicsDrawable
    Private awesome As FontAwesome
''    Private iconix As Iconics
'    Private header As AccountHeaderBuilder
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("lay_devil")
   
    Dim pnlHdr As Panel
    pnlHdr.Initialize("")
    pnlHdr.Color = Colors.DarkGray
    pnlHdr.Tag = "Header"
   
   
   
    Dim MSP1 As ProfileDrawerItem
    MSP1.Initialize("MSP1")
    Dim PDB1 As BitmapDrawable : PDB1.Initialize(LoadBitmap(File.DirAssets,"profile2.jpg"))
    MSP1.withName("tds").withEmail("[email protected]").withIcon(PDB1)
    Dim MSP2 As ProfileDrawerItem
    MSP2.Initialize("MSP")
    Dim PDB2 As BitmapDrawable : PDB2.Initialize(LoadBitmap(File.DirAssets,"profile3.jpg"))
    MSP2.withName("Neo").withEmail("[email protected]").withIcon(PDB2)   

    Dim Profiles(2) As ProfileDrawerItem
    Profiles(0) = MSP1
    Profiles(1) = MSP2

   
    Dim msa As AccountHeaderBuilder
    Dim HeaderBackground As BitmapDrawable
    HeaderBackground.Initialize(LoadBitmap(File.DirAssets,"header.jpg"))
    msa.Initialize("MSA")
    msa.addProfiles(Profiles)
    msa.withHeaderBackground(HeaderBackground)
    Dim MaterialHeaderResult As Object = msa.build    
   
   
   
    Dim s1 As IconicsDrawable : s1.Initialize("gmd_settings")      : s1.color(Colors.Red)
    Dim s2 As IconicsDrawable : s2.Initialize("gmd_help")          : s2.color(Colors.Red)
    Dim s3 As IconicsDrawable : s3.Initialize("faw_google_wallet") : s3.color(Colors.Red)


    icon.Initialize("gmd_account_circle")
    ic2.Initialize("faw_android")

    icon.icon("gmd_account_circle").color(Colors.Blue).contourColor(Colors.Red).drawContour(True).backgroundColor(Colors.White).iconOffsetXDp(8)
    ic2.color(Colors.Blue).contourColor(Colors.Red).drawContour(True).backgroundColor(Colors.White).iconOffsetXDp(8)
   
   
    mnu1.Initialize("")
    mnu1.withDescription("Desciption").withDescriptionTextColor(Colors.Green).withIdentifier(1).withTag("x").withName("TestA").withBadge("+1000").withIcon(icon.clone)
    submnu1.Initialize("")
    submnu1.withDescription("SubDesciption").withDescriptionTextColor(Colors.Magenta).withIdentifier(11).withTag("sub1").withName("SubTest").withBadge("+1000")
   
    mnu2.Initialize("")
    mnu2.withDescription("Desciption2").withDescriptionTextColor(Colors.Green).withIdentifier(2).withTag("x2").withName("TestB").withBadge("+10")
   
   
    mnu3.Initialize("")
    'ic2.Initialize(awesome.getIcon("faw_github"))
    mnu3.withDescription("Dynamic test").withDescriptionTextColor(Colors.Blue).withIdentifier(3).withTag("x3").withName("DynamicTest").withBadge("+99")'.withIcon(ic2.clone)


   
    mdb.Initialize("md")
    mdb.withAccountHeader(MaterialHeaderResult)
'    mdb.addDrawerItems(mnu1)
'    mdb.addDrawerItems(mnu2)
'    mdb.addDrawerItems(mnu3)
    md = mdb.build

   
   

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)


End Sub


Sub MD_onDrawerOpened()
    Log("onDrawerOpened()")
End Sub
Sub MD_onDrawerClosed()
    Log("onDrawerClosed()")
End Sub
Sub MD_onDrawerSlide(slideOffset As Float)   
    'Log($"onDrawerSlide(${slideOffset})"$)
End Sub
Sub MD_onItemClick(position As Int, drawerItem As Object)
    Log($"onItemClick(${position})"$)
   
End Sub
 

Attachments

  • MaterialDrawerDON2.zip
    154.9 KB · Views: 455
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
The accountheader is, like the not working profiles, not working as yet.

And it looks like you are not using the method right

B4X:
Dim MaterialHeaderResult As Object = msa.build
msa.build will not work the way you did.

I´ve extended the library to have a AccountHeader Object too.
And i got progress adding the header. But for now it is showing not a correct icon but i dont know why

Screenshot_20160605-115523.png

I´m working on it ;)
 
Upvote 0

itgirl

Active Member
Licensed User
Longtime User
ProfileDrawerItem as in
B4X:
.withIconUrl("some img url ")
not seems to work i guess it still work in progress because ther's no error not attempt to download
 
Upvote 0

itgirl

Active Member
Licensed User
Longtime User
i guess you are right... it is not working for me too
Yeah i guess its easy to put all the images in list then download it but its better if it was built in :/

anyways Really great Lib i cant stop playing with it lol the drawer dropdown ProfileDrawerItem is really beautiful
 
Upvote 0

itgirl

Active Member
Licensed User
Longtime User
Hello i think theres a problem with the drawer or maybe Im doing something wrong i just cant get the drawer to get above the statusbar and get the statusbar to Translucent
tried the
.withfullscreen
.withDisplayBelowStatusBar(false)
 

Attachments

  • 1.png
    1.png
    17 KB · Views: 452
Upvote 0

itgirl

Active Member
Licensed User
Longtime User
yup im workiing on it to find a solution for this one , ive tried with
B4X:
<item name="android:windowTranslucentStatus">true</item>
it works but it shift all the content up :/ so still working on this one ....

also why always the backarrow shows up in activityies even after i set the toolbar ??? i cant seem to get the Hamburger icon to show up instead of the back arrow :/
 
Upvote 0
Top