From 2efa7f4947becbfc647cc1fd2742bb0cbd0107db Mon Sep 17 00:00:00 2001 From: kubasz Date: Thu, 5 Sep 2019 20:28:52 +0200 Subject: [PATCH] Change IDrawerProfile, IUnreadCounter to interface. Add BS item description. Add BS on close listener. Fix BS list filtering. Add toolbar image. --- app/build.gradle | 28 +-- .../szczodrzynski/navigation/DrawerProfile.kt | 27 +++ .../szczodrzynski/navigation/MainActivity.kt | 16 +- app/src/main/res/layout/sample_nav_view.xml | 5 - build.gradle | 68 ++++-- navlib/build.gradle | 40 ++-- .../pl/szczodrzynski/navlib/ImageHolder.kt | 19 ++ .../pl/szczodrzynski/navlib/NavToolbar.kt | 18 ++ .../java/pl/szczodrzynski/navlib/NavView.kt | 24 +- .../java/pl/szczodrzynski/navlib/Utils.kt | 46 ++-- .../navlib/bottomsheet/NavBottomSheet.kt | 35 ++- .../items/BottomSheetPrimaryItem.kt | 31 ++- .../navlib/drawer/IDrawerProfile.kt | 19 +- .../navlib/drawer/IUnreadCounter.kt | 10 +- .../szczodrzynski/navlib/drawer/NavDrawer.kt | 207 ++++++++++-------- .../navlib/drawer/items/DrawerPrimaryItem.kt | 7 + .../src/main/res/layout/nav_bottom_sheet.xml | 2 +- .../main/res/layout/nav_bs_item_primary.xml | 53 +++-- navlib/src/main/res/layout/nav_view.xml | 15 +- navlib/src/main/res/values/colors.xml | 10 + navlib/src/main/res/values/styles.xml | 61 ++++-- 21 files changed, 497 insertions(+), 244 deletions(-) create mode 100644 app/src/main/java/pl/szczodrzynski/navigation/DrawerProfile.kt diff --git a/app/build.gradle b/app/build.gradle index 1dbb067..69dc3d0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,13 +5,13 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { - compileSdkVersion 28 + compileSdkVersion setup.compileSdk defaultConfig { applicationId "pl.szczodrzynski.navigation" - minSdkVersion 16 - targetSdkVersion 28 - versionCode 300 - versionName "0.3.0" + minSdkVersion setup.minSdk + targetSdkVersion setup.targetSdk + versionCode release.versionCode + versionName release.versionName } buildTypes { release { @@ -33,15 +33,15 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.0.2' - implementation "androidx.legacy:legacy-support-v4:1.0.0" - implementation "com.mikepenz:materialdrawer:7.0.0-rc05" + implementation "androidx.appcompat:appcompat:${versions.appcompat}" + implementation "androidx.legacy:legacy-support-v4:${versions.legacy}" + implementation "com.github.kuba2k2.MaterialDrawer:library:${versions.materialdrawer}" //implementation "com.mikepenz:crossfader:1.6.0" // do not update - implementation "com.mikepenz:iconics-core:${iconics}" // do not update. >3.1.0 Breaks jelly bean - implementation "com.mikepenz:iconics-views:${iconics}" // do not update - implementation "com.mikepenz:community-material-typeface:3.5.95.1-kotlin@aar" - implementation 'androidx.core:core-ktx:1.0.2' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - implementation "com.google.android.material:material:$material_version" + implementation "com.mikepenz:iconics-core:${versions.iconics}" // do not update. >3.1.0 Breaks jelly bean + implementation "com.mikepenz:iconics-views:${versions.iconics}" // do not update + implementation "com.mikepenz:community-material-typeface:${versions.font_cmd}@aar" + implementation "androidx.core:core-ktx:${versions.ktx}" + implementation "androidx.constraintlayout:constraintlayout:${versions.constraintLayout}" + implementation "com.google.android.material:material:${versions.material}" implementation project(":navlib") } diff --git a/app/src/main/java/pl/szczodrzynski/navigation/DrawerProfile.kt b/app/src/main/java/pl/szczodrzynski/navigation/DrawerProfile.kt new file mode 100644 index 0000000..0aa0a18 --- /dev/null +++ b/app/src/main/java/pl/szczodrzynski/navigation/DrawerProfile.kt @@ -0,0 +1,27 @@ +package pl.szczodrzynski.navigation + +import android.content.Context +import android.graphics.drawable.Drawable +import android.widget.ImageView +import pl.szczodrzynski.navlib.ImageHolder +import pl.szczodrzynski.navlib.drawer.IDrawerProfile + +class DrawerProfile( + override var id: Int, + override var name: String?, + override var subname: String?, + override var image: String? +) : IDrawerProfile { + + override fun getImageDrawable(context: Context): Drawable? { + return null + } + + override fun getImageHolder(context: Context): ImageHolder? { + return ImageHolder(image ?: return null) + } + + override fun applyImageTo(imageView: ImageView) { + ImageHolder(image ?: return).applyTo(imageView) + } +} \ No newline at end of file diff --git a/app/src/main/java/pl/szczodrzynski/navigation/MainActivity.kt b/app/src/main/java/pl/szczodrzynski/navigation/MainActivity.kt index ba17a2e..75b9b77 100644 --- a/app/src/main/java/pl/szczodrzynski/navigation/MainActivity.kt +++ b/app/src/main/java/pl/szczodrzynski/navigation/MainActivity.kt @@ -85,10 +85,6 @@ class MainActivity : AppCompatActivity() { recreate() } - commitButton.setOnClickListener { - navView.systemBarsUtil?.commit() - } - //navView.init(this) // init the drawer before SystemBarsUtil @@ -285,12 +281,12 @@ class MainActivity : AppCompatActivity() { setAccountHeaderBackground("/sdcard/ban.gif") appendProfiles( - IDrawerProfile(1, "Think Pad", "think with a pad", "/sdcard/thinkpad.gif"), - IDrawerProfile(2, "Phil Swift", "I sawed this boat in half!!!", "/sdcard/phil.jpg"), - IDrawerProfile(3, "The meme bay", "Visit my amazing website", "/sdcard/loader.gif"), - IDrawerProfile(4, "Mark Zuckerberg", "", null), - IDrawerProfile(5, "I love GDPR", "spotify:user:popjustice:playlist:5Pe51v0sHLybSEkX0m0JRf", "/sdcard/tenor2.gif"), - IDrawerProfile(6, "Gandalf", "http://sax.hol.es/", "/sdcard/facepalm.gif") + DrawerProfile(1, "Think Pad", "think with a pad", "/sdcard/thinkpad.gif"), + DrawerProfile(2, "Phil Swift", "I sawed this boat in half!!!", "/sdcard/phil.jpg"), + DrawerProfile(3, "The meme bay", "Visit my amazing website", "/sdcard/loader.gif"), + DrawerProfile(4, "Mark Zuckerberg", "", null), + DrawerProfile(5, "I love GDPR", "spotify:user:popjustice:playlist:5Pe51v0sHLybSEkX0m0JRf", "/sdcard/tenor2.gif"), + DrawerProfile(6, "Gandalf", "http://sax.hol.es/", "/sdcard/facepalm.gif") ) addProfileSettings( diff --git a/app/src/main/res/layout/sample_nav_view.xml b/app/src/main/res/layout/sample_nav_view.xml index b73bacc..48a82fc 100644 --- a/app/src/main/res/layout/sample_nav_view.xml +++ b/app/src/main/res/layout/sample_nav_view.xml @@ -29,11 +29,6 @@ android:layout_width="wrap_content" android:layout_height="48dp" android:text="Switch theme" /> -