mirror of
https://github.com/kuba2k2/NavLib.git
synced 2025-04-04 07:44:28 +02:00
Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a5a1597e40 | ||
![]() |
60cc1171f9 | ||
![]() |
8f10321820 | ||
![]() |
30d86d9618 | ||
![]() |
556d568228 | ||
![]() |
8a0e0438a5 | ||
![]() |
578306480b | ||
![]() |
7430169359 | ||
![]() |
4f08f171d6 | ||
![]() |
15c95baa6a | ||
![]() |
43fc2f10df | ||
![]() |
642d297cd0 | ||
![]() |
28cdab3414 | ||
![]() |
43f5ecdef5 | ||
![]() |
1d0e98a90e | ||
![]() |
3873fa4b04 | ||
![]() |
fd757f4228 | ||
![]() |
5c8b13c0d9 | ||
![]() |
9002237a02 | ||
![]() |
9c8fb47c52 | ||
![]() |
8b31921697 | ||
![]() |
8ae5e2b87a | ||
![]() |
e4ad01dc87 | ||
![]() |
84d6447887 | ||
![]() |
01c787405e | ||
![]() |
8a707ebec7 | ||
![]() |
3ed34a4705 | ||
![]() |
345cf00311 | ||
![]() |
9e2e4f6057 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -11,4 +11,6 @@
|
|||||||
/build
|
/build
|
||||||
/captures
|
/captures
|
||||||
.externalNativeBuild
|
.externalNativeBuild
|
||||||
/_hakerskie
|
/_hakerskie
|
||||||
|
*.apk
|
||||||
|
app/release/
|
4
.idea/gradle.xml
generated
4
.idea/gradle.xml
generated
@ -1,8 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
<option name="testRunner" value="PLATFORM" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
@ -10,10 +12,10 @@
|
|||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
<option value="$PROJECT_DIR$/app" />
|
<option value="$PROJECT_DIR$/app" />
|
||||||
<option value="$PROJECT_DIR$/navlib" />
|
<option value="$PROJECT_DIR$/navlib" />
|
||||||
|
<option value="$PROJECT_DIR$/navlib-font" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
<option name="resolveModulePerSourceSet" value="false" />
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
<option name="testRunner" value="PLATFORM" />
|
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
30
.idea/jarRepositories.xml
generated
Normal file
30
.idea/jarRepositories.xml
generated
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="BintrayJCenter" />
|
||||||
|
<option name="name" value="BintrayJCenter" />
|
||||||
|
<option name="url" value="https://jcenter.bintray.com/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven" />
|
||||||
|
<option name="name" value="maven" />
|
||||||
|
<option name="url" value="https://jitpack.io" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="Google" />
|
||||||
|
<option name="name" value="Google" />
|
||||||
|
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -5,7 +5,7 @@
|
|||||||
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
|
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
|
||||||
</configurations>
|
</configurations>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="false" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
1
.idea/runConfigurations.xml
generated
1
.idea/runConfigurations.xml
generated
@ -3,6 +3,7 @@
|
|||||||
<component name="RunConfigurationProducerService">
|
<component name="RunConfigurationProducerService">
|
||||||
<option name="ignoredProducers">
|
<option name="ignoredProducers">
|
||||||
<set>
|
<set>
|
||||||
|
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
||||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
|
|
||||||
apply plugin: 'kotlin-android-extensions'
|
apply plugin: 'kotlin-android-extensions'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion setup.compileSdk
|
compileSdkVersion setup.compileSdk
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "pl.szczodrzynski.navigation"
|
applicationId "pl.szczodrzynski.navigation"
|
||||||
minSdkVersion setup.minSdk
|
minSdkVersion setup.minSdk
|
||||||
targetSdkVersion setup.targetSdk
|
targetSdkVersion setup.targetSdk
|
||||||
versionCode release.versionCode
|
versionCode release.versionCode
|
||||||
versionName release.versionName
|
versionName release.versionName
|
||||||
|
|
||||||
|
multiDexEnabled true
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled false
|
minifyEnabled true
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,17 +33,18 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
implementation "androidx.appcompat:appcompat:${versions.appcompat}"
|
implementation "androidx.appcompat:appcompat:1.2.0"
|
||||||
implementation "androidx.legacy:legacy-support-v4:${versions.legacy}"
|
implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
||||||
implementation "com.github.kuba2k2:MaterialDrawer:${versions.materialdrawer}"
|
implementation "androidx.constraintlayout:constraintlayout:2.0.4"
|
||||||
//implementation "com.mikepenz:crossfader:1.6.0" // do not update
|
implementation "androidx.core:core-ktx:1.3.2"
|
||||||
implementation "com.mikepenz:iconics-core:${versions.iconics}" // do not update. >3.1.0 Breaks jelly bean
|
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
|
||||||
implementation "com.mikepenz:iconics-views:${versions.iconics}" // do not update
|
implementation "com.google.android.material:material:1.3.0"
|
||||||
implementation "com.mikepenz:community-material-typeface:${versions.font_cmd}@aar"
|
implementation 'androidx.multidex:multidex:2.0.1'
|
||||||
implementation "androidx.core:core-ktx:${versions.ktx}"
|
|
||||||
implementation "androidx.constraintlayout:constraintlayout:${versions.constraintLayout}"
|
implementation "com.mikepenz:iconics-views:5.3.0-b01"
|
||||||
implementation "com.google.android.material:material:${versions.material}"
|
implementation "com.mikepenz:community-material-typeface:5.8.55.0-kotlin@aar"
|
||||||
implementation "pl.droidsonroids.gif:android-gif-drawable:${versions.gifdrawable}"
|
|
||||||
|
// implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.15"
|
||||||
implementation project(":navlib")
|
implementation project(":navlib")
|
||||||
}
|
}
|
||||||
|
8
app/proguard-rules.pro
vendored
8
app/proguard-rules.pro
vendored
@ -19,3 +19,11 @@
|
|||||||
# If you keep the line number information, uncomment this to
|
# If you keep the line number information, uncomment this to
|
||||||
# hide the original source file name.
|
# hide the original source file name.
|
||||||
#-renamesourcefileattribute SourceFile
|
#-renamesourcefileattribute SourceFile
|
||||||
|
|
||||||
|
-keep class .R
|
||||||
|
-keep class **.R$* {
|
||||||
|
<fields>;
|
||||||
|
}
|
||||||
|
|
||||||
|
-keep class android.support.v7.** { *; }
|
||||||
|
-keep interface android.support.v7.** { *; }
|
@ -12,6 +12,7 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
|
android:name="androidx.multidex.MultiDexApplication"
|
||||||
android:theme="@style/AppTheme.Light"><!--
|
android:theme="@style/AppTheme.Light"><!--
|
||||||
android:windowSoftInputMode="adjustResize"-->
|
android:windowSoftInputMode="adjustResize"-->
|
||||||
<activity android:name=".MainActivity"
|
<activity android:name=".MainActivity"
|
||||||
@ -24,4 +25,4 @@
|
|||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -6,7 +6,6 @@ import android.graphics.PorterDuffColorFilter
|
|||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory
|
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory
|
||||||
import pl.droidsonroids.gif.GifDrawable
|
|
||||||
import pl.szczodrzynski.navlib.ImageHolder
|
import pl.szczodrzynski.navlib.ImageHolder
|
||||||
import pl.szczodrzynski.navlib.crc16
|
import pl.szczodrzynski.navlib.crc16
|
||||||
import pl.szczodrzynski.navlib.drawer.IDrawerProfile
|
import pl.szczodrzynski.navlib.drawer.IDrawerProfile
|
||||||
@ -17,8 +16,8 @@ import pl.szczodrzynski.navlib.getDrawableFromRes
|
|||||||
Example IDrawerProfile implementation
|
Example IDrawerProfile implementation
|
||||||
*/
|
*/
|
||||||
class DrawerProfile(
|
class DrawerProfile(
|
||||||
override var id: Int,
|
override val id: Int,
|
||||||
override var name: String?,
|
override var name: String,
|
||||||
override var subname: String?,
|
override var subname: String?,
|
||||||
override var image: String?
|
override var image: String?
|
||||||
) : IDrawerProfile {
|
) : IDrawerProfile {
|
||||||
@ -57,7 +56,7 @@ class DrawerProfile(
|
|||||||
/* if you want to use GIFs as profile drawables, add
|
/* if you want to use GIFs as profile drawables, add
|
||||||
implementation "pl.droidsonroids.gif:android-gif-drawable:${versions.gifdrawable}"
|
implementation "pl.droidsonroids.gif:android-gif-drawable:${versions.gifdrawable}"
|
||||||
*/
|
*/
|
||||||
return GifDrawable(image ?: "")
|
return null//GifDrawable(image ?: "")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return RoundedBitmapDrawableFactory.create(context.resources, image ?: "")
|
return RoundedBitmapDrawableFactory.create(context.resources, image ?: "")
|
||||||
@ -89,4 +88,4 @@ class DrawerProfile(
|
|||||||
override fun applyImageTo(imageView: ImageView) {
|
override fun applyImageTo(imageView: ImageView) {
|
||||||
getImageHolder(imageView.context).applyTo(imageView)
|
getImageHolder(imageView.context).applyTo(imageView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,16 +8,15 @@ import android.view.Gravity
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.mikepenz.iconics.IconicsColor
|
import com.mikepenz.iconics.Iconics
|
||||||
import com.mikepenz.iconics.IconicsDrawable
|
import com.mikepenz.iconics.IconicsDrawable
|
||||||
import com.mikepenz.iconics.IconicsSize
|
|
||||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
||||||
import com.mikepenz.materialdrawer.Drawer
|
import com.mikepenz.iconics.utils.actionBar
|
||||||
|
import com.mikepenz.iconics.utils.paddingDp
|
||||||
import com.mikepenz.materialdrawer.holder.StringHolder
|
import com.mikepenz.materialdrawer.holder.StringHolder
|
||||||
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem
|
|
||||||
import com.mikepenz.materialdrawer.model.ProfileDrawerItem
|
|
||||||
import com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem
|
import com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem
|
||||||
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
|
import com.mikepenz.materialdrawer.model.interfaces.*
|
||||||
|
import com.mikepenz.materialdrawer.model.utils.withIsHiddenInMiniDrawer
|
||||||
import kotlinx.android.synthetic.main.sample_nav_view.*
|
import kotlinx.android.synthetic.main.sample_nav_view.*
|
||||||
import pl.szczodrzynski.navlib.SystemBarsUtil
|
import pl.szczodrzynski.navlib.SystemBarsUtil
|
||||||
import pl.szczodrzynski.navlib.SystemBarsUtil.Companion.COLOR_DO_NOT_CHANGE
|
import pl.szczodrzynski.navlib.SystemBarsUtil.Companion.COLOR_DO_NOT_CHANGE
|
||||||
@ -29,9 +28,10 @@ import pl.szczodrzynski.navlib.bottomsheet.NavBottomSheet.Companion.SORT_MODE_DE
|
|||||||
import pl.szczodrzynski.navlib.bottomsheet.NavBottomSheet.Companion.TOGGLE_GROUP_SORTING_ORDER
|
import pl.szczodrzynski.navlib.bottomsheet.NavBottomSheet.Companion.TOGGLE_GROUP_SORTING_ORDER
|
||||||
import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetPrimaryItem
|
import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetPrimaryItem
|
||||||
import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetSeparatorItem
|
import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetSeparatorItem
|
||||||
import pl.szczodrzynski.navlib.drawer.IDrawerProfile
|
import pl.szczodrzynski.navlib.colorAttr
|
||||||
import pl.szczodrzynski.navlib.drawer.items.DrawerPrimaryItem
|
import pl.szczodrzynski.navlib.drawer.items.DrawerPrimaryItem
|
||||||
import pl.szczodrzynski.navlib.getColorFromAttr
|
import pl.szczodrzynski.navlib.getColorFromAttr
|
||||||
|
import pl.szczodrzynski.navlib.withIcon
|
||||||
|
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
@ -43,6 +43,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
Iconics.respectFontBoundsDefault = true
|
||||||
|
|
||||||
if (darkTheme == null)
|
if (darkTheme == null)
|
||||||
darkTheme = getSharedPreferences("prefs", Context.MODE_PRIVATE).getBoolean("darkTheme", false)
|
darkTheme = getSharedPreferences("prefs", Context.MODE_PRIVATE).getBoolean("darkTheme", false)
|
||||||
|
|
||||||
@ -213,13 +215,22 @@ class MainActivity : AppCompatActivity() {
|
|||||||
navView.bottomSheet.enableDragToOpen = isChecked
|
navView.bottomSheet.enableDragToOpen = isChecked
|
||||||
}
|
}
|
||||||
|
|
||||||
navView.bottomBar.fabIcon = CommunityMaterial.Icon2.cmd_pencil
|
navView.bottomBar.fabIcon = CommunityMaterial.Icon3.cmd_pencil
|
||||||
navView.bottomBar.fabExtendedText = "Compose"
|
navView.bottomBar.fabExtendedText = "Compose"
|
||||||
navView.bottomBar.fabExtended = false
|
navView.bottomBar.fabExtended = false
|
||||||
|
|
||||||
|
rippleButton.setOnClickListener {
|
||||||
|
navView.gainAttentionOnBottomBar()
|
||||||
|
}
|
||||||
|
|
||||||
|
navView.toolbar.subtitleFormat = R.string.toolbar_subtitle
|
||||||
|
navView.toolbar.subtitleFormatWithUnread = R.plurals.toolbar_subtitle_with_unread
|
||||||
|
|
||||||
navView.drawer.apply {
|
navView.drawer.apply {
|
||||||
|
|
||||||
|
miniDrawerVisiblePortrait = true
|
||||||
|
miniDrawerVisibleLandscape = null
|
||||||
|
|
||||||
addUnreadCounterType(type = 10, drawerItem = 1)
|
addUnreadCounterType(type = 10, drawerItem = 1)
|
||||||
addUnreadCounterType(type = 20, drawerItem = 2)
|
addUnreadCounterType(type = 20, drawerItem = 2)
|
||||||
addUnreadCounterType(type = 30, drawerItem = 60)
|
addUnreadCounterType(type = 30, drawerItem = 60)
|
||||||
@ -232,13 +243,13 @@ class MainActivity : AppCompatActivity() {
|
|||||||
.withSelected(true)
|
.withSelected(true)
|
||||||
.withIdentifier(1)
|
.withIdentifier(1)
|
||||||
.withBadgeStyle(badgeStyle)
|
.withBadgeStyle(badgeStyle)
|
||||||
.withIcon(CommunityMaterial.Icon.cmd_google_home),
|
.withIcon(CommunityMaterial.Icon2.cmd_google_home),
|
||||||
|
|
||||||
DrawerPrimaryItem()
|
DrawerPrimaryItem()
|
||||||
.withIdentifier(2)
|
.withIdentifier(2)
|
||||||
.withName("Settings")
|
.withName("Settings")
|
||||||
.withBadgeStyle(badgeStyle)
|
.withBadgeStyle(badgeStyle)
|
||||||
.withIcon(CommunityMaterial.Icon2.cmd_settings),
|
.withIcon(CommunityMaterial.Icon.cmd_cog_outline),
|
||||||
|
|
||||||
DrawerPrimaryItem().withName("iOS")
|
DrawerPrimaryItem().withName("iOS")
|
||||||
.withIdentifier(60)
|
.withIdentifier(60)
|
||||||
@ -253,10 +264,10 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
DrawerPrimaryItem().withName("Lock screen")
|
DrawerPrimaryItem().withName("Lock screen")
|
||||||
.withDescription("aaand not visible in Mini Drawer")
|
.withDescription("aaand not visible in Mini Drawer")
|
||||||
.withHiddenInMiniDrawer(true)
|
|
||||||
.withIdentifier(62)
|
.withIdentifier(62)
|
||||||
|
.withIsHiddenInMiniDrawer(true)
|
||||||
.withBadgeStyle(badgeStyle)
|
.withBadgeStyle(badgeStyle)
|
||||||
.withIcon(CommunityMaterial.Icon.cmd_fingerprint),
|
.withIcon(CommunityMaterial.Icon2.cmd_fingerprint),
|
||||||
|
|
||||||
DrawerPrimaryItem().withName("HDR enable/disable")
|
DrawerPrimaryItem().withName("HDR enable/disable")
|
||||||
.withTag(0)
|
.withTag(0)
|
||||||
@ -269,17 +280,14 @@ class MainActivity : AppCompatActivity() {
|
|||||||
.withDescription("Because we all hate ads")
|
.withDescription("Because we all hate ads")
|
||||||
.withIdentifier(64)
|
.withIdentifier(64)
|
||||||
.withBadgeStyle(badgeStyle)
|
.withBadgeStyle(badgeStyle)
|
||||||
.withIcon(CommunityMaterial.Icon.cmd_adchoices),
|
.withIcon(CommunityMaterial.Icon2.cmd_google_ads),
|
||||||
|
|
||||||
DrawerPrimaryItem().withName("Wonderful browsing experience and this is a long string")
|
DrawerPrimaryItem().withName("Wonderful browsing experience and this is a long string")
|
||||||
.withIdentifier(65)
|
.withIdentifier(65)
|
||||||
.withBadgeStyle(badgeStyle)
|
.withBadgeStyle(badgeStyle)
|
||||||
.withIcon(CommunityMaterial.Icon2.cmd_internet_explorer)
|
.withIcon(CommunityMaterial.Icon3.cmd_microsoft_internet_explorer)
|
||||||
)
|
)
|
||||||
|
|
||||||
setUnreadCount(2, 20, 30) // phil swift has 30 unreads on "Settings item"
|
|
||||||
setUnreadCount(4, 40, 1000) // mark has 99+ unreads on "Lock screen item"
|
|
||||||
|
|
||||||
//setAccountHeaderBackground("/sdcard/ban.gif")
|
//setAccountHeaderBackground("/sdcard/ban.gif")
|
||||||
|
|
||||||
appendProfiles(
|
appendProfiles(
|
||||||
@ -291,28 +299,31 @@ class MainActivity : AppCompatActivity() {
|
|||||||
DrawerProfile(6, "Gandalf", "http://sax.hol.es/", null)
|
DrawerProfile(6, "Gandalf", "http://sax.hol.es/", null)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
setUnreadCount(2, 20, 30) // phil swift has 30 unreads on "Settings item"
|
||||||
|
setUnreadCount(4, 40, 1000) // mark has 99+ unreads on "Lock screen item"
|
||||||
|
|
||||||
addProfileSettings(
|
addProfileSettings(
|
||||||
ProfileSettingDrawerItem()
|
ProfileSettingDrawerItem()
|
||||||
.withName("Add Account")
|
.withName("Add Account")
|
||||||
.withDescription("Add new GitHub Account")
|
.withDescription("Add new GitHub Account")
|
||||||
.withIcon(
|
.withIcon(
|
||||||
IconicsDrawable(context, CommunityMaterial.Icon2.cmd_plus)
|
IconicsDrawable(context, CommunityMaterial.Icon3.cmd_plus).apply {
|
||||||
.actionBar()
|
actionBar()
|
||||||
.padding(IconicsSize.dp(5))
|
paddingDp = 5
|
||||||
.color(IconicsColor.colorRes(pl.szczodrzynski.navlib.R.color.material_drawer_dark_primary_text))
|
colorAttr(context, R.attr.materialDrawerPrimaryText)
|
||||||
)
|
|
||||||
.withOnDrawerItemClickListener(object : Drawer.OnDrawerItemClickListener {
|
|
||||||
override fun onItemClick(view: View?, position: Int, drawerItem: IDrawerItem<*>): Boolean {
|
|
||||||
Toast.makeText(context, "Add account", Toast.LENGTH_SHORT).show()
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}),
|
)
|
||||||
|
.withOnDrawerItemClickListener { v, item, position ->
|
||||||
|
Toast.makeText(context, "Add account", Toast.LENGTH_SHORT).show()
|
||||||
|
true
|
||||||
|
},
|
||||||
ProfileSettingDrawerItem()
|
ProfileSettingDrawerItem()
|
||||||
.withName("Manage Account")
|
.withName("Manage Account")
|
||||||
.withIcon(CommunityMaterial.Icon2.cmd_settings)
|
.withIcon(CommunityMaterial.Icon.cmd_cog_outline)
|
||||||
)
|
)
|
||||||
|
|
||||||
drawerItemSelectedListener = { id, position, drawerItem ->
|
drawerItemSelectedListener = { id, position, drawerItem ->
|
||||||
|
navView.gainAttentionOnBottomBar()
|
||||||
if (id == 1 || id == 2) {
|
if (id == 1 || id == 2) {
|
||||||
getItemById(id) {
|
getItemById(id) {
|
||||||
if (it is DrawerPrimaryItem) {
|
if (it is DrawerPrimaryItem) {
|
||||||
@ -328,6 +339,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
// drawer item ID)
|
// drawer item ID)
|
||||||
// See with "Settings" when it.badge AND UnreadCounter is present.
|
// See with "Settings" when it.badge AND UnreadCounter is present.
|
||||||
//
|
//
|
||||||
|
// and it of course does not update the badge
|
||||||
|
//
|
||||||
// just do not do this.
|
// just do not do this.
|
||||||
it.badge = StringHolder("${it.tag as Int * 10}")
|
it.badge = StringHolder("${it.tag as Int * 10}")
|
||||||
}
|
}
|
||||||
@ -346,12 +359,16 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setSelection.setOnClickListener {
|
||||||
|
navView.drawer.setSelection(id = 1, fireOnClick = false)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
navView.bottomSheet.apply {
|
navView.bottomSheet.apply {
|
||||||
this += BottomSheetPrimaryItem(true)
|
this += BottomSheetPrimaryItem(true)
|
||||||
.withId(1)
|
.withId(1)
|
||||||
.withTitle("Compose")
|
.withTitle("Compose")
|
||||||
.withIcon(CommunityMaterial.Icon2.cmd_pencil)
|
.withIcon(CommunityMaterial.Icon3.cmd_pencil)
|
||||||
.withOnClickListener(View.OnClickListener {
|
.withOnClickListener(View.OnClickListener {
|
||||||
Toast.makeText(this@MainActivity, "Compose message", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this@MainActivity, "Compose message", Toast.LENGTH_SHORT).show()
|
||||||
})
|
})
|
||||||
@ -359,7 +376,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
this += BottomSheetPrimaryItem(false)
|
this += BottomSheetPrimaryItem(false)
|
||||||
.withId(3)
|
.withId(3)
|
||||||
.withTitle("Synchronise")
|
.withTitle("Synchronise")
|
||||||
.withIcon(CommunityMaterial.Icon2.cmd_sync)
|
.withIcon(CommunityMaterial.Icon3.cmd_sync)
|
||||||
.withOnClickListener(View.OnClickListener {
|
.withOnClickListener(View.OnClickListener {
|
||||||
Toast.makeText(this@MainActivity, "Synchronising...", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this@MainActivity, "Synchronising...", Toast.LENGTH_SHORT).show()
|
||||||
})
|
})
|
||||||
@ -391,7 +408,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
textInputEnabled = true
|
textInputEnabled = true
|
||||||
textInputHint = "Search"
|
textInputHint = "Search"
|
||||||
textInputHelperText = "0 messages found"
|
textInputHelperText = "0 messages found"
|
||||||
textInputIcon = CommunityMaterial.Icon2.cmd_magnify
|
textInputIcon = CommunityMaterial.Icon3.cmd_magnify
|
||||||
textInputChangedListener = object : NavBottomSheet.OnTextInputChangedListener {
|
textInputChangedListener = object : NavBottomSheet.OnTextInputChangedListener {
|
||||||
override fun onTextChanged(s: String, start: Int, before: Int, count: Int) {
|
override fun onTextChanged(s: String, start: Int, before: Int, count: Int) {
|
||||||
navView.toolbar.subtitle = s
|
navView.toolbar.subtitle = s
|
||||||
|
@ -29,6 +29,17 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:text="Switch theme" />
|
android:text="Switch theme" />
|
||||||
|
<Button
|
||||||
|
android:id="@+id/rippleButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:text="Ripple bottombar" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/setSelection"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:text="Set selection" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
8
app/src/main/res/values-pl/plurals.xml
Normal file
8
app/src/main/res/values-pl/plurals.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<plurals name="toolbar_subtitle_with_unread">
|
||||||
|
<item quantity="one">%1$s - %2$d nieprzeczytane</item>
|
||||||
|
<item quantity="few">%1$s - %2$d nieprzeczytane</item>
|
||||||
|
<item quantity="many">%1$s - %2$d nieprzeczytanych</item>
|
||||||
|
</plurals>
|
||||||
|
</resources>
|
6
app/src/main/res/values/plurals.xml
Normal file
6
app/src/main/res/values/plurals.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<plurals name="toolbar_subtitle_with_unread">
|
||||||
|
<item quantity="other">%1$s - %2$d unread</item>
|
||||||
|
</plurals>
|
||||||
|
</resources>
|
45
build.gradle
45
build.gradle
@ -2,49 +2,18 @@
|
|||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext {
|
ext {
|
||||||
kotlin_version = '1.3.50'
|
kotlin_version = '1.4.31'
|
||||||
|
|
||||||
release = [
|
release = [
|
||||||
versionName: "0.4.0",
|
// major.minor.patch.rc.beta
|
||||||
versionCode: 400
|
versionName: "0.8.0",
|
||||||
|
versionCode: 80099
|
||||||
]
|
]
|
||||||
|
|
||||||
setup = [
|
setup = [
|
||||||
compileSdk: 28,
|
compileSdk: 30,
|
||||||
buildTools: "28.0.3",
|
|
||||||
minSdk : 16,
|
minSdk : 16,
|
||||||
targetSdk : 28
|
targetSdk : 30
|
||||||
]
|
|
||||||
|
|
||||||
versions = [
|
|
||||||
kotlin : "1.3.50",
|
|
||||||
ktx : "1.0.2",
|
|
||||||
|
|
||||||
androidX : '1.0.0',
|
|
||||||
annotation : '1.1.0',
|
|
||||||
recyclerView : '1.1.0-beta03',
|
|
||||||
material : '1.1.0-alpha09',
|
|
||||||
appcompat : '1.1.0-rc01',
|
|
||||||
constraintLayout : '2.0.0-beta2',
|
|
||||||
cardview : '1.0.0',
|
|
||||||
gridLayout : '1.0.0',
|
|
||||||
navigation : "2.0.0",
|
|
||||||
navigationFragment: "1.0.0",
|
|
||||||
legacy : "1.0.0",
|
|
||||||
|
|
||||||
room : "2.2.0-beta01",
|
|
||||||
lifecycle : "2.2.0-alpha03",
|
|
||||||
|
|
||||||
firebase : '17.2.0',
|
|
||||||
firebasemessaging: "20.0.0",
|
|
||||||
play_services : "17.0.0",
|
|
||||||
|
|
||||||
materialdialogs : "0.9.6.0",
|
|
||||||
materialdrawer : "62b24da031",
|
|
||||||
iconics : "4.0.1-b02",
|
|
||||||
font_cmd : "3.5.95.1-kotlin",
|
|
||||||
|
|
||||||
gifdrawable : "1.2.15"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +22,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
classpath "com.android.tools.build:gradle:4.2.0-beta06"
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
|
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
|
||||||
|
1
navlib-font/.gitignore
vendored
Normal file
1
navlib-font/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/build
|
44
navlib-font/build.gradle
Normal file
44
navlib-font/build.gradle
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 Mike Penz
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion setup.compileSdk
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
minSdkVersion setup.minSdk
|
||||||
|
targetSdkVersion setup.targetSdk
|
||||||
|
consumerProguardFiles 'consumer-proguard-rules.pro'
|
||||||
|
versionCode 10
|
||||||
|
versionName "1.0"
|
||||||
|
|
||||||
|
resValue "string", "NavLibFont_version", "${versionName}"
|
||||||
|
}
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation "com.mikepenz:iconics-typeface-api:5.3.0-b01"
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||||
|
}
|
1
navlib-font/consumer-proguard-rules.pro
Normal file
1
navlib-font/consumer-proguard-rules.pro
Normal file
@ -0,0 +1 @@
|
|||||||
|
-keep class com.mikepenz.iconics.typeface.library.navlibfont.NavLibFont { *; }
|
18
navlib-font/gradle.properties
Normal file
18
navlib-font/gradle.properties
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2019 Mike Penz
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
POM_NAME=Android-Iconics NavLibFont Typeface Library
|
||||||
|
POM_ARTIFACT_ID=navlibfont-typeface
|
||||||
|
POM_PACKAGING=aar
|
18
navlib-font/src/main/AndroidManifest.xml
Normal file
18
navlib-font/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright 2019 Mike Penz
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<manifest package="com.mikepenz.iconics.typeface.library.navlibfont" />
|
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 Mike Penz
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.mikepenz.iconics.typeface.library.navlibfont
|
||||||
|
|
||||||
|
import com.mikepenz.iconics.typeface.IIcon
|
||||||
|
import com.mikepenz.iconics.typeface.ITypeface
|
||||||
|
import java.util.LinkedList
|
||||||
|
|
||||||
|
@Suppress("EnumEntryName")
|
||||||
|
object NavLibFont : ITypeface {
|
||||||
|
|
||||||
|
override val fontRes: Int
|
||||||
|
get() = R.font.navlibfont_font_v1_0
|
||||||
|
|
||||||
|
override val characters: Map<String, Char> by lazy {
|
||||||
|
Icon.values().associate { it.name to it.character }
|
||||||
|
}
|
||||||
|
|
||||||
|
override val mappingPrefix: String
|
||||||
|
get() = "nav"
|
||||||
|
|
||||||
|
override val fontName: String
|
||||||
|
get() = "NavLibFont"
|
||||||
|
|
||||||
|
override val version: String
|
||||||
|
get() = "1.0"
|
||||||
|
|
||||||
|
override val iconCount: Int
|
||||||
|
get() = characters.size
|
||||||
|
|
||||||
|
override val icons: List<String>
|
||||||
|
get() = characters.keys.toCollection(LinkedList())
|
||||||
|
|
||||||
|
override val author: String
|
||||||
|
get() = "Kuba Szczodrzyński"
|
||||||
|
|
||||||
|
override val url: String
|
||||||
|
get() = "https://github.com/kuba2k2/NavLib"
|
||||||
|
|
||||||
|
override val description: String
|
||||||
|
get() = ""
|
||||||
|
|
||||||
|
override val license: String
|
||||||
|
get() = ""
|
||||||
|
|
||||||
|
override val licenseUrl: String
|
||||||
|
get() = ""
|
||||||
|
|
||||||
|
override fun getIcon(key: String): IIcon = Icon.valueOf(key)
|
||||||
|
|
||||||
|
enum class Icon constructor(override val character: Char) : IIcon {
|
||||||
|
nav_dots_vertical('\ue801'),
|
||||||
|
nav_menu('\ue800'),
|
||||||
|
nav_sort_ascending('\ue803'),
|
||||||
|
nav_sort_descending('\ue802');
|
||||||
|
|
||||||
|
override val typeface: ITypeface by lazy { NavLibFont }
|
||||||
|
}
|
||||||
|
}
|
BIN
navlib-font/src/main/res/font/navlibfont_font_v1_0.ttf
Normal file
BIN
navlib-font/src/main/res/font/navlibfont_font_v1_0.ttf
Normal file
Binary file not shown.
20
navlib-font/src/main/res/values/font_addon.xml
Normal file
20
navlib-font/src/main/res/values/font_addon.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2019 Mike Penz
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<string name="define_font_NavLibFont">com.mikepenz.iconics.typeface.library.navlibfont.NavLibFont</string>
|
||||||
|
</resources>
|
31
navlib-font/src/main/res/values/font_description.xml
Normal file
31
navlib-font/src/main/res/values/font_description.xml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2019 Mike Penz
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<string name="define_FontAwesome">year;author;libraryName;libraryWebsite</string>
|
||||||
|
<string name="library_FontAwesome_author">Kuba Szczodrzyński</string>
|
||||||
|
<string name="library_FontAwesome_authorWebsite">https://github.com/kuba2k2/NavLib</string>
|
||||||
|
<string name="library_FontAwesome_libraryName">NavLibFont</string>
|
||||||
|
<string name="library_FontAwesome_libraryDescription"></string>
|
||||||
|
<string name="library_FontAwesome_libraryWebsite">https://github.com/kuba2k2/NavLib</string>
|
||||||
|
<string name="library_FontAwesome_libraryVersion">@string/NavLibFont_version</string>
|
||||||
|
<string name="library_FontAwesome_licenseId"></string>
|
||||||
|
<string name="library_FontAwesome_isOpenSource">true</string>
|
||||||
|
<string name="library_FontAwesome_repositoryLink">https://github.com/kuba2k2/NavLib</string>
|
||||||
|
<!-- Custom variables section -->
|
||||||
|
<string name="library_FontAwesome_year">2018</string>
|
||||||
|
</resources>
|
@ -2,6 +2,7 @@ apply plugin: 'com.android.library'
|
|||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
apply plugin: 'kotlin-kapt'
|
apply plugin: 'kotlin-kapt'
|
||||||
apply plugin: 'kotlin-android-extensions'
|
apply plugin: 'kotlin-android-extensions'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion setup.compileSdk
|
compileSdkVersion setup.compileSdk
|
||||||
|
|
||||||
@ -23,8 +24,8 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dataBinding {
|
buildFeatures {
|
||||||
enabled = true
|
dataBinding = true
|
||||||
}
|
}
|
||||||
|
|
||||||
packagingOptions {
|
packagingOptions {
|
||||||
@ -35,19 +36,20 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
|
||||||
implementation "androidx.annotation:annotation:${versions.annotation}"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
implementation "androidx.appcompat:appcompat:${versions.appcompat}"
|
implementation "androidx.appcompat:appcompat:1.2.0"
|
||||||
implementation "androidx.constraintlayout:constraintlayout:${versions.constraintLayout}"
|
implementation "androidx.core:core-ktx:1.3.2"
|
||||||
implementation "androidx.core:core-ktx:${versions.ktx}"
|
implementation "androidx.recyclerview:recyclerview:1.1.0"
|
||||||
implementation "androidx.gridlayout:gridlayout:1.0.0"
|
implementation "com.google.android.material:material:1.3.0"
|
||||||
implementation "androidx.legacy:legacy-support-v4:${versions.legacy}"
|
|
||||||
implementation "androidx.recyclerview:recyclerview:${versions.recyclerView}"
|
|
||||||
implementation "com.google.android.material:material:${versions.material}"
|
|
||||||
|
|
||||||
api "com.github.kuba2k2:MaterialDrawer:${versions.materialdrawer}"
|
api "com.mikepenz:materialize:1.2.1"
|
||||||
api "com.mikepenz:community-material-typeface:${versions.font_cmd}@aar"
|
api "com.mikepenz:materialdrawer:8.3.3"
|
||||||
api "com.mikepenz:iconics-core:${versions.iconics}"
|
api "com.mikepenz:iconics-core:5.3.0-b01"
|
||||||
implementation "com.mikepenz:itemanimators:1.1.0"
|
api "com.mikepenz:itemanimators:1.1.0"
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}"
|
|
||||||
implementation "pl.droidsonroids.gif:android-gif-drawable:${versions.gifdrawable}"
|
compileOnly "pl.droidsonroids.gif:android-gif-drawable:1.2.15"
|
||||||
|
|
||||||
|
implementation "com.balysv:material-ripple:1.0.2"
|
||||||
|
|
||||||
|
implementation project(":navlib-font")
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
-keep class androidx.drawerlayout.widget.DrawerLayout { *; }
|
2
navlib/proguard-rules.pro
vendored
2
navlib/proguard-rules.pro
vendored
@ -19,3 +19,5 @@
|
|||||||
# If you keep the line number information, uncomment this to
|
# If you keep the line number information, uncomment this to
|
||||||
# hide the original source file name.
|
# hide the original source file name.
|
||||||
#-renamesourcefileattribute SourceFile
|
#-renamesourcefileattribute SourceFile
|
||||||
|
|
||||||
|
-keep class androidx.drawerlayout.widget.DrawerLayout { *; }
|
||||||
|
109
navlib/src/main/java/pl/szczodrzynski/navlib/BadgeDrawable.java
Normal file
109
navlib/src/main/java/pl/szczodrzynski/navlib/BadgeDrawable.java
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
package pl.szczodrzynski.navlib;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.ColorFilter;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.PixelFormat;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.graphics.Typeface;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
|
public class BadgeDrawable extends Drawable {
|
||||||
|
|
||||||
|
private Paint mBadgePaint;
|
||||||
|
private Paint mBadgePaint1;
|
||||||
|
private Paint mTextPaint;
|
||||||
|
private Rect mTxtRect = new Rect();
|
||||||
|
|
||||||
|
private String mCount = "";
|
||||||
|
private boolean mWillDraw = false;
|
||||||
|
|
||||||
|
public BadgeDrawable(Context context) {
|
||||||
|
float mTextSize = context.getResources().getDimension(R.dimen.badge_text_size);
|
||||||
|
|
||||||
|
mBadgePaint = new Paint();
|
||||||
|
mBadgePaint.setColor(0xffff3d00);
|
||||||
|
mBadgePaint.setAntiAlias(true);
|
||||||
|
mBadgePaint.setStyle(Paint.Style.FILL);
|
||||||
|
/*mBadgePaint1 = new Paint();
|
||||||
|
mBadgePaint1.setColor(ContextCompat.getColor(context.getApplicationContext(), R.color.grey_ivory5));
|
||||||
|
mBadgePaint1.setAntiAlias(true);
|
||||||
|
mBadgePaint1.setStyle(Paint.Style.FILL);*/
|
||||||
|
|
||||||
|
mTextPaint = new Paint();
|
||||||
|
mTextPaint.setColor(Color.WHITE);
|
||||||
|
mTextPaint.setTypeface(Typeface.DEFAULT);
|
||||||
|
mTextPaint.setTextSize(mTextSize);
|
||||||
|
mTextPaint.setAntiAlias(true);
|
||||||
|
mTextPaint.setTextAlign(Paint.Align.CENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Canvas canvas) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!mWillDraw) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Rect bounds = getBounds();
|
||||||
|
float width = bounds.right - bounds.left;
|
||||||
|
float height = bounds.bottom - bounds.top;
|
||||||
|
|
||||||
|
// Position the badge in the top-right quadrant of the icon.
|
||||||
|
|
||||||
|
/*Using Math.max rather than Math.min */
|
||||||
|
|
||||||
|
float radius = ((Math.max(width, height) / 2)) / 2;
|
||||||
|
float centerX = (width - radius - 1) +5;
|
||||||
|
float centerY = radius -5;
|
||||||
|
if(mCount.length() <= 2){
|
||||||
|
// Draw badge circle.
|
||||||
|
//canvas.drawCircle(centerX, centerY, (int)(radius+7.5), mBadgePaint1);
|
||||||
|
canvas.drawCircle(centerX, centerY, (int)(radius+5.5), mBadgePaint);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//canvas.drawCircle(centerX, centerY, (int)(radius+8.5), mBadgePaint1);
|
||||||
|
canvas.drawCircle(centerX, centerY, (int)(radius+6.5), mBadgePaint);
|
||||||
|
// canvas.drawRoundRect(radius, radius, radius, radius, 10, 10, mBadgePaint);
|
||||||
|
}
|
||||||
|
// Draw badge count text inside the circle.
|
||||||
|
mTextPaint.getTextBounds(mCount, 0, mCount.length(), mTxtRect);
|
||||||
|
float textHeight = mTxtRect.bottom - mTxtRect.top;
|
||||||
|
float textY = centerY + (textHeight / 2f);
|
||||||
|
if(mCount.length() > 2)
|
||||||
|
canvas.drawText("99+", centerX, textY, mTextPaint);
|
||||||
|
else
|
||||||
|
canvas.drawText(mCount, centerX, textY, mTextPaint);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Sets the count (i.e notifications) to display.
|
||||||
|
*/
|
||||||
|
public void setCount(String count) {
|
||||||
|
mCount = count;
|
||||||
|
|
||||||
|
// Only draw a badge if there are notifications.
|
||||||
|
mWillDraw = !count.equalsIgnoreCase("0");
|
||||||
|
invalidateSelf();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAlpha(int alpha) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setColorFilter(ColorFilter cf) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOpacity() {
|
||||||
|
return PixelFormat.UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
@ -10,7 +10,6 @@ import android.util.AttributeSet
|
|||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewOutlineProvider
|
import android.view.ViewOutlineProvider
|
||||||
import androidx.appcompat.widget.AppCompatImageView
|
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
import com.mikepenz.materialdrawer.R
|
import com.mikepenz.materialdrawer.R
|
||||||
import com.mikepenz.materialdrawer.util.DrawerImageLoader
|
import com.mikepenz.materialdrawer.util.DrawerImageLoader
|
||||||
@ -22,7 +21,7 @@ import pl.droidsonroids.gif.GifImageView
|
|||||||
* drawable on top. This is useful for applying a beveled look to image contents, but is also
|
* drawable on top. This is useful for applying a beveled look to image contents, but is also
|
||||||
* flexible enough for use with other desired aesthetics.
|
* flexible enough for use with other desired aesthetics.
|
||||||
*/
|
*/
|
||||||
open class BezelGifImageView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0) : GifImageView(context, attrs, defStyle) {
|
open class BezelImageView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0) : GifImageView(context, attrs, defStyle) {
|
||||||
private val mBlackPaint: Paint
|
private val mBlackPaint: Paint
|
||||||
private val mMaskedPaint: Paint
|
private val mMaskedPaint: Paint
|
||||||
|
|
||||||
@ -54,14 +53,14 @@ open class BezelGifImageView @JvmOverloads constructor(context: Context, attrs:
|
|||||||
// Attribute initialization
|
// Attribute initialization
|
||||||
val a = context.obtainStyledAttributes(attrs, R.styleable.BezelImageView, defStyle, R.style.BezelImageView)
|
val a = context.obtainStyledAttributes(attrs, R.styleable.BezelImageView, defStyle, R.style.BezelImageView)
|
||||||
|
|
||||||
mMaskDrawable = a.getDrawable(R.styleable.BezelImageView_biv_maskDrawable)
|
mMaskDrawable = a.getDrawable(R.styleable.BezelImageView_materialDrawerMaskDrawable)
|
||||||
if (mMaskDrawable != null) {
|
if (mMaskDrawable != null) {
|
||||||
mMaskDrawable.callback = this
|
mMaskDrawable.callback = this
|
||||||
}
|
}
|
||||||
|
|
||||||
mDrawCircularShadow = a.getBoolean(R.styleable.BezelImageView_biv_drawCircularShadow, true)
|
mDrawCircularShadow = a.getBoolean(R.styleable.BezelImageView_materialDrawerDrawCircularShadow, true)
|
||||||
|
|
||||||
mSelectorColor = a.getColor(R.styleable.BezelImageView_biv_selectorOnPress, 0)
|
mSelectorColor = a.getColor(R.styleable.BezelImageView_materialDrawerSelectorOnPress, 0)
|
||||||
|
|
||||||
a.recycle()
|
a.recycle()
|
||||||
|
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package pl.szczodrzynski.navlib
|
package pl.szczodrzynski.navlib
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.mikepenz.iconics.typeface.IIcon
|
||||||
import com.mikepenz.materialdrawer.*
|
import com.mikepenz.materialdrawer.*
|
||||||
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
|
import com.mikepenz.materialdrawer.holder.StringHolder
|
||||||
import com.mikepenz.materialdrawer.model.interfaces.IProfile
|
import com.mikepenz.materialdrawer.model.AbstractDrawerItem
|
||||||
|
import com.mikepenz.materialdrawer.model.BaseDrawerItem
|
||||||
|
import com.mikepenz.materialdrawer.model.interfaces.*
|
||||||
|
import com.mikepenz.materialdrawer.util.getDrawerItem
|
||||||
|
import com.mikepenz.materialdrawer.util.updateItem
|
||||||
|
import com.mikepenz.materialdrawer.widget.MaterialDrawerSliderView
|
||||||
|
|
||||||
fun DrawerBuilder.withOnDrawerItemClickListener(listener: (view: View?, position: Int, drawerItem: IDrawerItem<*>) -> Boolean): DrawerBuilder {
|
/*inline fun DrawerBuilder.withOnDrawerItemClickListener(crossinline listener: (view: View?, position: Int, drawerItem: IDrawerItem<*>) -> Boolean): DrawerBuilder {
|
||||||
return this.withOnDrawerItemClickListener(object : Drawer.OnDrawerItemClickListener {
|
return this.withOnDrawerItemClickListener(object : Drawer.OnDrawerItemClickListener {
|
||||||
override fun onItemClick(view: View?, position: Int, drawerItem: IDrawerItem<*>): Boolean {
|
override fun onItemClick(view: View?, position: Int, drawerItem: IDrawerItem<*>): Boolean {
|
||||||
return listener(view, position, drawerItem)
|
return listener(view, position, drawerItem)
|
||||||
@ -13,7 +20,7 @@ fun DrawerBuilder.withOnDrawerItemClickListener(listener: (view: View?, position
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fun DrawerBuilder.withOnDrawerItemLongClickListener(listener: (view: View, position: Int, drawerItem: IDrawerItem<*>) -> Boolean): DrawerBuilder {
|
inline fun DrawerBuilder.withOnDrawerItemLongClickListener(crossinline listener: (view: View, position: Int, drawerItem: IDrawerItem<*>) -> Boolean): DrawerBuilder {
|
||||||
return this.withOnDrawerItemLongClickListener(object : Drawer.OnDrawerItemLongClickListener {
|
return this.withOnDrawerItemLongClickListener(object : Drawer.OnDrawerItemLongClickListener {
|
||||||
override fun onItemLongClick(view: View, position: Int, drawerItem: IDrawerItem<*>): Boolean {
|
override fun onItemLongClick(view: View, position: Int, drawerItem: IDrawerItem<*>): Boolean {
|
||||||
return listener(view, position, drawerItem)
|
return listener(view, position, drawerItem)
|
||||||
@ -21,7 +28,7 @@ fun DrawerBuilder.withOnDrawerItemLongClickListener(listener: (view: View, posit
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fun AccountHeaderBuilder.withOnAccountHeaderListener(listener: (view: View?, profile: IProfile<*>, current: Boolean) -> Boolean): AccountHeaderBuilder {
|
inline fun AccountHeaderBuilder.withOnAccountHeaderListener(crossinline listener: (view: View?, profile: IProfile<*>, current: Boolean) -> Boolean): AccountHeaderBuilder {
|
||||||
return this.withOnAccountHeaderListener(object : AccountHeader.OnAccountHeaderListener {
|
return this.withOnAccountHeaderListener(object : AccountHeader.OnAccountHeaderListener {
|
||||||
override fun onProfileChanged(view: View?, profile: IProfile<*>, current: Boolean): Boolean {
|
override fun onProfileChanged(view: View?, profile: IProfile<*>, current: Boolean): Boolean {
|
||||||
return listener(view, profile, current)
|
return listener(view, profile, current)
|
||||||
@ -29,7 +36,7 @@ fun AccountHeaderBuilder.withOnAccountHeaderListener(listener: (view: View?, pro
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fun AccountHeaderBuilder.withOnAccountHeaderItemLongClickListener(listener: (view: View, profile: IProfile<*>, current: Boolean) -> Boolean): AccountHeaderBuilder {
|
inline fun AccountHeaderBuilder.withOnAccountHeaderItemLongClickListener(crossinline listener: (view: View, profile: IProfile<*>, current: Boolean) -> Boolean): AccountHeaderBuilder {
|
||||||
return this.withOnAccountHeaderItemLongClickListener(object : AccountHeader.OnAccountHeaderItemLongClickListener {
|
return this.withOnAccountHeaderItemLongClickListener(object : AccountHeader.OnAccountHeaderItemLongClickListener {
|
||||||
override fun onProfileLongClick(view: View, profile: IProfile<*>, current: Boolean): Boolean {
|
override fun onProfileLongClick(view: View, profile: IProfile<*>, current: Boolean): Boolean {
|
||||||
return listener(view, profile, current)
|
return listener(view, profile, current)
|
||||||
@ -37,13 +44,13 @@ fun AccountHeaderBuilder.withOnAccountHeaderItemLongClickListener(listener: (vie
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fun AccountHeaderBuilder.withOnAccountHeaderProfileImageListener(
|
inline fun AccountHeaderBuilder.withOnAccountHeaderProfileImageListener(
|
||||||
onClick: (
|
crossinline onClick: (
|
||||||
view: View,
|
view: View,
|
||||||
profile: IProfile<*>,
|
profile: IProfile<*>,
|
||||||
current: Boolean
|
current: Boolean
|
||||||
) -> Boolean,
|
) -> Boolean,
|
||||||
onLongClick: (
|
crossinline onLongClick: (
|
||||||
view: View,
|
view: View,
|
||||||
profile: IProfile<*>,
|
profile: IProfile<*>,
|
||||||
current: Boolean
|
current: Boolean
|
||||||
@ -59,10 +66,20 @@ fun AccountHeaderBuilder.withOnAccountHeaderProfileImageListener(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fun MiniDrawer.withOnMiniDrawerItemClickListener(listener: (view: View?, position: Int, drawerItem: IDrawerItem<*>, type: Int) -> Boolean): MiniDrawer {
|
inline fun MiniDrawer.withOnMiniDrawerItemClickListener(crossinline listener: (view: View?, position: Int, drawerItem: IDrawerItem<*>, type: Int) -> Boolean): MiniDrawer {
|
||||||
return this.withOnMiniDrawerItemClickListener(object : MiniDrawer.OnMiniDrawerItemClickListener {
|
return this.withOnMiniDrawerItemClickListener(object : MiniDrawer.OnMiniDrawerItemClickListener {
|
||||||
override fun onItemClick(view: View?, position: Int, drawerItem: IDrawerItem<*>, type: Int): Boolean {
|
override fun onItemClick(view: View?, position: Int, drawerItem: IDrawerItem<*>, type: Int): Boolean {
|
||||||
return listener(view, position, drawerItem, type)
|
return listener(view, position, drawerItem, type)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
fun MaterialDrawerSliderView.updateBadge(identifier: Long, badge: StringHolder?) {
|
||||||
|
val drawerItem = getDrawerItem(identifier)
|
||||||
|
if (drawerItem is Badgeable) {
|
||||||
|
drawerItem.withBadge(badge)
|
||||||
|
updateItem(drawerItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T : Iconable> T.withIcon(icon: IIcon) = withIcon(pl.szczodrzynski.navlib.ImageHolder(icon))
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
package pl.szczodrzynski.navlib
|
package pl.szczodrzynski.navlib
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.res.ColorStateList
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.PorterDuff
|
import android.graphics.PorterDuff
|
||||||
import android.graphics.PorterDuffColorFilter
|
import android.graphics.PorterDuffColorFilter
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.view.View
|
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import androidx.appcompat.content.res.AppCompatResources
|
import androidx.appcompat.content.res.AppCompatResources
|
||||||
import com.mikepenz.iconics.IconicsColor
|
|
||||||
import com.mikepenz.iconics.IconicsDrawable
|
import com.mikepenz.iconics.IconicsDrawable
|
||||||
import com.mikepenz.iconics.IconicsSize
|
|
||||||
import com.mikepenz.iconics.typeface.IIcon
|
import com.mikepenz.iconics.typeface.IIcon
|
||||||
|
import com.mikepenz.iconics.utils.actionBar
|
||||||
|
import com.mikepenz.iconics.utils.sizeDp
|
||||||
import com.mikepenz.materialdrawer.util.DrawerImageLoader
|
import com.mikepenz.materialdrawer.util.DrawerImageLoader
|
||||||
import pl.droidsonroids.gif.GifDrawable
|
import pl.droidsonroids.gif.GifDrawable
|
||||||
import java.io.FileNotFoundException
|
import java.io.FileNotFoundException
|
||||||
@ -25,31 +25,24 @@ import java.io.FileNotFoundException
|
|||||||
|
|
||||||
open class ImageHolder : com.mikepenz.materialdrawer.holder.ImageHolder {
|
open class ImageHolder : com.mikepenz.materialdrawer.holder.ImageHolder {
|
||||||
|
|
||||||
constructor(url: String) : super(url) {}
|
|
||||||
|
|
||||||
constructor(uri: Uri) : super(uri) {}
|
|
||||||
|
|
||||||
constructor(icon: Drawable?) : super(icon) {}
|
|
||||||
|
|
||||||
constructor(bitmap: Bitmap?) : super(bitmap) {}
|
|
||||||
|
|
||||||
constructor(@DrawableRes iconRes: Int) : super(iconRes) {}
|
|
||||||
|
|
||||||
constructor(@DrawableRes iconRes: Int, colorFilter: Int?) : super(iconRes) {
|
constructor(@DrawableRes iconRes: Int, colorFilter: Int?) : super(iconRes) {
|
||||||
this.colorFilter = colorFilter
|
this.colorFilter = colorFilter
|
||||||
}
|
}
|
||||||
|
constructor(iicon: IIcon) : super(null as Drawable?) {
|
||||||
constructor(iicon: IIcon) : super(null as Bitmap?) {
|
this.iicon = iicon
|
||||||
this.iIcon = iicon
|
|
||||||
}
|
}
|
||||||
|
constructor() : super()
|
||||||
|
constructor(url: String) : super(url)
|
||||||
|
constructor(uri: Uri) : super(uri)
|
||||||
|
constructor(icon: Drawable?) : super(icon)
|
||||||
|
constructor(bitmap: Bitmap) : super(bitmap)
|
||||||
|
constructor(iconRes: Int) : super(iconRes)
|
||||||
|
|
||||||
|
var iicon: IIcon? = null
|
||||||
@ColorInt
|
@ColorInt
|
||||||
var colorFilter: Int? = null
|
var colorFilter: Int? = null
|
||||||
var colorFilterMode: PorterDuff.Mode = PorterDuff.Mode.DST_OVER
|
var colorFilterMode: PorterDuff.Mode = PorterDuff.Mode.DST_OVER
|
||||||
|
|
||||||
override fun applyTo(imageView: ImageView): Boolean {
|
|
||||||
return applyTo(imageView, null)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sets an existing image to the imageView
|
* sets an existing image to the imageView
|
||||||
@ -59,14 +52,14 @@ open class ImageHolder : com.mikepenz.materialdrawer.holder.ImageHolder {
|
|||||||
* @return true if an image was set
|
* @return true if an image was set
|
||||||
*/
|
*/
|
||||||
override fun applyTo(imageView: ImageView, tag: String?): Boolean {
|
override fun applyTo(imageView: ImageView, tag: String?): Boolean {
|
||||||
val ii = iIcon
|
val ii = iicon
|
||||||
|
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
if (uri.toString().endsWith(".gif", true)) {
|
if (uri.toString().endsWith(".gif", true)) {
|
||||||
imageView.setImageDrawable(GifDrawable(uri.toString()))
|
imageView.setImageDrawable(GifDrawable(uri.toString()))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val consumed = DrawerImageLoader.instance.setImage(imageView, uri, tag)
|
val consumed = DrawerImageLoader.instance.setImage(imageView, uri!!, tag)
|
||||||
if (!consumed) {
|
if (!consumed) {
|
||||||
imageView.setImageURI(uri)
|
imageView.setImageURI(uri)
|
||||||
}
|
}
|
||||||
@ -90,4 +83,39 @@ open class ImageHolder : com.mikepenz.materialdrawer.holder.ImageHolder {
|
|||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this only handles Drawables
|
||||||
|
*
|
||||||
|
* @param ctx
|
||||||
|
* @param iconColor
|
||||||
|
* @param tint
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
override fun decideIcon(ctx: Context, iconColor: ColorStateList, tint: Boolean, paddingDp: Int): Drawable? {
|
||||||
|
var icon: Drawable? = icon
|
||||||
|
val ii = iicon
|
||||||
|
val uri = uri
|
||||||
|
|
||||||
|
when {
|
||||||
|
ii != null -> icon = IconicsDrawable(ctx).apply {
|
||||||
|
this.icon = ii
|
||||||
|
colorList = iconColor
|
||||||
|
sizeDp = 24
|
||||||
|
}
|
||||||
|
iconRes != -1 -> icon = AppCompatResources.getDrawable(ctx, iconRes)
|
||||||
|
uri != null -> try {
|
||||||
|
val inputStream = ctx.contentResolver.openInputStream(uri)
|
||||||
|
icon = Drawable.createFromStream(inputStream, uri.toString())
|
||||||
|
} catch (e: FileNotFoundException) {
|
||||||
|
//no need to handle this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//if we got an icon AND we have auto tinting enabled AND it is no IIcon, tint it ;)
|
||||||
|
if (icon != null && tint && iicon == null) {
|
||||||
|
icon = icon.mutate()
|
||||||
|
icon.setColorFilter(iconColor.defaultColor, PorterDuff.Mode.SRC_IN)
|
||||||
|
}
|
||||||
|
return icon
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,20 @@
|
|||||||
package pl.szczodrzynski.navlib
|
package pl.szczodrzynski.navlib
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.graphics.drawable.LayerDrawable
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import com.google.android.material.bottomappbar.BottomAppBar
|
import com.google.android.material.bottomappbar.BottomAppBar
|
||||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
import com.mikepenz.iconics.IconicsDrawable
|
import com.mikepenz.iconics.IconicsDrawable
|
||||||
import com.mikepenz.iconics.typeface.IIcon
|
import com.mikepenz.iconics.typeface.IIcon
|
||||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
import com.mikepenz.iconics.typeface.library.navlibfont.NavLibFont
|
||||||
import com.mikepenz.iconics.utils.colorInt
|
|
||||||
import com.mikepenz.iconics.utils.sizeDp
|
import com.mikepenz.iconics.utils.sizeDp
|
||||||
import pl.szczodrzynski.navlib.bottomsheet.NavBottomSheet
|
import pl.szczodrzynski.navlib.bottomsheet.NavBottomSheet
|
||||||
import pl.szczodrzynski.navlib.drawer.NavDrawer
|
import pl.szczodrzynski.navlib.drawer.NavDrawer
|
||||||
@ -87,11 +89,19 @@ class NavBottomBar : BottomAppBar {
|
|||||||
/**
|
/**
|
||||||
* Set the FAB's icon.
|
* Set the FAB's icon.
|
||||||
*/
|
*/
|
||||||
var fabIcon: IIcon = CommunityMaterial.Icon.cmd_android
|
var fabIcon: IIcon? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
fabView?.setImageDrawable(IconicsDrawable(context, value).colorInt(R.attr.colorFabIcon).sizeDp(24))
|
fabView?.setImageDrawable(IconicsDrawable(context).apply {
|
||||||
fabExtendedView?.icon = IconicsDrawable(context, value).colorInt(R.attr.colorFabIcon).sizeDp(24)
|
icon = value
|
||||||
|
colorAttr(context, R.attr.colorFabIcon)
|
||||||
|
sizeDp = 24
|
||||||
|
})
|
||||||
|
fabExtendedView?.icon = IconicsDrawable(context).apply {
|
||||||
|
icon = value
|
||||||
|
colorAttr(context, R.attr.colorFabIcon)
|
||||||
|
sizeDp = 24
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Set the ExtendedFAB's text.
|
* Set the ExtendedFAB's text.
|
||||||
@ -102,6 +112,15 @@ class NavBottomBar : BottomAppBar {
|
|||||||
fabExtendedView?.text = value
|
fabExtendedView?.text = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the FAB's on click listener
|
||||||
|
*/
|
||||||
|
fun setFabOnClickListener(onClickListener: OnClickListener?) {
|
||||||
|
fabView?.setOnClickListener(onClickListener)
|
||||||
|
fabExtendedView?.setOnClickListener(onClickListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private fun create(attrs: AttributeSet?, defStyle: Int) {
|
private fun create(attrs: AttributeSet?, defStyle: Int) {
|
||||||
setOnTouchListener { _, event ->
|
setOnTouchListener { _, event ->
|
||||||
if (bottomSheet?.enable != true || bottomSheet?.enableDragToOpen != true)
|
if (bottomSheet?.enable != true || bottomSheet?.enableDragToOpen != true)
|
||||||
@ -112,17 +131,24 @@ class NavBottomBar : BottomAppBar {
|
|||||||
|
|
||||||
elevation = 0f
|
elevation = 0f
|
||||||
|
|
||||||
navigationIcon = IconicsDrawable(context)
|
val icon = ContextCompat.getDrawable(context, R.drawable.ic_menu_badge) as LayerDrawable?
|
||||||
.icon(CommunityMaterial.Icon2.cmd_menu)
|
icon?.apply {
|
||||||
.sizeDp(20)
|
mutate()
|
||||||
.colorInt(getColorFromAttr(context, R.attr.colorOnPrimary))
|
setDrawableByLayerId(R.id.ic_menu, IconicsDrawable(context).apply {
|
||||||
|
this.icon = NavLibFont.Icon.nav_menu
|
||||||
|
sizeDp = 24
|
||||||
|
colorAttr(context, R.attr.colorOnPrimary)
|
||||||
|
})
|
||||||
|
setDrawableByLayerId(R.id.ic_badge, BadgeDrawable(context))
|
||||||
|
}
|
||||||
|
navigationIcon = icon
|
||||||
|
|
||||||
menu.add(0, -1, 0, "Menu")
|
menu.add(0, -1, 0, "Menu")
|
||||||
.setIcon(
|
.setIcon(IconicsDrawable(context).apply {
|
||||||
IconicsDrawable(context)
|
this.icon = NavLibFont.Icon.nav_dots_vertical
|
||||||
.icon(CommunityMaterial.Icon.cmd_dots_vertical)
|
sizeDp = 24
|
||||||
.sizeDp(20)
|
colorAttr(context, R.attr.colorOnPrimary)
|
||||||
.colorInt(getColorFromAttr(context, R.attr.colorOnPrimary)))
|
})
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS)
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS)
|
||||||
|
|
||||||
setNavigationOnClickListener {
|
setNavigationOnClickListener {
|
||||||
@ -182,4 +208,4 @@ class NavBottomBar : BottomAppBar {
|
|||||||
override fun setOnMenuItemClickListener(listener: OnMenuItemClickListener?) {
|
override fun setOnMenuItemClickListener(listener: OnMenuItemClickListener?) {
|
||||||
onMenuItemClickListener = listener
|
onMenuItemClickListener = listener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@ package pl.szczodrzynski.navlib
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import androidx.core.view.children
|
|
||||||
import com.google.android.material.appbar.MaterialToolbar
|
import com.google.android.material.appbar.MaterialToolbar
|
||||||
|
|
||||||
class NavToolbar : MaterialToolbar {
|
class NavToolbar : MaterialToolbar {
|
||||||
|
|
||||||
constructor(context: Context) : super(context) {
|
constructor(context: Context) : super(context) {
|
||||||
create(null, 0)
|
create(null, 0)
|
||||||
}
|
}
|
||||||
@ -27,10 +27,24 @@ class NavToolbar : MaterialToolbar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun setSubtitle(subtitle: CharSequence?) {
|
||||||
|
if(subtitle.isNullOrEmpty()) {
|
||||||
|
setPadding(0, 0, 0, 0)
|
||||||
|
toolbarImage?.translationY = 0f
|
||||||
|
} else {
|
||||||
|
setPadding(0, -1, 0, 5)
|
||||||
|
toolbarImage?.translationY = 6f
|
||||||
|
}
|
||||||
|
super.setSubtitle(subtitle)
|
||||||
|
}
|
||||||
|
|
||||||
private fun create(attrs: AttributeSet?, defStyle: Int) {
|
private fun create(attrs: AttributeSet?, defStyle: Int) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var subtitleFormat: Int? = null
|
||||||
|
var subtitleFormatWithUnread: Int? = null
|
||||||
|
|
||||||
var profileImageClickListener: (() -> Unit)? = null
|
var profileImageClickListener: (() -> Unit)? = null
|
||||||
|
|
||||||
var profileImage
|
var profileImage
|
||||||
|
@ -3,6 +3,7 @@ package pl.szczodrzynski.navlib
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.content.res.Configuration.ORIENTATION_PORTRAIT
|
import android.content.res.Configuration.ORIENTATION_PORTRAIT
|
||||||
|
import android.graphics.Point
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
@ -12,10 +13,10 @@ import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
|||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
import androidx.core.view.children
|
||||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
import kotlinx.android.synthetic.main.nav_view.view.*
|
import kotlinx.android.synthetic.main.nav_view.view.*
|
||||||
import pl.szczodrzynski.edziennik.utils.SwipeRefreshLayoutNoTouch
|
|
||||||
import pl.szczodrzynski.navlib.bottomsheet.NavBottomSheet
|
import pl.szczodrzynski.navlib.bottomsheet.NavBottomSheet
|
||||||
import pl.szczodrzynski.navlib.drawer.NavDrawer
|
import pl.szczodrzynski.navlib.drawer.NavDrawer
|
||||||
|
|
||||||
@ -39,6 +40,9 @@ class NavView : FrameLayout {
|
|||||||
lateinit var toolbar: NavToolbar
|
lateinit var toolbar: NavToolbar
|
||||||
lateinit var bottomBar: NavBottomBar
|
lateinit var bottomBar: NavBottomBar
|
||||||
lateinit var bottomSheet: NavBottomSheet
|
lateinit var bottomSheet: NavBottomSheet
|
||||||
|
val coordinator by lazy {
|
||||||
|
findViewById<CoordinatorLayout>(R.id.nv_coordinator)
|
||||||
|
}
|
||||||
|
|
||||||
var navigationLoader: NavigationLoader? = null
|
var navigationLoader: NavigationLoader? = null
|
||||||
|
|
||||||
@ -75,9 +79,8 @@ class NavView : FrameLayout {
|
|||||||
|
|
||||||
drawer = NavDrawer(
|
drawer = NavDrawer(
|
||||||
context,
|
context,
|
||||||
findViewById(R.id.nv_drawerContainer),
|
findViewById(R.id.nv_drawerLayout),
|
||||||
findViewById(R.id.nv_fixedDrawerContainer),
|
findViewById(R.id.nv_drawerContainerLandscape),
|
||||||
findViewById(R.id.nv_miniDrawerContainerLandscape),
|
|
||||||
findViewById(R.id.nv_miniDrawerContainerPortrait),
|
findViewById(R.id.nv_miniDrawerContainerPortrait),
|
||||||
findViewById(R.id.nv_miniDrawerElevation)
|
findViewById(R.id.nv_miniDrawerElevation)
|
||||||
)
|
)
|
||||||
@ -95,16 +98,33 @@ class NavView : FrameLayout {
|
|||||||
bottomBar.fabView = floatingActionButton
|
bottomBar.fabView = floatingActionButton
|
||||||
bottomBar.fabExtendedView = extendedFloatingActionButton
|
bottomBar.fabExtendedView = extendedFloatingActionButton
|
||||||
|
|
||||||
|
ripple.isEnabled = false
|
||||||
|
ripple.children.forEach { it.isEnabled = false }
|
||||||
|
|
||||||
//bottomSheetBehavior.peekHeight = displayHeight
|
//bottomSheetBehavior.peekHeight = displayHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun convertDpToPixel(dp: Float): Float {
|
||||||
|
val resources = context.resources
|
||||||
|
val metrics = resources.displayMetrics
|
||||||
|
return dp * (metrics.densityDpi / 160f)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun gainAttentionOnBottomBar() {
|
||||||
|
var x = ripple.width.toFloat()
|
||||||
|
var y = ripple.height.toFloat()
|
||||||
|
x -= convertDpToPixel(56f) / 2
|
||||||
|
y -= convertDpToPixel(56f) / 2
|
||||||
|
ripple.performRipple(Point(x.toInt(), y.toInt()))
|
||||||
|
}
|
||||||
|
|
||||||
fun configSystemBarsUtil(systemBarsUtil: SystemBarsUtil) {
|
fun configSystemBarsUtil(systemBarsUtil: SystemBarsUtil) {
|
||||||
this.systemBarsUtil = systemBarsUtil.apply {
|
this.systemBarsUtil = systemBarsUtil.apply {
|
||||||
this.statusBarBgView = statusBarBackground
|
this.statusBarBgView = statusBarBackground
|
||||||
this.navigationBarBgView = navigationBarBackground
|
this.navigationBarBgView = navigationBarBackground
|
||||||
this.statusBarDarkView = nv_statusBarDarker
|
this.statusBarDarkView = nv_statusBarDarker
|
||||||
//this.navigationBarDarkView = navigationBarBackground
|
//this.navigationBarDarkView = navigationBarBackground
|
||||||
this.insetsListener = nv_drawerContainer
|
this.insetsListener = nv_drawerLayout
|
||||||
this.marginBySystemBars = mainView
|
this.marginBySystemBars = mainView
|
||||||
this.paddingByNavigationBar = bottomSheet.getContentView()
|
this.paddingByNavigationBar = bottomSheet.getContentView()
|
||||||
}
|
}
|
||||||
@ -135,9 +155,8 @@ class NavView : FrameLayout {
|
|||||||
/**
|
/**
|
||||||
* Set the FAB's on click listener
|
* Set the FAB's on click listener
|
||||||
*/
|
*/
|
||||||
fun setFabOnClickListener(onClickListener: OnClickListener) {
|
fun setFabOnClickListener(onClickListener: OnClickListener?) {
|
||||||
floatingActionButton.setOnClickListener(onClickListener)
|
bottomBar.setFabOnClickListener(onClickListener)
|
||||||
extendedFloatingActionButton.setOnClickListener(onClickListener)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal var systemBarsUtil: SystemBarsUtil? = null
|
internal var systemBarsUtil: SystemBarsUtil? = null
|
||||||
@ -168,7 +187,7 @@ class NavView : FrameLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun onBackPressed(): Boolean {
|
fun onBackPressed(): Boolean {
|
||||||
if (drawer.isOpen) {
|
if (drawer.isOpen && !drawer.fixedDrawerEnabled()) {
|
||||||
if (drawer.profileSelectionIsOpen) {
|
if (drawer.profileSelectionIsOpen) {
|
||||||
drawer.profileSelectionClose()
|
drawer.profileSelectionClose()
|
||||||
return true
|
return true
|
||||||
|
@ -5,13 +5,12 @@ import android.content.res.Configuration.ORIENTATION_PORTRAIT
|
|||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Build.VERSION.SDK_INT
|
import android.os.Build.VERSION.SDK_INT
|
||||||
import android.os.Build.VERSION_CODES.*
|
import android.os.Build.VERSION_CODES
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.*
|
import android.view.View.*
|
||||||
import android.view.Window
|
import android.view.Window
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.core.graphics.ColorUtils
|
import androidx.core.graphics.ColorUtils
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
import com.mikepenz.materialize.util.KeyboardUtil
|
import com.mikepenz.materialize.util.KeyboardUtil
|
||||||
@ -185,12 +184,12 @@ class SystemBarsUtil(private val activity: Activity) {
|
|||||||
// #3 SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN makes the activity not resize when keyboard is open
|
// #3 SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN makes the activity not resize when keyboard is open
|
||||||
// Samsung TouchWiz - app will go fullscreen. There is a problem though, see #3.
|
// Samsung TouchWiz - app will go fullscreen. There is a problem though, see #3.
|
||||||
var targetAppFullscreen = false
|
var targetAppFullscreen = false
|
||||||
if (SDK_INT >= KITKAT) {
|
if (SDK_INT >= VERSION_CODES.KITKAT) {
|
||||||
targetAppFullscreen = true
|
targetAppFullscreen = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (SDK_INT in KITKAT until LOLLIPOP) {
|
if (SDK_INT in VERSION_CODES.KITKAT until VERSION_CODES.LOLLIPOP) {
|
||||||
// API 19-20 (KitKat 4.4) - set gradient status bar
|
// API 19-20 (KitKat 4.4) - set gradient status bar
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
|
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
|
||||||
// take FallbackGradient color
|
// take FallbackGradient color
|
||||||
@ -198,7 +197,7 @@ class SystemBarsUtil(private val activity: Activity) {
|
|||||||
// disable darker even if [statusBarDarker] == true BUT gradient fallback is not COLOR_HALF_TRANSPARENT
|
// disable darker even if [statusBarDarker] == true BUT gradient fallback is not COLOR_HALF_TRANSPARENT
|
||||||
//targetStatusBarDarker = targetStatusBarDarker && targetStatusBarFallbackGradient == COLOR_HALF_TRANSPARENT
|
//targetStatusBarDarker = targetStatusBarDarker && targetStatusBarFallbackGradient == COLOR_HALF_TRANSPARENT
|
||||||
}
|
}
|
||||||
else if (SDK_INT >= LOLLIPOP) {
|
else if (SDK_INT >= VERSION_CODES.LOLLIPOP) {
|
||||||
// API 21+ (Lollipop 5.0+) - set transparent status bar
|
// API 21+ (Lollipop 5.0+) - set transparent status bar
|
||||||
if (statusBarTranslucent) {
|
if (statusBarTranslucent) {
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
|
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
|
||||||
@ -206,17 +205,17 @@ class SystemBarsUtil(private val activity: Activity) {
|
|||||||
else {
|
else {
|
||||||
window.statusBarColor = Color.TRANSPARENT
|
window.statusBarColor = Color.TRANSPARENT
|
||||||
}
|
}
|
||||||
if (SDK_INT < M && targetStatusBarLight) {
|
if (SDK_INT < VERSION_CODES.M && targetStatusBarLight) {
|
||||||
// take FallbackLight color
|
// take FallbackLight color
|
||||||
targetStatusBarMode = TARGET_MODE_LIGHT
|
targetStatusBarMode = TARGET_MODE_LIGHT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (SDK_INT >= M && targetStatusBarLight) {
|
if (SDK_INT >= VERSION_CODES.M && targetStatusBarLight) {
|
||||||
// API 23+ (Marshmallow 6.0+) - set the status bar icons to dark color if [statusBarLight] is true
|
// API 23+ (Marshmallow 6.0+) - set the status bar icons to dark color if [statusBarLight] is true
|
||||||
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility or SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility or SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
||||||
}
|
}
|
||||||
// FOR SAMSUNG/SONY DEVICES (TouchWiz 4.1-4.3)
|
// FOR SAMSUNG/SONY DEVICES (TouchWiz 4.1-4.3)
|
||||||
if (SDK_INT < KITKAT) {
|
if (SDK_INT < VERSION_CODES.KITKAT) {
|
||||||
val libs = activity.packageManager.systemSharedLibraryNames
|
val libs = activity.packageManager.systemSharedLibraryNames
|
||||||
var reflect: String? = null
|
var reflect: String? = null
|
||||||
// TODO galaxy s3 - opening keyboard does not resize activity if fullscreen
|
// TODO galaxy s3 - opening keyboard does not resize activity if fullscreen
|
||||||
@ -282,22 +281,21 @@ class SystemBarsUtil(private val activity: Activity) {
|
|||||||
|
|
||||||
// TODO navigation bar options like status bar
|
// TODO navigation bar options like status bar
|
||||||
// NAVIGATION BAR
|
// NAVIGATION BAR
|
||||||
if (SDK_INT >= KITKAT && (SDK_INT < LOLLIPOP || !navigationBarTransparent)) {
|
if (SDK_INT >= VERSION_CODES.KITKAT && (SDK_INT < VERSION_CODES.LOLLIPOP || !navigationBarTransparent)) {
|
||||||
// API 19-20 (KitKat 4.4) - set gradient navigation bar
|
// API 19-20 (KitKat 4.4) - set gradient navigation bar
|
||||||
// API 21+ (Lollipop 5.0+) - set half-transparent navigation bar if [navigationBarTransparent] is false
|
// API 21+ (Lollipop 5.0+) - set half-transparent navigation bar if [navigationBarTransparent] is false
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION)
|
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDK_INT >= LOLLIPOP && navigationBarTransparent) {
|
if (SDK_INT >= VERSION_CODES.LOLLIPOP && navigationBarTransparent) {
|
||||||
// API 21+ (Lollipop 5.0+) - set fully transparent navigation bar if [navigationBarTransparent] is true
|
// API 21+ (Lollipop 5.0+) - set fully transparent navigation bar if [navigationBarTransparent] is true
|
||||||
window.navigationBarColor = Color.TRANSPARENT
|
window.navigationBarColor = Color.TRANSPARENT
|
||||||
}
|
}
|
||||||
|
|
||||||
// PADDING
|
// PADDING
|
||||||
if (insetsListener != null) {
|
if (insetsListener != null) {
|
||||||
if (SDK_INT >= LOLLIPOP) {
|
if (SDK_INT >= VERSION_CODES.LOLLIPOP && false) {
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(insetsListener!!) { _, insets ->
|
ViewCompat.setOnApplyWindowInsetsListener(insetsListener!!) { _, insets ->
|
||||||
Toast.makeText(activity, "Insets applied ", Toast.LENGTH_SHORT).show()
|
|
||||||
Log.d("NavLib", "Got insets left = ${insets.systemWindowInsetLeft}, top = ${insets.systemWindowInsetTop}, right = ${insets.systemWindowInsetRight}, bottom = ${insets.systemWindowInsetBottom}")
|
Log.d("NavLib", "Got insets left = ${insets.systemWindowInsetLeft}, top = ${insets.systemWindowInsetTop}, right = ${insets.systemWindowInsetRight}, bottom = ${insets.systemWindowInsetBottom}")
|
||||||
if (insetsApplied)
|
if (insetsApplied)
|
||||||
return@setOnApplyWindowInsetsListener insets.consumeSystemWindowInsets()
|
return@setOnApplyWindowInsetsListener insets.consumeSystemWindowInsets()
|
||||||
@ -375,4 +373,4 @@ class SystemBarsUtil(private val activity: Activity) {
|
|||||||
keyboardUtil?.disable()
|
keyboardUtil?.disable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,20 +5,18 @@ import android.content.Context
|
|||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.util.DisplayMetrics
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.WindowManager
|
||||||
import androidx.annotation.AttrRes
|
import androidx.annotation.AttrRes
|
||||||
|
import androidx.annotation.ColorInt
|
||||||
|
import androidx.annotation.ColorRes
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import com.google.android.material.elevation.ElevationOverlayProvider
|
import com.google.android.material.elevation.ElevationOverlayProvider
|
||||||
import com.mikepenz.iconics.IconicsColor
|
import com.mikepenz.iconics.IconicsColor
|
||||||
import com.mikepenz.iconics.IconicsDrawable
|
import com.mikepenz.iconics.IconicsDrawable
|
||||||
import android.util.DisplayMetrics
|
import com.mikepenz.iconics.utils.colorInt
|
||||||
import android.view.WindowManager
|
|
||||||
import androidx.annotation.ColorInt
|
|
||||||
import androidx.annotation.ColorRes
|
|
||||||
import com.mikepenz.materialdrawer.Drawer
|
|
||||||
import com.mikepenz.materialdrawer.holder.StringHolder
|
|
||||||
import com.mikepenz.materialdrawer.model.interfaces.Badgeable
|
|
||||||
|
|
||||||
|
|
||||||
/*private val displayMetrics by lazy {
|
/*private val displayMetrics by lazy {
|
||||||
@ -122,7 +120,9 @@ fun hasNavigationBar(context: Context): Boolean {
|
|||||||
return hasNavigationBar
|
return hasNavigationBar
|
||||||
}
|
}
|
||||||
|
|
||||||
fun IconicsDrawable.colorAttr(context: Context, @AttrRes attrRes: Int) = color(IconicsColor.colorInt(getColorFromAttr(context, attrRes)))
|
fun IconicsDrawable.colorAttr(context: Context, @AttrRes attrRes: Int) {
|
||||||
|
colorInt = getColorFromAttr(context, attrRes)
|
||||||
|
}
|
||||||
|
|
||||||
fun getColorFromAttr(context: Context, @AttrRes color: Int): Int {
|
fun getColorFromAttr(context: Context, @AttrRes color: Int): Int {
|
||||||
val typedValue = TypedValue()
|
val typedValue = TypedValue()
|
||||||
@ -149,14 +149,6 @@ fun Context.getColorFromRes(@ColorRes id: Int): Int {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Drawer.updateBadge(identifier: Long, badge: StringHolder?) {
|
|
||||||
val drawerItem = getDrawerItem(identifier)
|
|
||||||
if (drawerItem is Badgeable<*>) {
|
|
||||||
drawerItem.withBadge(badge)
|
|
||||||
updateItem(drawerItem)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun crc16(buffer: String): Int {
|
fun crc16(buffer: String): Int {
|
||||||
/* Note the change here */
|
/* Note the change here */
|
||||||
var crc = 0x1D0F
|
var crc = 0x1D0F
|
||||||
@ -169,4 +161,4 @@ fun crc16(buffer: String): Int {
|
|||||||
}
|
}
|
||||||
crc = crc and 0xffff
|
crc = crc and 0xffff
|
||||||
return crc
|
return crc
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import android.content.Context
|
|||||||
import android.graphics.PorterDuff
|
import android.graphics.PorterDuff
|
||||||
import android.graphics.PorterDuffColorFilter
|
import android.graphics.PorterDuffColorFilter
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.system.Os.close
|
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
import android.text.TextWatcher
|
import android.text.TextWatcher
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
@ -28,13 +27,12 @@ import com.google.android.material.textfield.TextInputEditText
|
|||||||
import com.google.android.material.textfield.TextInputLayout
|
import com.google.android.material.textfield.TextInputLayout
|
||||||
import com.mikepenz.iconics.IconicsDrawable
|
import com.mikepenz.iconics.IconicsDrawable
|
||||||
import com.mikepenz.iconics.typeface.IIcon
|
import com.mikepenz.iconics.typeface.IIcon
|
||||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
import com.mikepenz.iconics.typeface.library.navlibfont.NavLibFont
|
||||||
import com.mikepenz.iconics.utils.paddingDp
|
import com.mikepenz.iconics.utils.paddingDp
|
||||||
import com.mikepenz.iconics.utils.sizeDp
|
import com.mikepenz.iconics.utils.sizeDp
|
||||||
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
|
|
||||||
import pl.szczodrzynski.navlib.*
|
import pl.szczodrzynski.navlib.*
|
||||||
import pl.szczodrzynski.navlib.bottomsheet.items.IBottomSheetItem
|
|
||||||
import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetSeparatorItem
|
import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetSeparatorItem
|
||||||
|
import pl.szczodrzynski.navlib.bottomsheet.items.IBottomSheetItem
|
||||||
|
|
||||||
|
|
||||||
class NavBottomSheet : CoordinatorLayout {
|
class NavBottomSheet : CoordinatorLayout {
|
||||||
@ -280,7 +278,9 @@ class NavBottomSheet : CoordinatorLayout {
|
|||||||
private fun toggleGroupGetIconicsDrawable(context: Context, icon: IIcon?): Drawable? {
|
private fun toggleGroupGetIconicsDrawable(context: Context, icon: IIcon?): Drawable? {
|
||||||
if (icon == null)
|
if (icon == null)
|
||||||
return null
|
return null
|
||||||
return IconicsDrawable(context, icon).sizeDp(24).paddingDp(4)
|
return IconicsDrawable(context, icon).apply {
|
||||||
|
sizeDp = 24
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toggleGroupAddItem(id: Int, text: String, @DrawableRes icon: Int, defaultSortOrder: Int = SORT_MODE_ASCENDING) {
|
fun toggleGroupAddItem(id: Int, text: String, @DrawableRes icon: Int, defaultSortOrder: Int = SORT_MODE_ASCENDING) {
|
||||||
@ -337,8 +337,8 @@ class NavBottomSheet : CoordinatorLayout {
|
|||||||
}
|
}
|
||||||
button.tag = tag
|
button.tag = tag
|
||||||
button.icon = toggleGroupGetIconicsDrawable(context, when (sortingMode) {
|
button.icon = toggleGroupGetIconicsDrawable(context, when (sortingMode) {
|
||||||
SORT_MODE_ASCENDING -> CommunityMaterial.Icon2.cmd_sort_ascending
|
SORT_MODE_ASCENDING -> NavLibFont.Icon.nav_sort_ascending
|
||||||
SORT_MODE_DESCENDING -> CommunityMaterial.Icon2.cmd_sort_descending
|
SORT_MODE_DESCENDING -> NavLibFont.Icon.nav_sort_descending
|
||||||
else -> null
|
else -> null
|
||||||
})
|
})
|
||||||
if (sortingMode != null) {
|
if (sortingMode != null) {
|
||||||
@ -386,7 +386,11 @@ class NavBottomSheet : CoordinatorLayout {
|
|||||||
set(value) {
|
set(value) {
|
||||||
textInputLayout.startIconDrawable = when (value) {
|
textInputLayout.startIconDrawable = when (value) {
|
||||||
is Drawable -> value
|
is Drawable -> value
|
||||||
is IIcon -> IconicsDrawable(context, value).sizeDp(24)/*.colorInt(Color.BLACK)*/
|
is IIcon -> IconicsDrawable(context).apply {
|
||||||
|
icon = value
|
||||||
|
sizeDp = 24
|
||||||
|
// colorInt = Color.BLACK
|
||||||
|
}
|
||||||
is Int -> context.getDrawableFromRes(value)
|
is Int -> context.getDrawableFromRes(value)
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
@ -431,4 +435,4 @@ class NavBottomSheet : CoordinatorLayout {
|
|||||||
return
|
return
|
||||||
isOpen = !isOpen
|
isOpen = !isOpen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,8 @@ import androidx.annotation.StringRes
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.mikepenz.iconics.IconicsDrawable
|
import com.mikepenz.iconics.IconicsDrawable
|
||||||
import com.mikepenz.iconics.typeface.IIcon
|
import com.mikepenz.iconics.typeface.IIcon
|
||||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
|
||||||
import com.mikepenz.iconics.utils.colorInt
|
|
||||||
import com.mikepenz.iconics.utils.sizeDp
|
import com.mikepenz.iconics.utils.sizeDp
|
||||||
import com.mikepenz.materialize.holder.ImageHolder
|
import pl.szczodrzynski.navlib.ImageHolder
|
||||||
import pl.szczodrzynski.navlib.R
|
import pl.szczodrzynski.navlib.R
|
||||||
import pl.szczodrzynski.navlib.colorAttr
|
import pl.szczodrzynski.navlib.colorAttr
|
||||||
import pl.szczodrzynski.navlib.getColorFromAttr
|
import pl.szczodrzynski.navlib.getColorFromAttr
|
||||||
@ -43,10 +41,11 @@ data class BottomSheetPrimaryItem(override val isContextual: Boolean = true) : I
|
|||||||
override fun bindViewHolder(viewHolder: ViewHolder) {
|
override fun bindViewHolder(viewHolder: ViewHolder) {
|
||||||
viewHolder.root.setOnClickListener(onClickListener)
|
viewHolder.root.setOnClickListener(onClickListener)
|
||||||
|
|
||||||
viewHolder.image.setImageDrawable(IconicsDrawable(viewHolder.text.context)
|
viewHolder.image.setImageDrawable(IconicsDrawable(viewHolder.text.context).apply {
|
||||||
.icon(iconicsIcon ?: CommunityMaterial.Icon.cmd_android)
|
icon = iconicsIcon
|
||||||
.colorAttr(viewHolder.text.context, R.attr.material_drawer_primary_icon)
|
colorAttr(viewHolder.text.context, android.R.attr.textColorSecondary)
|
||||||
.sizeDp(24))
|
sizeDp = 24
|
||||||
|
})
|
||||||
|
|
||||||
viewHolder.description.visibility = View.VISIBLE
|
viewHolder.description.visibility = View.VISIBLE
|
||||||
when {
|
when {
|
||||||
@ -59,7 +58,7 @@ data class BottomSheetPrimaryItem(override val isContextual: Boolean = true) : I
|
|||||||
titleRes != null -> viewHolder.text.setText(titleRes!!)
|
titleRes != null -> viewHolder.text.setText(titleRes!!)
|
||||||
else -> viewHolder.text.text = title
|
else -> viewHolder.text.text = title
|
||||||
}
|
}
|
||||||
viewHolder.text.setTextColor(getColorFromAttr(viewHolder.text.context, R.attr.material_drawer_primary_text))
|
viewHolder.text.setTextColor(getColorFromAttr(viewHolder.text.context, android.R.attr.textColorPrimary))
|
||||||
}
|
}
|
||||||
|
|
||||||
/*_____ _
|
/*_____ _
|
||||||
@ -122,4 +121,4 @@ data class BottomSheetPrimaryItem(override val isContextual: Boolean = true) : I
|
|||||||
this.onClickListener = onClickListener
|
this.onClickListener = onClickListener
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,8 @@ import android.widget.ImageView
|
|||||||
import pl.szczodrzynski.navlib.ImageHolder
|
import pl.szczodrzynski.navlib.ImageHolder
|
||||||
|
|
||||||
interface IDrawerProfile {
|
interface IDrawerProfile {
|
||||||
var id: Int
|
val id: Int
|
||||||
var name: String?
|
var name: String
|
||||||
var subname: String?
|
var subname: String?
|
||||||
var image: String?
|
var image: String?
|
||||||
|
|
||||||
|
@ -7,32 +7,44 @@ import android.content.res.Configuration
|
|||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.PorterDuff
|
import android.graphics.PorterDuff
|
||||||
|
import android.graphics.drawable.LayerDrawable
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.view.Gravity
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
|
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.customview.widget.ViewDragHelper
|
import androidx.customview.widget.ViewDragHelper
|
||||||
import androidx.drawerlayout.widget.DrawerLayout
|
import androidx.drawerlayout.widget.DrawerLayout
|
||||||
|
import com.mikepenz.fastadapter.IAdapter
|
||||||
import com.mikepenz.itemanimators.AlphaCrossFadeAnimator
|
import com.mikepenz.itemanimators.AlphaCrossFadeAnimator
|
||||||
import com.mikepenz.materialdrawer.*
|
import com.mikepenz.materialdrawer.*
|
||||||
import com.mikepenz.materialdrawer.holder.BadgeStyle
|
import com.mikepenz.materialdrawer.holder.BadgeStyle
|
||||||
|
import com.mikepenz.materialdrawer.holder.ColorHolder
|
||||||
import com.mikepenz.materialdrawer.holder.StringHolder
|
import com.mikepenz.materialdrawer.holder.StringHolder
|
||||||
import com.mikepenz.materialdrawer.model.BaseDrawerItem
|
import com.mikepenz.materialdrawer.model.BaseDrawerItem
|
||||||
|
import com.mikepenz.materialdrawer.model.MiniProfileDrawerItem
|
||||||
import com.mikepenz.materialdrawer.model.ProfileDrawerItem
|
import com.mikepenz.materialdrawer.model.ProfileDrawerItem
|
||||||
import com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem
|
import com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem
|
||||||
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
|
import com.mikepenz.materialdrawer.model.interfaces.*
|
||||||
import com.mikepenz.materialdrawer.model.interfaces.IProfile
|
import com.mikepenz.materialdrawer.util.*
|
||||||
|
import com.mikepenz.materialdrawer.widget.AccountHeaderView
|
||||||
|
import com.mikepenz.materialdrawer.widget.MaterialDrawerSliderView
|
||||||
|
import com.mikepenz.materialdrawer.widget.MiniDrawerSliderView
|
||||||
|
import com.mikepenz.materialize.util.UIUtils
|
||||||
import pl.szczodrzynski.navlib.*
|
import pl.szczodrzynski.navlib.*
|
||||||
import pl.szczodrzynski.navlib.R
|
import pl.szczodrzynski.navlib.R
|
||||||
import pl.szczodrzynski.navlib.drawer.items.DrawerPrimaryItem
|
import pl.szczodrzynski.navlib.drawer.items.DrawerPrimaryItem
|
||||||
|
|
||||||
class NavDrawer(
|
class NavDrawer(
|
||||||
val context: Context,
|
val context: Context,
|
||||||
val drawerContainer: LinearLayout,
|
val drawerLayout: DrawerLayout,
|
||||||
val fixedDrawerContainer: FrameLayout,
|
val drawerContainerLandscape: FrameLayout,
|
||||||
val miniDrawerContainerLandscape: FrameLayout,
|
val drawerContainerPortrait: FrameLayout,
|
||||||
val miniDrawerContainerPortrait: FrameLayout,
|
|
||||||
val miniDrawerElevation: View
|
val miniDrawerElevation: View
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
@ -48,11 +60,9 @@ class NavDrawer(
|
|||||||
internal lateinit var toolbar: NavToolbar
|
internal lateinit var toolbar: NavToolbar
|
||||||
internal lateinit var bottomBar: NavBottomBar
|
internal lateinit var bottomBar: NavBottomBar
|
||||||
|
|
||||||
private var drawer: Drawer? = null
|
private lateinit var drawer: MaterialDrawerSliderView
|
||||||
private var drawerView: View? = null
|
private lateinit var accountHeader: AccountHeaderView
|
||||||
private var accountHeader: AccountHeader? = null
|
private lateinit var miniDrawer: MiniDrawerSliderView
|
||||||
private var miniDrawer: MiniDrawer? = null
|
|
||||||
private var miniDrawerView: View? = null
|
|
||||||
|
|
||||||
private var drawerMode: Int = DRAWER_MODE_NORMAL
|
private var drawerMode: Int = DRAWER_MODE_NORMAL
|
||||||
private var selection: Int = -1
|
private var selection: Int = -1
|
||||||
@ -70,123 +80,111 @@ class NavDrawer(
|
|||||||
getColorFromAttr(context, R.attr.colorOnError)
|
getColorFromAttr(context, R.attr.colorOnError)
|
||||||
)*/
|
)*/
|
||||||
|
|
||||||
badgeStyle = BadgeStyle()
|
badgeStyle = BadgeStyle().apply {
|
||||||
.withTextColor(Color.WHITE)
|
textColor = ColorHolder.fromColor(Color.WHITE)
|
||||||
.withColorRes(R.color.md_red_700)
|
color = ColorHolder.fromColor(0xffd32f2f.toInt())
|
||||||
|
}
|
||||||
val drawerBuilder = DrawerBuilder()
|
|
||||||
.withActivity(activity)
|
drawerLayout.addDrawerListener(object : DrawerLayout.DrawerListener {
|
||||||
.withDrawerLayout(R.layout.material_drawer_fits_not)
|
override fun onDrawerStateChanged(newState: Int) {}
|
||||||
.withHasStableIds(true)
|
override fun onDrawerSlide(drawerView: View, slideOffset: Float) {}
|
||||||
.withItemAnimator(AlphaCrossFadeAnimator())
|
override fun onDrawerClosed(drawerView: View) {
|
||||||
.withRootView(drawerContainer)
|
drawerClosedListener?.invoke()
|
||||||
.withFullscreen(true)
|
profileSelectionClose()
|
||||||
.withTranslucentStatusBar(false)
|
}
|
||||||
.withTranslucentNavigationBar(true)
|
override fun onDrawerOpened(drawerView: View) {
|
||||||
.withTranslucentNavigationBarProgrammatically(false)
|
drawerOpenedListener?.invoke()
|
||||||
.withToolbar(bottomBar)
|
}
|
||||||
.withDisplayBelowStatusBar(false)
|
})
|
||||||
.withActionBarDrawerToggleAnimated(true)
|
|
||||||
.withShowDrawerOnFirstLaunch(true)
|
accountHeader = AccountHeaderView(context).apply {
|
||||||
.withShowDrawerUntilDraggedOpened(true)
|
headerBackground = ImageHolder(R.drawable.header)
|
||||||
.withGenerateMiniDrawer(true /* if it is not showing on screen, clicking items throws an exception */)
|
displayBadgesOnSmallProfileImages = true
|
||||||
.withOnDrawerListener(object : Drawer.OnDrawerListener {
|
|
||||||
override fun onDrawerSlide(drawerView: View, slideOffset: Float) {}
|
onAccountHeaderListener = { view, profile, current ->
|
||||||
override fun onDrawerOpened(drawerView: View) {
|
if (profile is ProfileSettingDrawerItem) {
|
||||||
drawerOpenedListener?.invoke()
|
drawerProfileSettingClickListener?.invoke(profile.identifier.toInt(), view) ?: false
|
||||||
}
|
}
|
||||||
override fun onDrawerClosed(drawerView: View) {
|
else {
|
||||||
drawerClosedListener?.invoke()
|
updateBadges()
|
||||||
profileSelectionClose()
|
if (current) {
|
||||||
}
|
close()
|
||||||
})
|
profileSelectionClose()
|
||||||
.withOnDrawerItemClickListener { _, position, drawerItem ->
|
true
|
||||||
if (drawerItem.identifier.toInt() == selection) {
|
}
|
||||||
return@withOnDrawerItemClickListener false
|
else {
|
||||||
}
|
(drawerProfileSelectedListener?.invoke(profile.identifier.toInt(), profile, current, view) ?: false).also {
|
||||||
when (drawerItemSelectedListener?.invoke(drawerItem.identifier.toInt(), position, drawerItem)) {
|
setToolbarProfileImage(profileList.singleOrNull { it.id == profile.identifier.toInt() })
|
||||||
true -> {
|
}
|
||||||
when {
|
}
|
||||||
!drawerItem.isSelectable -> {
|
}
|
||||||
setSelection(selection, false)
|
}
|
||||||
return@withOnDrawerItemClickListener false
|
|
||||||
}
|
onAccountHeaderItemLongClickListener = { view, profile, current ->
|
||||||
drawerItem is DrawerPrimaryItem -> toolbar.title = drawerItem.appTitle ?: drawerItem.name?.getText(context) ?: ""
|
if (profile is ProfileSettingDrawerItem) {
|
||||||
drawerItem is BaseDrawerItem<*, *> -> toolbar.title = drawerItem.name?.getText(context) ?: ""
|
drawerProfileSettingLongClickListener?.invoke(profile.identifier.toInt(), view) ?: true
|
||||||
}
|
}
|
||||||
//setSelection(drawerItem.identifier.toInt(), false)
|
else {
|
||||||
return@withOnDrawerItemClickListener false
|
drawerProfileLongClickListener?.invoke(profile.identifier.toInt(), profile, current, view) ?: false
|
||||||
}
|
}
|
||||||
false -> {
|
}
|
||||||
setSelection(selection, false)
|
|
||||||
return@withOnDrawerItemClickListener true
|
onAccountHeaderProfileImageListener = { view, profile, current ->
|
||||||
}
|
drawerProfileImageClickListener?.invoke(profile.identifier.toInt(), profile, current, view) ?: false
|
||||||
else -> {
|
}
|
||||||
return@withOnDrawerItemClickListener false
|
//.withTextColor(ContextCompat.getColor(context, R.color.material_drawer_dark_primary_text))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
drawer = MaterialDrawerSliderView(context).apply {
|
||||||
}
|
accountHeader = this@NavDrawer.accountHeader
|
||||||
.withOnDrawerItemLongClickListener { _, position, drawerItem ->
|
itemAnimator = AlphaCrossFadeAnimator()
|
||||||
drawerItemLongClickListener?.invoke(drawerItem.identifier.toInt(), position, drawerItem) ?: true
|
//hasStableIds = true
|
||||||
}
|
|
||||||
|
onDrawerItemClickListener = { _, drawerItem, position ->
|
||||||
|
if (drawerItem.identifier.toInt() == selection) {
|
||||||
val accountHeaderBuilder = AccountHeaderBuilder()
|
false
|
||||||
.withActivity(activity)
|
}
|
||||||
.withTranslucentStatusBar(true)
|
else {
|
||||||
.withOnAccountHeaderListener { view, profile, current ->
|
val consumed = drawerItemSelectedListener?.invoke(drawerItem.identifier.toInt(), position, drawerItem)
|
||||||
if (profile is ProfileSettingDrawerItem) {
|
if (consumed == false || !drawerItem.isSelectable) {
|
||||||
return@withOnAccountHeaderListener drawerProfileSettingClickListener?.invoke(profile.identifier.toInt(), view) ?: false
|
setSelection(selection, false)
|
||||||
}
|
consumed == false
|
||||||
updateBadges()
|
}
|
||||||
if (current) {
|
else if (consumed == true) {
|
||||||
close()
|
when (drawerItem) {
|
||||||
profileSelectionClose()
|
is DrawerPrimaryItem -> toolbar.title = drawerItem.appTitle ?: drawerItem.name?.getText(context) ?: ""
|
||||||
return@withOnAccountHeaderListener true
|
is BaseDrawerItem<*, *> -> toolbar.title = drawerItem.name?.getText(context) ?: ""
|
||||||
}
|
}
|
||||||
(drawerProfileSelectedListener?.invoke(profile.identifier.toInt(), profile, current, view) ?: false).also {
|
false
|
||||||
setToolbarProfileImage(profileList.singleOrNull { it.id == profile.identifier.toInt() })
|
}
|
||||||
}
|
else {
|
||||||
}
|
false
|
||||||
.withOnAccountHeaderItemLongClickListener { view, profile, current ->
|
}
|
||||||
if (profile is ProfileSettingDrawerItem) {
|
}
|
||||||
return@withOnAccountHeaderItemLongClickListener drawerProfileSettingLongClickListener?.invoke(profile.identifier.toInt(), view) ?: true
|
}
|
||||||
}
|
|
||||||
drawerProfileLongClickListener?.invoke(profile.identifier.toInt(), profile, current, view) ?: false
|
onDrawerItemLongClickListener = { _, drawerItem, position ->
|
||||||
}
|
drawerItemLongClickListener?.invoke(drawerItem.identifier.toInt(), position, drawerItem) ?: true
|
||||||
.withOnAccountHeaderProfileImageListener(
|
}
|
||||||
onClick = { view, profile, current ->
|
}
|
||||||
drawerProfileImageClickListener?.invoke(profile.identifier.toInt(), profile, current, view) ?: false
|
|
||||||
},
|
miniDrawer = MiniDrawerSliderView(context).apply {
|
||||||
onLongClick = { view, profile, current ->
|
drawer = this@NavDrawer.drawer
|
||||||
drawerProfileImageLongClickListener?.invoke(profile.identifier.toInt(), profile, current, view) ?: false
|
includeSecondaryDrawerItems = false
|
||||||
}
|
try {
|
||||||
)
|
this::class.java.getDeclaredField("onMiniDrawerItemClickListener").let {
|
||||||
.withHeaderBackground(R.drawable.header)
|
it.isAccessible = true
|
||||||
.withTextColor(ContextCompat.getColor(context, R.color.material_drawer_dark_primary_text))
|
it.set(this, { v: View?, position: Int, item: IDrawerItem<*>, type: Int ->
|
||||||
|
if (item is MiniProfileDrawerItem) {
|
||||||
accountHeader = accountHeaderBuilder.build()
|
profileSelectionOpen()
|
||||||
drawerBuilder.withAccountHeader(accountHeader!!)
|
open()
|
||||||
drawer = drawerBuilder.build()
|
true
|
||||||
|
} else false
|
||||||
drawerView = drawer?.slider
|
})
|
||||||
|
}
|
||||||
miniDrawer = drawer?.miniDrawer
|
} catch (_: Exception) { }
|
||||||
miniDrawer?.withOnMiniDrawerItemClickListener { _, _, _, type ->
|
|
||||||
if (type == MiniDrawer.PROFILE) {
|
|
||||||
profileSelectionOpen()
|
|
||||||
open()
|
|
||||||
return@withOnMiniDrawerItemClickListener true
|
|
||||||
}
|
|
||||||
return@withOnMiniDrawerItemClickListener false
|
|
||||||
}
|
}
|
||||||
miniDrawer?.withIncludeSecondaryDrawerItems(false)
|
|
||||||
|
|
||||||
// TODO 2019-08-27 build miniDrawerView only if needed
|
|
||||||
// building in decideDrawerMode causes an exception when clicking drawer items
|
|
||||||
// also update method updateMiniDrawer...
|
|
||||||
miniDrawerView = miniDrawer?.build(context)
|
|
||||||
updateMiniDrawer()
|
updateMiniDrawer()
|
||||||
|
|
||||||
toolbar.profileImageClickListener = {
|
toolbar.profileImageClickListener = {
|
||||||
@ -212,62 +210,62 @@ class NavDrawer(
|
|||||||
appendItem(item)
|
appendItem(item)
|
||||||
}
|
}
|
||||||
fun appendItem(item: IDrawerItem<*>) {
|
fun appendItem(item: IDrawerItem<*>) {
|
||||||
drawer?.addItem(item)
|
drawer.addItems(item)
|
||||||
updateMiniDrawer()
|
updateMiniDrawer()
|
||||||
}
|
}
|
||||||
fun appendItems(vararg items: IDrawerItem<*>) {
|
fun appendItems(vararg items: IDrawerItem<*>) {
|
||||||
drawer?.addItems(*items)
|
drawer.addItems(*items)
|
||||||
updateMiniDrawer()
|
updateMiniDrawer()
|
||||||
}
|
}
|
||||||
fun prependItem(item: IDrawerItem<*>) {
|
fun prependItem(item: IDrawerItem<*>) {
|
||||||
drawer?.addItemAtPosition(item, 0)
|
drawer.addItemAtPosition(0, item)
|
||||||
updateMiniDrawer()
|
updateMiniDrawer()
|
||||||
}
|
}
|
||||||
fun prependItems(vararg items: IDrawerItem<*>) {
|
fun prependItems(vararg items: IDrawerItem<*>) {
|
||||||
drawer?.addItemsAtPosition(0, *items)
|
drawer.addItemsAtPosition(0, *items)
|
||||||
updateMiniDrawer()
|
updateMiniDrawer()
|
||||||
}
|
}
|
||||||
fun addItemAt(index: Int, item: IDrawerItem<*>) {
|
fun addItemAt(index: Int, item: IDrawerItem<*>) {
|
||||||
drawer?.addItemAtPosition(item, index)
|
drawer.addItemAtPosition(index, item)
|
||||||
updateMiniDrawer()
|
updateMiniDrawer()
|
||||||
}
|
}
|
||||||
fun addItemsAt(index: Int, vararg items: IDrawerItem<*>) {
|
fun addItemsAt(index: Int, vararg items: IDrawerItem<*>) {
|
||||||
drawer?.addItemsAtPosition(index, *items)
|
drawer.addItemsAtPosition(index, *items)
|
||||||
updateMiniDrawer()
|
updateMiniDrawer()
|
||||||
}
|
}
|
||||||
fun removeItemById(id: Int) {
|
fun removeItemById(id: Int) {
|
||||||
drawer?.removeItem(id.toLong())
|
drawer.removeItems(id.toLong())
|
||||||
updateMiniDrawer()
|
updateMiniDrawer()
|
||||||
}
|
}
|
||||||
fun removeItemAt(index: Int) {
|
fun removeItemAt(index: Int) {
|
||||||
drawer?.removeItemByPosition(index)
|
drawer.removeItemByPosition(index)
|
||||||
updateMiniDrawer()
|
updateMiniDrawer()
|
||||||
}
|
}
|
||||||
fun removeAllItems() {
|
fun removeAllItems() {
|
||||||
drawer?.removeAllItems()
|
drawer.removeAllItems()
|
||||||
updateMiniDrawer()
|
updateMiniDrawer()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getItemById(id: Int, run: (it: IDrawerItem<*>?) -> Unit) {
|
fun getItemById(id: Int, run: (it: IDrawerItem<*>?) -> Unit) {
|
||||||
drawer?.getDrawerItem(id.toLong()).also {
|
drawer.getDrawerItem(id.toLong()).also {
|
||||||
run(it)
|
run(it)
|
||||||
if (it != null)
|
if (it != null)
|
||||||
drawer?.updateItem(it)
|
drawer.updateItem(it)
|
||||||
updateMiniDrawer()
|
updateMiniDrawer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fun getItemByIndex(index: Int, run: (it: IDrawerItem<*>?) -> Unit) {
|
fun getItemByIndex(index: Int, run: (it: IDrawerItem<*>?) -> Unit) {
|
||||||
drawer?.drawerItems?.getOrNull(index).also {
|
drawer.itemAdapter.itemList.get(index).also {
|
||||||
run(it)
|
run(it)
|
||||||
if (it != null)
|
if (it != null)
|
||||||
drawer?.updateItem(it)
|
drawer.updateItem(it)
|
||||||
updateMiniDrawer()
|
updateMiniDrawer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setItems(vararg items: IDrawerItem<*>) {
|
fun setItems(vararg items: IDrawerItem<*>) {
|
||||||
drawer?.removeAllItems()
|
drawer.removeAllItems()
|
||||||
drawer?.addItems(*items)
|
drawer.addItems(*items)
|
||||||
updateMiniDrawer()
|
updateMiniDrawer()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,55 +276,81 @@ class NavDrawer(
|
|||||||
| | | | | |\ V / (_| | || __/ | | | | | | __/ |_| | | | (_) | (_| \__ \
|
| | | | | |\ V / (_| | || __/ | | | | | | __/ |_| | | | (_) | (_| \__ \
|
||||||
|_| |_| |_| \_/ \__,_|\__\___| |_| |_| |_|\___|\__|_| |_|\___/ \__,_|__*/
|
|_| |_| |_| \_/ \__,_|\__\___| |_| |_| |_|\___|\__|_| |_|\___/ \__,_|__*/
|
||||||
private fun drawerSetDragMargin(size: Float) {
|
private fun drawerSetDragMargin(size: Float) {
|
||||||
val mDrawerLayout = drawer?.drawerLayout
|
try {
|
||||||
val mDragger = mDrawerLayout?.javaClass?.getDeclaredField(
|
val mDrawerLayout = drawerLayout
|
||||||
"mLeftDragger"
|
val mDragger = mDrawerLayout::class.java.getDeclaredField(
|
||||||
)//mRightDragger for right obviously
|
"mLeftDragger"
|
||||||
mDragger?.isAccessible = true
|
)
|
||||||
val draggerObj = mDragger?.get(mDrawerLayout) as ViewDragHelper?
|
mDragger.isAccessible = true
|
||||||
|
val draggerObj = mDragger.get(mDrawerLayout) as ViewDragHelper?
|
||||||
|
draggerObj?.edgeSize = size.toInt()
|
||||||
|
|
||||||
val mEdgeSize = draggerObj?.javaClass?.getDeclaredField(
|
// update for SDK >= 29 (Android 10)
|
||||||
"mEdgeSize"
|
val useSystemInsets = mDrawerLayout::class.java.getDeclaredField(
|
||||||
)
|
"sEdgeSizeUsingSystemGestureInsets"
|
||||||
mEdgeSize?.isAccessible = true
|
)
|
||||||
|
useSystemInsets.isAccessible = true
|
||||||
mEdgeSize?.setInt(
|
useSystemInsets.set(null, false)
|
||||||
draggerObj,
|
}
|
||||||
size.toInt()
|
catch (e: Exception) {
|
||||||
) //optimal value as for me, you may set any constant in dp
|
e.printStackTrace()
|
||||||
|
Toast.makeText(context, "Oops, proguard works", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var miniDrawerVisiblePortrait: Boolean? = null
|
||||||
|
set(value) {
|
||||||
|
field = value
|
||||||
|
val configuration = context.resources.configuration
|
||||||
|
decideDrawerMode(
|
||||||
|
configuration.orientation,
|
||||||
|
configuration.screenWidthDp,
|
||||||
|
configuration.screenHeightDp
|
||||||
|
)
|
||||||
|
}
|
||||||
|
var miniDrawerVisibleLandscape: Boolean? = null
|
||||||
|
set(value) {
|
||||||
|
field = value
|
||||||
|
val configuration = context.resources.configuration
|
||||||
|
decideDrawerMode(
|
||||||
|
configuration.orientation,
|
||||||
|
configuration.screenWidthDp,
|
||||||
|
configuration.screenHeightDp
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
internal fun decideDrawerMode(orientation: Int, widthDp: Int, heightDp: Int) {
|
internal fun decideDrawerMode(orientation: Int, widthDp: Int, heightDp: Int) {
|
||||||
|
val drawerLayoutParams = DrawerLayout.LayoutParams(WRAP_CONTENT, MATCH_PARENT).apply {
|
||||||
|
gravity = Gravity.START
|
||||||
|
}
|
||||||
|
val fixedLayoutParams = FrameLayout.LayoutParams(UIUtils.convertDpToPixel(300f, context).toInt(), MATCH_PARENT)
|
||||||
|
|
||||||
Log.d("NavLib", "Deciding drawer mode:")
|
Log.d("NavLib", "Deciding drawer mode:")
|
||||||
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||||
if (fixedDrawerContainer.childCount > 0) {
|
|
||||||
fixedDrawerContainer.removeAllViews()
|
|
||||||
}
|
|
||||||
Log.d("NavLib", "- fixed container disabled")
|
Log.d("NavLib", "- fixed container disabled")
|
||||||
drawer?.drawerLayout?.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)
|
|
||||||
if (drawer?.drawerLayout?.indexOfChild(drawerView) == -1) {
|
|
||||||
drawer?.drawerLayout?.addView(drawerView)
|
|
||||||
}
|
|
||||||
Log.d("NavLib", "- slider enabled")
|
|
||||||
|
|
||||||
if (miniDrawerContainerLandscape.childCount > 0) {
|
if (drawerContainerLandscape.childCount > 0) {
|
||||||
miniDrawerContainerLandscape.removeAllViews()
|
drawerContainerLandscape.removeAllViews()
|
||||||
}
|
}
|
||||||
Log.d("NavLib", "- mini drawer land disabled")
|
Log.d("NavLib", "- mini drawer land disabled")
|
||||||
|
|
||||||
if (widthDp >= 480) {
|
if (drawerLayout.indexOfChild(drawer) == -1) {
|
||||||
if (miniDrawerView == null)
|
drawerLayout.addView(drawer, drawerLayoutParams)
|
||||||
miniDrawerView = miniDrawer?.build(context)
|
}
|
||||||
if (miniDrawerContainerPortrait.indexOfChild(miniDrawerView) == -1)
|
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)
|
||||||
miniDrawerContainerPortrait.addView(miniDrawerView)
|
Log.d("NavLib", "- slider enabled")
|
||||||
|
|
||||||
|
if ((widthDp >= 480 && miniDrawerVisiblePortrait != false) || miniDrawerVisiblePortrait == true) {
|
||||||
|
if (drawerContainerPortrait.indexOfChild(miniDrawer) == -1)
|
||||||
|
drawerContainerPortrait.addView(miniDrawer)
|
||||||
Log.d("NavLib", "- mini drawer port enabled")
|
Log.d("NavLib", "- mini drawer port enabled")
|
||||||
drawerSetDragMargin(72 * resources.displayMetrics.density)
|
drawerSetDragMargin(72 * resources.displayMetrics.density)
|
||||||
drawerMode = DRAWER_MODE_MINI
|
drawerMode = DRAWER_MODE_MINI
|
||||||
updateMiniDrawer()
|
updateMiniDrawer()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (miniDrawerContainerPortrait.childCount > 0) {
|
if (drawerContainerPortrait.childCount > 0) {
|
||||||
miniDrawerContainerPortrait.removeAllViews()
|
drawerContainerPortrait.removeAllViews()
|
||||||
}
|
}
|
||||||
Log.d("NavLib", "- mini drawer port disabled")
|
Log.d("NavLib", "- mini drawer port disabled")
|
||||||
drawerSetDragMargin(20 * resources.displayMetrics.density)
|
drawerSetDragMargin(20 * resources.displayMetrics.density)
|
||||||
@ -334,68 +358,67 @@ class NavDrawer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (miniDrawerContainerPortrait.childCount > 0) {
|
if (drawerContainerPortrait.childCount > 0) {
|
||||||
miniDrawerContainerPortrait.removeAllViews()
|
drawerContainerPortrait.removeAllViews()
|
||||||
}
|
}
|
||||||
Log.d("NavLib", "- mini drawer port disabled")
|
Log.d("NavLib", "- mini drawer port disabled")
|
||||||
|
|
||||||
if (widthDp in 480 until 9000) {
|
if ((widthDp in 480 until 900 && miniDrawerVisibleLandscape != false) || miniDrawerVisibleLandscape == true) {
|
||||||
if (miniDrawerView == null)
|
if (drawerContainerLandscape.indexOfChild(miniDrawer) == -1)
|
||||||
miniDrawerView = miniDrawer?.build(context)
|
drawerContainerLandscape.addView(miniDrawer)
|
||||||
if (miniDrawerContainerLandscape.indexOfChild(miniDrawerView) == -1)
|
|
||||||
miniDrawerContainerLandscape.addView(miniDrawerView)
|
|
||||||
Log.d("NavLib", "- mini drawer land enabled")
|
Log.d("NavLib", "- mini drawer land enabled")
|
||||||
drawerSetDragMargin(72 * resources.displayMetrics.density)
|
drawerSetDragMargin(72 * resources.displayMetrics.density)
|
||||||
drawerMode = DRAWER_MODE_MINI
|
drawerMode = DRAWER_MODE_MINI
|
||||||
updateMiniDrawer()
|
updateMiniDrawer()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (miniDrawerContainerLandscape.childCount > 0) {
|
if (drawerContainerLandscape.childCount > 0) {
|
||||||
miniDrawerContainerLandscape.removeAllViews()
|
drawerContainerLandscape.removeAllViews()
|
||||||
}
|
}
|
||||||
Log.d("NavLib", "- mini drawer land disabled")
|
Log.d("NavLib", "- mini drawer land disabled")
|
||||||
drawerSetDragMargin(20 * resources.displayMetrics.density)
|
drawerSetDragMargin(20 * resources.displayMetrics.density)
|
||||||
drawerMode = DRAWER_MODE_NORMAL
|
drawerMode = DRAWER_MODE_NORMAL
|
||||||
}
|
}
|
||||||
if (widthDp >= 9000) {
|
if (widthDp >= 900) {
|
||||||
// screen is big enough to show fixed drawer
|
// screen is big enough to show fixed drawer
|
||||||
if (drawer?.drawerLayout?.indexOfChild(drawerView) != -1) {
|
if (drawerLayout.indexOfChild(drawer) != -1) {
|
||||||
// remove from slider
|
// remove from slider
|
||||||
drawer?.drawerLayout?.removeView(drawerView)
|
drawerLayout.removeView(drawer)
|
||||||
}
|
}
|
||||||
// lock the slider
|
// lock the slider
|
||||||
drawer?.drawerLayout?.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
|
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
|
||||||
Log.d("NavLib", "- slider disabled")
|
Log.d("NavLib", "- slider disabled")
|
||||||
// add to fixed container
|
// add to fixed container
|
||||||
if (fixedDrawerContainer.indexOfChild(drawerView) == -1)
|
if (drawerContainerLandscape.indexOfChild(drawer) == -1)
|
||||||
fixedDrawerContainer.addView(drawerView)
|
drawerContainerLandscape.addView(drawer, fixedLayoutParams)
|
||||||
|
drawer.visibility = View.VISIBLE
|
||||||
Log.d("NavLib", "- fixed container enabled")
|
Log.d("NavLib", "- fixed container enabled")
|
||||||
drawerMode = DRAWER_MODE_FIXED
|
drawerMode = DRAWER_MODE_FIXED
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// screen is too small for the fixed drawer
|
// screen is too small for the fixed drawer
|
||||||
if (fixedDrawerContainer.childCount > 0) {
|
if (drawerContainerLandscape.indexOfChild(drawer) != -1) {
|
||||||
// remove from fixed container
|
// remove from fixed container
|
||||||
fixedDrawerContainer.removeAllViews()
|
drawerContainerLandscape.removeView(drawer)
|
||||||
}
|
}
|
||||||
Log.d("NavLib", "- fixed container disabled")
|
Log.d("NavLib", "- fixed container disabled")
|
||||||
// unlock the slider
|
// unlock the slider
|
||||||
drawer?.drawerLayout?.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)
|
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)
|
||||||
if (drawer?.drawerLayout?.indexOfChild(drawerView) == -1) {
|
if (drawerLayout.indexOfChild(drawer) == -1) {
|
||||||
// add to slider
|
// add to slider
|
||||||
drawer?.drawerLayout?.addView(drawerView)
|
drawerLayout.addView(drawer, drawerLayoutParams)
|
||||||
}
|
}
|
||||||
Log.d("NavLib", "- slider enabled")
|
Log.d("NavLib", "- slider enabled")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
miniDrawerElevation.visibility = if (drawerMode == DRAWER_MODE_MINI) View.VISIBLE else View.GONE
|
miniDrawerElevation.visibility = if (drawerMode == DRAWER_MODE_MINI || drawerMode == DRAWER_MODE_FIXED) View.VISIBLE else View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateMiniDrawer() {
|
private fun updateMiniDrawer() {
|
||||||
selection = drawer?.currentSelection?.toInt() ?: -1
|
selection = drawer.selectedItemIdentifier.toInt()
|
||||||
//if (drawerMode == DRAWER_MODE_MINI)
|
//if (drawerMode == DRAWER_MODE_MINI)
|
||||||
miniDrawer?.createItems()
|
miniDrawer.createItems()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* _____ _ _ _ _ _ _
|
/* _____ _ _ _ _ _ _
|
||||||
@ -405,45 +428,37 @@ class NavDrawer(
|
|||||||
| | | |_| | |_) | | | (__ | | | | | | __/ |_| | | | (_) | (_| \__ \
|
| | | |_| | |_) | | | (__ | | | | | | __/ |_| | | | (_) | (_| \__ \
|
||||||
|_| \__,_|_.__/|_|_|\___| |_| |_| |_|\___|\__|_| |_|\___/ \__,_|__*/
|
|_| \__,_|_.__/|_|_|\___| |_| |_| |_|\___|\__|_| |_|\___/ \__,_|__*/
|
||||||
var isOpen
|
var isOpen
|
||||||
get() = drawer?.isDrawerOpen ?: false || drawerMode == DRAWER_MODE_FIXED
|
get() = drawerLayout.isOpen || drawerMode == DRAWER_MODE_FIXED
|
||||||
set(value) {
|
set(value) {
|
||||||
if (drawerMode == DRAWER_MODE_FIXED)
|
if (drawerMode == DRAWER_MODE_FIXED)
|
||||||
return
|
return
|
||||||
if (value && !isOpen) drawer?.openDrawer() else if (!value && isOpen) drawer?.closeDrawer()
|
if (value && !isOpen) drawerLayout.open() else if (!value && isOpen) drawerLayout.close()
|
||||||
}
|
}
|
||||||
fun open() { isOpen = true }
|
fun open() { isOpen = true }
|
||||||
fun close() { isOpen = false }
|
fun close() { isOpen = false }
|
||||||
fun toggle() {
|
fun toggle() { isOpen = !isOpen }
|
||||||
if (drawer == null)
|
|
||||||
return
|
|
||||||
isOpen = !isOpen
|
|
||||||
}
|
|
||||||
|
|
||||||
var profileSelectionIsOpen
|
var profileSelectionIsOpen
|
||||||
get() = accountHeader?.isSelectionListShown == true
|
get() = accountHeader.selectionListShown
|
||||||
set(value) {
|
set(value) {
|
||||||
if (value != profileSelectionIsOpen)
|
if (value != profileSelectionIsOpen)
|
||||||
profileSelectionToggle()
|
profileSelectionToggle()
|
||||||
}
|
}
|
||||||
fun profileSelectionOpen() { profileSelectionIsOpen = true }
|
fun profileSelectionOpen() { profileSelectionIsOpen = true }
|
||||||
fun profileSelectionClose() { profileSelectionIsOpen = false }
|
fun profileSelectionClose() { profileSelectionIsOpen = false }
|
||||||
fun profileSelectionToggle() {
|
fun profileSelectionToggle() { accountHeader.selectionListShown = !accountHeader.selectionListShown }
|
||||||
accountHeader?.let {
|
|
||||||
it.toggleSelectionList(it.view.context)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var drawerOpenedListener: (() -> Unit)? = null
|
var drawerOpenedListener: (() -> Unit)? = null
|
||||||
var drawerClosedListener: (() -> Unit)? = null
|
var drawerClosedListener: (() -> Unit)? = null
|
||||||
var drawerItemSelectedListener: ((id: Int, position: Int, drawerItem: IDrawerItem<*>) -> Boolean)? = null
|
var drawerItemSelectedListener: ((id: Int, position: Int, drawerItem: IDrawerItem<*>) -> Boolean)? = null
|
||||||
var drawerItemLongClickListener: ((id: Int, position: Int, drawerItem: IDrawerItem<*>) -> Boolean)? = null
|
var drawerItemLongClickListener: ((id: Int, position: Int, drawerItem: IDrawerItem<*>) -> Boolean)? = null
|
||||||
var drawerProfileSelectedListener: ((id: Int, profile: IProfile<*>, current: Boolean, view: View?) -> Boolean)? = null
|
var drawerProfileSelectedListener: ((id: Int, profile: IProfile, current: Boolean, view: View?) -> Boolean)? = null
|
||||||
var drawerProfileLongClickListener: ((id: Int, profile: IProfile<*>, current: Boolean, view: View) -> Boolean)? = null
|
var drawerProfileLongClickListener: ((id: Int, profile: IProfile, current: Boolean, view: View?) -> Boolean)? = null
|
||||||
var drawerProfileImageClickListener: ((id: Int, profile: IProfile<*>, current: Boolean, view: View) -> Boolean)? = null
|
var drawerProfileImageClickListener: ((id: Int, profile: IProfile, current: Boolean, view: View) -> Boolean)? = null
|
||||||
var drawerProfileImageLongClickListener: ((id: Int, profile: IProfile<*>, current: Boolean, view: View) -> Boolean)? = null
|
var drawerProfileImageLongClickListener: ((id: Int, profile: IProfile, current: Boolean, view: View) -> Boolean)? = null
|
||||||
var drawerProfileListEmptyListener: (() -> Unit)? = null
|
var drawerProfileListEmptyListener: (() -> Unit)? = null
|
||||||
var drawerProfileSettingClickListener: ((id: Int, view: View?) -> Boolean)? = null
|
var drawerProfileSettingClickListener: ((id: Int, view: View?) -> Boolean)? = null
|
||||||
var drawerProfileSettingLongClickListener: ((id: Int, view: View) -> Boolean)? = null
|
var drawerProfileSettingLongClickListener: ((id: Int, view: View?) -> Boolean)? = null
|
||||||
|
|
||||||
fun miniDrawerEnabled(): Boolean = drawerMode == DRAWER_MODE_MINI
|
fun miniDrawerEnabled(): Boolean = drawerMode == DRAWER_MODE_MINI
|
||||||
fun fixedDrawerEnabled(): Boolean = drawerMode == DRAWER_MODE_FIXED
|
fun fixedDrawerEnabled(): Boolean = drawerMode == DRAWER_MODE_FIXED
|
||||||
@ -455,25 +470,26 @@ class NavDrawer(
|
|||||||
profileSelectionClose()
|
profileSelectionClose()
|
||||||
selection = id
|
selection = id
|
||||||
|
|
||||||
if (drawer?.currentSelection != id.toLong()) {
|
if (drawer.selectedItemIdentifier != id.toLong()) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drawer?.currentSelection != id.toLong() || !fireOnClick)
|
if (drawer.selectedItemIdentifier != id.toLong() || !fireOnClick)
|
||||||
drawer?.setSelection(id.toLong(), fireOnClick)
|
drawer.setSelectionAtPosition(drawer.getPosition(id.toLong()), fireOnClick)
|
||||||
|
|
||||||
|
miniDrawer.setSelection(-1L)
|
||||||
if (drawerMode == DRAWER_MODE_MINI)
|
if (drawerMode == DRAWER_MODE_MINI)
|
||||||
miniDrawer?.setSelection(id.toLong())
|
miniDrawer.setSelection(id.toLong())
|
||||||
}
|
}
|
||||||
fun getSelection(): Int = selection
|
fun getSelection(): Int = selection
|
||||||
|
|
||||||
// TODO 2019-08-27 add methods for Drawable, @DrawableRes
|
// TODO 2019-08-27 add methods for Drawable, @DrawableRes
|
||||||
fun setAccountHeaderBackground(path: String?) {
|
fun setAccountHeaderBackground(path: String?) {
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
accountHeader?.setBackgroundRes(R.drawable.header)
|
accountHeader.headerBackground = ImageHolder(R.drawable.header)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
accountHeader?.setHeaderBackground(ImageHolder(path))
|
accountHeader.headerBackground = ImageHolder(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* _____ __ _ _
|
/* _____ __ _ _
|
||||||
@ -485,12 +501,12 @@ class NavDrawer(
|
|||||||
private var profileList: MutableList<IDrawerProfile> = mutableListOf()
|
private var profileList: MutableList<IDrawerProfile> = mutableListOf()
|
||||||
|
|
||||||
fun addProfileSettings(vararg items: ProfileSettingDrawerItem) {
|
fun addProfileSettings(vararg items: ProfileSettingDrawerItem) {
|
||||||
accountHeader?.profiles?.addAll(items)
|
accountHeader.profiles?.addAll(items)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateProfileList() {
|
private fun updateProfileList() {
|
||||||
// remove all profile items
|
// remove all profile items
|
||||||
val profiles = accountHeader?.profiles?.filterNot { it is ProfileDrawerItem } as MutableList<IProfile<*>>?
|
val profiles = accountHeader.profiles?.filterNot { it is ProfileDrawerItem } as MutableList<IProfile>?
|
||||||
|
|
||||||
if (profileList.isEmpty())
|
if (profileList.isEmpty())
|
||||||
drawerProfileListEmptyListener?.invoke()
|
drawerProfileListEmptyListener?.invoke()
|
||||||
@ -502,12 +518,14 @@ class NavDrawer(
|
|||||||
.withName(profile.name)
|
.withName(profile.name)
|
||||||
.withEmail(profile.subname)
|
.withEmail(profile.subname)
|
||||||
.also { it.icon = image }
|
.also { it.icon = image }
|
||||||
|
.withBadgeStyle(badgeStyle)
|
||||||
.withNameShown(true)
|
.withNameShown(true)
|
||||||
.also { profiles?.add(index, it) }
|
.also { profiles?.add(index, it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
accountHeader?.profiles = profiles
|
accountHeader.profiles = profiles
|
||||||
|
|
||||||
|
updateBadges()
|
||||||
updateMiniDrawer()
|
updateMiniDrawer()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,14 +533,16 @@ class NavDrawer(
|
|||||||
profileList = profiles as MutableList<IDrawerProfile>
|
profileList = profiles as MutableList<IDrawerProfile>
|
||||||
updateProfileList()
|
updateProfileList()
|
||||||
}
|
}
|
||||||
|
private var currentProfileObj: IDrawerProfile? = null
|
||||||
val profileListEmpty: Boolean
|
val profileListEmpty: Boolean
|
||||||
get() = profileList.isEmpty()
|
get() = profileList.isEmpty()
|
||||||
var currentProfile: Int
|
var currentProfile: Int
|
||||||
get() = accountHeader?.activeProfile?.identifier?.toInt() ?: -1
|
get() = accountHeader.activeProfile?.identifier?.toInt() ?: -1
|
||||||
set(value) {
|
set(value) {
|
||||||
Log.d("NavDebug", "currentProfile = $value")
|
Log.d("NavDebug", "currentProfile = $value")
|
||||||
accountHeader?.setActiveProfile(value.toLong(), false)
|
accountHeader.setActiveProfile(value.toLong(), false)
|
||||||
setToolbarProfileImage(profileList.singleOrNull { it.id == value })
|
currentProfileObj = profileList.singleOrNull { it.id == value }
|
||||||
|
setToolbarProfileImage(currentProfileObj)
|
||||||
updateBadges()
|
updateBadges()
|
||||||
}
|
}
|
||||||
fun appendProfile(profile: IDrawerProfile) {
|
fun appendProfile(profile: IDrawerProfile) {
|
||||||
@ -562,7 +582,7 @@ class NavDrawer(
|
|||||||
updateProfileList()
|
updateProfileList()
|
||||||
}
|
}
|
||||||
fun removeAllProfileSettings() {
|
fun removeAllProfileSettings() {
|
||||||
accountHeader?.profiles = accountHeader?.profiles?.filterNot { it is ProfileSettingDrawerItem }?.toMutableList()
|
accountHeader.profiles = accountHeader.profiles?.filterNot { it is ProfileSettingDrawerItem }?.toMutableList()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getProfileById(id: Int, run: (it: IDrawerProfile?) -> Unit) {
|
fun getProfileById(id: Int, run: (it: IDrawerProfile?) -> Unit) {
|
||||||
@ -595,20 +615,51 @@ class NavDrawer(
|
|||||||
private val unreadCounterTypeMap = mutableMapOf<Int, Int>()
|
private val unreadCounterTypeMap = mutableMapOf<Int, Int>()
|
||||||
|
|
||||||
fun updateBadges() {
|
fun updateBadges() {
|
||||||
|
|
||||||
|
currentProfileObj = profileList.singleOrNull { it.id == currentProfile }
|
||||||
|
|
||||||
|
drawer.itemAdapter.itemList.items.forEachIndexed { index, item ->
|
||||||
|
if (item is Badgeable) {
|
||||||
|
item.badge = null
|
||||||
|
drawer.updateItem(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var profileCounters = listOf<IUnreadCounter>()
|
||||||
|
|
||||||
|
accountHeader.profiles?.forEach { profile ->
|
||||||
|
if (profile !is ProfileDrawerItem) return@forEach
|
||||||
|
val counters = unreadCounterList.filter { it.profileId == profile.identifier.toInt() }
|
||||||
|
val count = counters.sumBy { it.count }
|
||||||
|
val badge = when {
|
||||||
|
count == 0 -> null
|
||||||
|
count >= 99 -> StringHolder("99+")
|
||||||
|
else -> StringHolder(count.toString())
|
||||||
|
}
|
||||||
|
if (profile.badge != badge) {
|
||||||
|
profile.badge = badge
|
||||||
|
accountHeader.updateProfile(profile)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentProfile == profile.identifier.toInt())
|
||||||
|
profileCounters = counters
|
||||||
|
}
|
||||||
|
|
||||||
Log.d("NavDebug", "updateBadges()")
|
Log.d("NavDebug", "updateBadges()")
|
||||||
unreadCounterList.map {
|
profileCounters.map {
|
||||||
it.drawerItemId = unreadCounterTypeMap[it.type]
|
it.drawerItemId = unreadCounterTypeMap[it.type]
|
||||||
}
|
}
|
||||||
unreadCounterList.forEach {
|
var totalCount = 0
|
||||||
|
profileCounters.forEach {
|
||||||
if (it.drawerItemId == null)
|
if (it.drawerItemId == null)
|
||||||
return@forEach
|
return@forEach
|
||||||
if (it.profileId != currentProfile) {
|
if (it.profileId != currentProfile) {
|
||||||
Log.d("NavDebug", "- Remove badge for ${it.drawerItemId}")
|
//Log.d("NavDebug", "- Remove badge for ${it.drawerItemId}")
|
||||||
drawer?.updateBadge(it.drawerItemId?.toLong() ?: 0, null)
|
//drawer?.updateBadge(it.drawerItemId?.toLong() ?: 0, null)
|
||||||
return@forEach
|
return@forEach
|
||||||
}
|
}
|
||||||
Log.d("NavDebug", "- Set badge ${it.count} for ${it.drawerItemId}")
|
Log.d("NavDebug", "- Set badge ${it.count} for ${it.drawerItemId}")
|
||||||
drawer?.updateBadge(
|
drawer.updateBadge(
|
||||||
it.drawerItemId?.toLong() ?: 0,
|
it.drawerItemId?.toLong() ?: 0,
|
||||||
when {
|
when {
|
||||||
it.count == 0 -> null
|
it.count == 0 -> null
|
||||||
@ -616,8 +667,36 @@ class NavDrawer(
|
|||||||
else -> StringHolder(it.count.toString())
|
else -> StringHolder(it.count.toString())
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
totalCount += it.count
|
||||||
}
|
}
|
||||||
updateMiniDrawer()
|
updateMiniDrawer()
|
||||||
|
|
||||||
|
if (bottomBar.navigationIcon is LayerDrawable) {
|
||||||
|
(bottomBar.navigationIcon as LayerDrawable?)?.apply {
|
||||||
|
findDrawableByLayerId(R.id.ic_badge)
|
||||||
|
.takeIf { it is BadgeDrawable }
|
||||||
|
?.also { badge ->
|
||||||
|
(badge as BadgeDrawable).setCount(totalCount.toString())
|
||||||
|
mutate()
|
||||||
|
setDrawableByLayerId(R.id.ic_badge, badge)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalCount == 0) {
|
||||||
|
toolbar.subtitle = resources.getString(
|
||||||
|
toolbar.subtitleFormat ?: return,
|
||||||
|
currentProfileObj?.name ?: ""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
toolbar.subtitle = resources.getQuantityString(
|
||||||
|
toolbar.subtitleFormatWithUnread ?: toolbar.subtitleFormat ?: return,
|
||||||
|
totalCount,
|
||||||
|
currentProfileObj?.name ?: "",
|
||||||
|
totalCount
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setUnreadCounterList(unreadCounterList: MutableList<out IUnreadCounter>) {
|
fun setUnreadCounterList(unreadCounterList: MutableList<out IUnreadCounter>) {
|
||||||
@ -642,10 +721,10 @@ class NavDrawer(
|
|||||||
}
|
}
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
item.count = count
|
item.count = count
|
||||||
updateBadges()
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
unreadCounterList.add(UnreadCounter(profileId, type, null, count))
|
unreadCounterList.add(UnreadCounter(profileId, type, null, count))
|
||||||
}
|
}
|
||||||
|
updateBadges()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
navlib/src/main/res/drawable/ic_menu_badge.xml
Normal file
10
navlib/src/main/res/drawable/ic_menu_badge.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item
|
||||||
|
android:id="@+id/ic_menu"
|
||||||
|
android:drawable="@drawable/placeholder"
|
||||||
|
android:gravity="center" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/ic_badge"
|
||||||
|
android:drawable="@drawable/placeholder" />
|
||||||
|
</layer-list>
|
3
navlib/src/main/res/drawable/placeholder.xml
Normal file
3
navlib/src/main/res/drawable/placeholder.xml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
</shape>
|
@ -32,8 +32,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/bottom_sheet_background"
|
android:background="@drawable/bottom_sheet_background"
|
||||||
android:paddingStart="8dp"
|
android:paddingHorizontal="8dp"
|
||||||
android:paddingEnd="8dp"
|
|
||||||
tools:paddingBottom="48dp"
|
tools:paddingBottom="48dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
@ -107,4 +106,4 @@
|
|||||||
</androidx.core.widget.NestedScrollView>
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
tools:parentTag="FrameLayout">
|
tools:parentTag="FrameLayout">
|
||||||
|
|
||||||
<LinearLayout
|
<androidx.drawerlayout.widget.DrawerLayout
|
||||||
android:id="@+id/nv_drawerContainer"
|
android:id="@+id/nv_drawerLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
@ -37,33 +37,39 @@
|
|||||||
tools:paddingBottom="48dp">
|
tools:paddingBottom="48dp">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/nv_miniDrawerContainerLandscape"
|
android:id="@+id/nv_drawerContainerLandscape"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:background="#2196f3" /><!--tools:layout_width="72dp"-->
|
android:background="@color/colorSurface_4dp"
|
||||||
|
tools:layout_width="72dp" />
|
||||||
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
android:id="@+id/nv_coordinator"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<pl.szczodrzynski.navlib.NavToolbar
|
<pl.szczodrzynski.navlib.NavToolbar
|
||||||
android:id="@+id/nv_toolbar"
|
android:id="@+id/nv_toolbar"
|
||||||
|
style="@style/Widget.MaterialComponents.Toolbar.Surface"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="wrap_content"
|
||||||
android:background="?actionBarBackground"
|
android:background="?actionBarBackground"
|
||||||
|
android:clipToPadding="false"
|
||||||
android:elevation="4dp"
|
android:elevation="4dp"
|
||||||
|
android:minHeight="?attr/actionBarSize"
|
||||||
app:title="@string/app_name"
|
app:title="@string/app_name"
|
||||||
|
app:titleMargin="0dp"
|
||||||
tools:targetApi="lollipop">
|
tools:targetApi="lollipop">
|
||||||
|
|
||||||
<com.mikepenz.materialdrawer.view.BezelImageView
|
<com.mikepenz.materialdrawer.view.BezelImageView
|
||||||
android:id="@+id/nv_toolbar_image"
|
android:id="@+id/nv_toolbar_image"
|
||||||
android:layout_width="30dp"
|
android:layout_width="30dp"
|
||||||
android:layout_height="30dp"
|
android:layout_height="30dp"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="center_vertical|end"
|
||||||
android:layout_marginEnd="13dp"
|
android:layout_marginEnd="13dp"
|
||||||
android:layout_marginRight="13dp"
|
android:layout_marginRight="13dp"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
app:biv_selectorOnPress="#80ffffff"
|
app:materialDrawerSelectorOnPress="#80ffffff"
|
||||||
tools:src="@tools:sample/backgrounds/scenic" />
|
tools:src="@tools:sample/backgrounds/scenic" />
|
||||||
|
|
||||||
</pl.szczodrzynski.navlib.NavToolbar>
|
</pl.szczodrzynski.navlib.NavToolbar>
|
||||||
@ -89,7 +95,8 @@
|
|||||||
android:id="@+id/nv_miniDrawerContainerPortrait"
|
android:id="@+id/nv_miniDrawerContainerPortrait"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:background="#ffb300" /><!--tools:layout_width="72dp"-->
|
android:background="@color/colorSurface_4dp"
|
||||||
|
tools:layout_width="72dp" /><!--tools:layout_width="72dp"-->
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/nv_miniDrawerElevation"
|
android:id="@+id/nv_miniDrawerElevation"
|
||||||
@ -105,10 +112,34 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
|
android:gravity="start"
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
app:fabAlignmentMode="center"
|
app:fabAlignmentMode="center"
|
||||||
app:fabAnimationMode="scale" />
|
app:fabAnimationMode="scale" />
|
||||||
|
|
||||||
|
<com.balysv.materialripple.MaterialRippleLayout
|
||||||
|
android:id="@+id/ripple"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="?actionBarSize"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:enabled="false"
|
||||||
|
android:focusableInTouchMode="false"
|
||||||
|
android:focusable="false"
|
||||||
|
app:mrl_rippleFadeDuration="200"
|
||||||
|
app:mrl_rippleDuration="350"
|
||||||
|
app:mrl_rippleColor="?colorOnBackground"
|
||||||
|
app:mrl_rippleAlpha="0.3">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:enabled="false"
|
||||||
|
android:focusableInTouchMode="false"
|
||||||
|
android:focusable="false"
|
||||||
|
android:visibility="invisible"/>
|
||||||
|
|
||||||
|
</com.balysv.materialripple.MaterialRippleLayout>
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||||
android:id="@+id/nv_extendedFloatingActionButton"
|
android:id="@+id/nv_extendedFloatingActionButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -149,13 +180,7 @@
|
|||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<FrameLayout
|
</androidx.drawerlayout.widget.DrawerLayout>
|
||||||
android:id="@+id/nv_fixedDrawerContainer"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:background="#4caf50"/><!--tools:layout_width="300dp"-->
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/nv_statusBarDarker"
|
android:id="@+id/nv_statusBarDarker"
|
||||||
@ -183,4 +208,4 @@
|
|||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
|
||||||
</merge>
|
</merge>
|
||||||
|
4
navlib/src/main/res/values/dimens.xml
Normal file
4
navlib/src/main/res/values/dimens.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<dimen name="badge_text_size">10sp</dimen>
|
||||||
|
</resources>
|
@ -1,3 +1,4 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">NavLib</string>
|
<string name="app_name">NavLib</string>
|
||||||
|
<string name="toolbar_subtitle">%1$s</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -95,16 +95,9 @@
|
|||||||
<item name="android:textViewStyle">@style/NavView.TextView</item>
|
<item name="android:textViewStyle">@style/NavView.TextView</item>
|
||||||
|
|
||||||
<!-- drawer & bottom sheet styling -->
|
<!-- drawer & bottom sheet styling -->
|
||||||
<item name="material_drawer_background">?android:colorBackground</item>
|
<item name="materialDrawerStyle">@style/Widget.MaterialDrawerStyle</item>
|
||||||
<item name="material_drawer_primary_text">?android:textColorPrimary</item>
|
<item name="materialDrawerHeaderStyle">@style/Widget.MaterialDrawerHeaderStyle</item>
|
||||||
<item name="material_drawer_primary_icon">#5F6368</item>
|
<!--<item name="materialDrawerPrimaryIcon">#5F6368</item>-->
|
||||||
<item name="material_drawer_secondary_text">?android:textColorSecondary</item>
|
|
||||||
<item name="material_drawer_hint_text">@color/material_drawer_hint_text</item>
|
|
||||||
<item name="material_drawer_divider">@color/material_drawer_divider</item>
|
|
||||||
<item name="material_drawer_selected">@color/material_drawer_selected</item> <!-- Material 2 defines 12% alpha, primary color -->
|
|
||||||
<item name="material_drawer_selected_text">#242424</item>
|
|
||||||
<item name="material_drawer_header_selection_text">@color/material_drawer_header_selection_text</item>
|
|
||||||
<item name="material_drawer_header_selection_subtext">@color/material_drawer_dark_header_selection_subtext</item>
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="NavView.Dark" parent="Theme.MaterialComponents.NoActionBar">
|
<style name="NavView.Dark" parent="Theme.MaterialComponents.NoActionBar">
|
||||||
@ -148,16 +141,9 @@
|
|||||||
<item name="android:textViewStyle">@style/NavView.TextView</item>
|
<item name="android:textViewStyle">@style/NavView.TextView</item>
|
||||||
|
|
||||||
<!-- drawer & bottom sheet styling -->
|
<!-- drawer & bottom sheet styling -->
|
||||||
<item name="material_drawer_background">?android:colorBackground</item>
|
<item name="materialDrawerStyle">@style/Widget.MaterialDrawerStyle</item>
|
||||||
<item name="material_drawer_primary_text">?android:textColorPrimary</item>
|
<item name="materialDrawerHeaderStyle">@style/Widget.MaterialDrawerHeaderStyle</item>
|
||||||
<item name="material_drawer_primary_icon">#9AA0A6</item>
|
<!--<item name="material_drawer_primary_icon">#9AA0A6</item>-->
|
||||||
<item name="material_drawer_secondary_text">?android:textColorSecondary</item>
|
|
||||||
<item name="material_drawer_hint_text">@color/material_drawer_dark_hint_text</item>
|
|
||||||
<item name="material_drawer_divider">@color/material_drawer_dark_divider</item>
|
|
||||||
<item name="material_drawer_selected">@color/material_drawer_dark_selected</item> <!-- Material 2 defines 12% alpha, primary color -->
|
|
||||||
<item name="material_drawer_selected_text">#FFFFFF</item>
|
|
||||||
<item name="material_drawer_header_selection_text">@color/material_drawer_dark_header_selection_text</item>
|
|
||||||
<item name="material_drawer_header_selection_subtext">@color/material_drawer_dark_header_selection_subtext</item>
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="NavView.Black" parent="NavView.Dark">
|
<style name="NavView.Black" parent="NavView.Dark">
|
||||||
@ -170,4 +156,4 @@
|
|||||||
<style name="width_max_600dp">
|
<style name="width_max_600dp">
|
||||||
<item name="android:layout_width">match_parent</item>
|
<item name="android:layout_width">match_parent</item>
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1 +1 @@
|
|||||||
include ':app', ':navlib'
|
include ':app', ':navlib', ':navlib-font'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user