MaterialDrawer V0.9 (Mike Penz)

DonManfred

Expert
Licensed User
Longtime User
UPDATE 03/33/2020:
- Do not use this Library anymore. I suggest to use b4xdrawer.

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


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.


Known problems:
- For me the Drawer will show behind the Actionbar. Due to this the layout in the top area is not placed correctly.
I think it must be changed in the theme somehow but i´m sorr, i do not know how to fix this. Any help on this is highly appreciated!



This library is Donationware. You can download the library, you can test the library. But if you want to USE the library in your App you need to Donate for it. I spend A LOT of time to build this library.

Please click here to donate for my work to write the wrapper (You can donate any amount you want :))
 

Attachments

  • MaterialDrawerAAR.zip
    463 KB · Views: 1,326
  • MaterialDrawerEx1.zip
    88.3 KB · Views: 973
  • MaterialDrawerFONTS1.zip
    437.3 KB · Views: 1,047
  • MaterialDrawerFONTS2.zip
    466.6 KB · Views: 989
  • MaterialDrawerV0.9.zip
    266.3 KB · Views: 1,136
  • resource.zip
    139.6 KB · Views: 1,013
Last edited:

corwin42

Expert
Licensed User
Longtime User
Known problems:
- For me the Drawer will show behind the Actionbar. Due to this the layout in the top area is not placed correctly.
I think it must be changed in the theme somehow but i´m sorr, i do not know how to fix this. Any help on this is highly appreciated!

I didn't took a closer look at the library and example for now.

For my understanding it is not possible to show the drawer behind an ActionBar because the ActionBar is a system component and is always shown on top.
You have to use a ToolBar which is part of the UI layout of the application and can be placed behind the drawer then.

Does the drawer show behind the (transparent) status bar? This was a main problem I had when I created the NavigationDrawer object in the DesignSupport library.
Screenshot_20160826-160906.png

I got it only right when I created the layout by XML files and not by code.
 

DonManfred

Expert
Licensed User
Longtime User

alimanam3386

Active Member
Licensed User
Longtime User
Hi

First thank you for your great work:) ... when I compile the example I got this error : [API 22 Android 5.1.1]

ER01.png


ER02.png


B4X:
Panel size is unknown. Layout may not be loaded correctly.
main_activity_create (java line: 460)
android.content.res.Resources$NotFoundException: Resource ID #0x0
    at android.content.res.Resources.getValue(Resources.java:2452)
    at android.content.res.Resources.loadXmlResourceParser(Resources.java:4159)
    at android.content.res.Resources.getLayout(Resources.java:2268)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:413)
    at com.mikepenz.materialdrawer.AccountHeaderBuilder.withAccountHeader(AccountHeaderBuilder.java:598)
    at com.mikepenz.materialdrawer.AccountHeaderBuilder.build(AccountHeaderBuilder.java:756)
    at de.donmanfred.AccountHeaderBuilderWrapper.build(AccountHeaderBuilderWrapper.java:564)
    at de.donmanfred.MaterialDrawer.main._activity_create(main.java:460)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at de.donmanfred.MaterialDrawer.main.afterFirstLayout(main.java:102)
    at de.donmanfred.MaterialDrawer.main.access$000(main.java:17)
    at de.donmanfred.MaterialDrawer.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6872)
    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)
android.content.res.Resources$NotFoundException: Resource ID #0x0
 

MAGAREY

Member
Licensed User
Longtime User
Hi

First thank you for your great work:) ... when I compile the example I got this error : [API 22 Android 5.1.1]

ER01.png


ER02.png


B4X:
Panel size is unknown. Layout may not be loaded correctly.
main_activity_create (java line: 460)
android.content.res.Resources$NotFoundException: Resource ID #0x0
    at android.content.res.Resources.getValue(Resources.java:2452)
    at android.content.res.Resources.loadXmlResourceParser(Resources.java:4159)
    at android.content.res.Resources.getLayout(Resources.java:2268)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:413)
    at com.mikepenz.materialdrawer.AccountHeaderBuilder.withAccountHeader(AccountHeaderBuilder.java:598)
    at com.mikepenz.materialdrawer.AccountHeaderBuilder.build(AccountHeaderBuilder.java:756)
    at de.donmanfred.AccountHeaderBuilderWrapper.build(AccountHeaderBuilderWrapper.java:564)
    at de.donmanfred.MaterialDrawer.main._activity_create(main.java:460)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at de.donmanfred.MaterialDrawer.main.afterFirstLayout(main.java:102)
    at de.donmanfred.MaterialDrawer.main.access$000(main.java:17)
    at de.donmanfred.MaterialDrawer.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6872)
    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)
android.content.res.Resources$NotFoundException: Resource ID #0x0
I have the same problem, any suggestions?
 

MAGAREY

Member
Licensed User
Longtime User
Known problems:
- For me the Drawer will show behind the Actionbar. Due to this the layout in the top area is not placed correctly.
I think it must be changed in the theme somehow but i´m sorr, i do not know how to fix this. Any help on this is highly appreciated!

It worked for me, placing this on the manifest:


B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="21"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:label, "$LABEL$")

'End of default text.
AddPermission(android.permission.INTERNET) ' Allows applications to open network sockets.
SetApplicationAttribute(android:theme, "@style/MyAppTheme")

CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="@style/Theme.AppCompat">
        <item name="colorPrimary">#FF9800</item>
        <item name="colorPrimaryDark">#F57C00</item>
        <item name="colorAccent">#FFA726</item>
           <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="windowActionModeOverlay">true</item>
    </style>
</resources>
)
 

DonManfred

Expert
Licensed User
Longtime User
placing this on the manifest
COOOOOOOL
It is working for me also. Great...

Now we can try to find the right way of placing images or icons in the above header... As of now i´m not sure if this is the account header or another view of the drawer...
 

MAGAREY

Member
Licensed User
Longtime User
i tried every views of the drawer, every account header and headers, and nothing, Any suggestions?
 

jayel

Active Member
Licensed User
Longtime User
hello,

B4X:
#Region  Project Attributes
    #ApplicationLabel: RoboNotification
    #VersionCode: 31
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
'    #AdditionalRes: C:\ANDROID\SlidingMenu\library\res, com.jeremyfeinstein.slidingmenu.lib
    #AdditionalRes: C:\ANDROID\extra-libs\res\b4a_appcompat, android.support.v7.appcompat
    #AdditionalRes: C:\ANDROID\extra-libs\res\md-app\res
    #AdditionalRes: C:\ANDROID\extra-libs\res\md-lib\res
  
    #AdditionalJar: bcprov-jdk15on-154.jar

    #Extends: android.support.v7.app.AppCompatActivity
#End Region

Sub MakeMenu
    Dim pnlHdr As Panel
    pnlHdr.Initialize("pnlHdr")
    pnlHdr.Color     = Colors.DarkGray
    pnlHdr.Tag       = "Header"
  
  
'    Dim MSP1 As MSProfile
'    Dim PDB1 As BitmapDrawable : PDB1.Initialize(LoadBitmap(File.DirAssets,"profile2.jpg"))
'    MSP1.withName("tds").withEmail("h@g.com").withIcon(PDB1)
'    Dim MSP2 As MSProfile
'    Dim PDB2 As BitmapDrawable : PDB2.Initialize(LoadBitmap(File.DirAssets,"profile3.jpg"))
'    MSP2.withName("Neo").withEmail("neo@g.com").withIcon(PDB2)
'  
'    Dim Profiles(2) As MSProfile
'    Profiles(0) = MSP1
'    Profiles(1) = MSP2
  

  
    Dim p1 As MSIconicDrawable : p1.Initialize("ic_home_variant_black_24dp")  : p1.Color = 0xffff4081  '<---- this line is the error
  
  
    Dim s1 As MSIconicDrawable : s1.Initialize("ic_settings_black_24dp") : s1.Color = 0xffff4081
    Dim s2 As MSIconicDrawable : s2.Initialize("ic_application_black_24dp") : s2.Color = 0xffff4081
    Dim s3 As MSIconicDrawable : s3.Initialize("ic_logout_black_24dp") : s3.Color = 0xffff4081

  
    MDB.Initialize("MD")
    MDB.withHeader(pnlHdr, -1, 80dip)
    MDB.AddPrimaryDrawerItem  ("Actions"  , p1.Drawable ,Null ,"99+" ,True,1, "Acties domotica")
    MDB.AddSectionDrawerItem  ("Section"  ,True)
    MDB.AddSecondaryDrawerItem("Settings" ,s1.Drawable ,Null ,""    ,True ,2)
    MDB.AddSecondaryDrawerItem("About"     ,s2.Drawable ,Null ,""    ,True ,3)
    MDB.AddSectionDrawerItem  ("Section"  ,True)
    MDB.AddSecondaryDrawerItem("Logout"     ,s3.Drawable ,Null ,""    ,True ,4)
  
    MD = MDB.Build
End Sub

I copied my png's to the folder C:\ANDROID\extra-libs\res\md-app\res
But i get following error :
Installing file.
PackageAdded: package:be.robotronic.robonotification
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (firebasemessaging) Create **
** Service (firebasemessaging) Start **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
JobName = LoginSpecial, Success = true
Error occurred on line: 512 (Main)
java.lang.NullPointerException: Attempt to invoke interface method 'com.mikepenz.iconics.typeface.IIcon com.mikepenz.iconics.typeface.ITypeface.getIcon(java.lang.String)' on a null object reference
at com.mikepenz.iconics.IconicsDrawable.<init>(IconicsDrawable.java:90)
at com.maximussoft.msmaterialdrawer.IconicDrawable.Initialize(IconicDrawable.java:18)
at be.robotronic.robonotification.main._makemenu(main.java:1038)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:708)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.BA$2.run(BA.java:328)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

Somebody any clue?

Greets John
 

mmucek

Member
Licensed User
Longtime User
I installed MaterialDrawerEx1 example and it works great. Tried to add google maps and first of all i added
#AdditionalJar: com.google.android.gms:play-services-maps
and got this error:

B4X:
B4A version: 6.50
Parsing code.    (0.00s)
Compiling code.    (0.11s)
   
ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code.    (0.00s)
Organizing libraries.    (2.07s)
Generating R file.    (0.92s)
Compiling generated Java code.    (2.32s)
Convert byte code - optimized dex.    Error
trouble writing output: Too many field references: 67535; max is 65536.
You may try using --multi-dex option.
References by package:
     2 android.accounts
    26 android.app
     1 android.content
    29 android.content.pm
    10 android.content.res
     3 android.database
    46 android.graphics
     3 android.hardware
     1 android.location
     2 android.media
     1 android.media.browse
     2 android.net
    18 android.os
     3 android.print
     7 android.provider
    11 android.support.annotation
     6 android.support.compat
     6 android.support.coreui
     6 android.support.coreutils
  3267 android.support.design
    98 android.support.design.internal
   686 android.support.design.widget
     6 android.support.fragment
   159 android.support.graphics.drawable
     6 android.support.graphics.drawable.animated
     6 android.support.mediacompat
  3446 android.support.transition
     6 android.support.v4
    13 android.support.v4.accessibilityservice
    17 android.support.v4.animation
   865 android.support.v4.app
   112 android.support.v4.content
     1 android.support.v4.content.pm
     1 android.support.v4.content.res
     9 android.support.v4.graphics
    41 android.support.v4.graphics.drawable
     4 android.support.v4.hardware.display
    12 android.support.v4.hardware.fingerprint
    10 android.support.v4.internal.view
   350 android.support.v4.media
   300 android.support.v4.media.session
    10 android.support.v4.net
    19 android.support.v4.os
    63 android.support.v4.print
     9 android.support.v4.provider
    55 android.support.v4.text
     6 android.support.v4.text.util
   102 android.support.v4.util
   434 android.support.v4.view
   137 android.support.v4.view.accessibility
     8 android.support.v4.view.animation
   495 android.support.v4.widget
   394 android.support.v7.app
  3267 android.support.v7.appcompat
     8 android.support.v7.content.res
    18 android.support.v7.graphics.drawable
  3267 android.support.v7.recyclerview
     1 android.support.v7.text
     2 android.support.v7.transition
   124 android.support.v7.util
    77 android.support.v7.view
   248 android.support.v7.view.menu
  1379 android.support.v7.widget
    89 android.support.v7.widget.helper
     1 android.support.v7.widget.util
     5 android.text
     1 android.text.util
     2 android.transition
    14 android.util
    19 android.view
     8 android.view.accessibility
     1 android.view.inputmethod
    12 android.widget
   121 anywheresoftware.b4a
    81 anywheresoftware.b4a.keywords
   125 anywheresoftware.b4a.keywords.constants
   180 anywheresoftware.b4a.objects
    13 anywheresoftware.b4a.objects.collections
    15 anywheresoftware.b4a.objects.drawable
     3 anywheresoftware.b4a.objects.streams
   173 anywheresoftware.b4a.phone
    15 anywheresoftware.b4j.object
  3261 com.google.android.gms
    20 com.google.android.gms.actions
    15 com.google.android.gms.ads.identifier
    36 com.google.android.gms.auth.api.signin
     6 com.google.android.gms.auth.api.signin.internal
  3261 com.google.android.gms.base
    93 com.google.android.gms.common
    93 com.google.android.gms.common.api
    41 com.google.android.gms.common.data
    46 com.google.android.gms.common.images
   164 com.google.android.gms.common.internal
     1 com.google.android.gms.common.internal.safeparcel
     4 com.google.android.gms.common.server
    12 com.google.android.gms.common.server.converter
    33 com.google.android.gms.common.server.response
    50 com.google.android.gms.common.stats
    23 com.google.android.gms.common.util
    27 com.google.android.gms.dynamic
     2 com.google.android.gms.dynamite.descriptors.com.google.android.gms.flags
    16 com.google.android.gms.flags.impl
     6 com.google.android.gms.iid
  1366 com.google.android.gms.internal
     5 com.google.android.gms.location.places
  3423 com.google.android.gms.maps
    44 com.google.android.gms.maps.internal
   164 com.google.android.gms.maps.model
    10 com.google.android.gms.maps.model.internal
    18 com.google.android.gms.phenotype
    11 com.google.android.gms.playlog.internal
     6 com.google.android.gms.security
    26 com.google.android.gms.signin.internal
    48 com.google.android.gms.tasks
  1581 com.mikepenz
  3304 com.mikepenz.fastadapter
    12 com.mikepenz.fastadapter.adapters
    11 com.mikepenz.fastadapter.helpers
    10 com.mikepenz.fastadapter.items
     1 com.mikepenz.fastadapter.utils
    29 com.mikepenz.fastadapter_extensions
     4 com.mikepenz.fastadapter_extensions.dialog
     6 com.mikepenz.fastadapter_extensions.drag
    27 com.mikepenz.fastadapter_extensions.items
    34 com.mikepenz.fastadapter_extensions.scroll
     8 com.mikepenz.fastadapter_extensions.swipe
     2 com.mikepenz.fastadapter_extensions.utilities
  3948 com.mikepenz.fontawesome_typeface_library
   801 com.mikepenz.google_material_typeface_library
  3315 com.mikepenz.iconics
    18 com.mikepenz.iconics.context
  3267 com.mikepenz.iconics.core
   690 com.mikepenz.iconics.typeface
    15 com.mikepenz.iconics.utils
     8 com.mikepenz.iconics.view
  3267 com.mikepenz.library_extensions
   293 com.mikepenz.materialdrawer
    10 com.mikepenz.materialdrawer.holder
    11 com.mikepenz.materialdrawer.icons
   181 com.mikepenz.materialdrawer.model
     1 com.mikepenz.materialdrawer.model.utils
    18 com.mikepenz.materialdrawer.util
    21 com.mikepenz.materialdrawer.view
  3288 com.mikepenz.materialize
   339 com.mikepenz.materialize.color
     2 com.mikepenz.materialize.drawable
    11 com.mikepenz.materialize.holder
     5 com.mikepenz.materialize.util
    16 com.mikepenz.materialize.view
  3319 de.amberhome.objects
  3331 de.amberhome.objects.appcompat
    62 de.donmanfred
  3306 de.donmanfred.MaterialDrawer
    13 java.lang
    11 java.lang.annotation
     1 java.nio
     6 java.util
     2 java.util.concurrent
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
It happens when you reference many libraries with internal resources.

You can solve it by editing the AndroidManifest.xml file that is in the AAR projects (use 7zip to open them) and change the package name to be the same as other packages.

For example find the one with package name de.amberhome.objects (one of corwin42's libraries) and change it to de.amberhome.objects.appcompat.
 
Last edited:
Top