diff --git a/build.gradle b/build.gradle
index 2476f92..5a6d3d8 100644
--- a/build.gradle
+++ b/build.gradle
@@ -30,7 +30,7 @@ buildscript {
minSdk : 14,
targetSdk : 28,
version : "3.0.0",
- supportLib: "1.0.0-rc01"
+ supportLib: "1.0.0-rc02"
]
}
@@ -41,8 +41,8 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.3.0-alpha06'
- classpath 'com.novoda:bintray-release:0.8.1'
+ classpath 'com.android.tools.build:gradle:3.3.0-alpha11'
+ classpath 'guru.stefma.bintrayrelease:bintrayrelease:1.0.0'
}
}
diff --git a/library/build.gradle b/library/build.gradle
index efdbef1..b3216d1 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -23,7 +23,7 @@
*/
apply plugin: 'com.android.library'
-apply plugin: 'com.novoda.bintray-release'
+apply plugin: "guru.stefma.bintrayrelease"
android {
@@ -59,12 +59,14 @@ android {
dependencies {
implementation "androidx.annotation:annotation:${var.supportLib}"
+ implementation "androidx.fragment:fragment:${var.supportLib}"
}
+version = '3.0.0'
+group = 'rebus'
publish {
userOrg = 'raphaelbussa'
- groupId = 'rebus'
artifactId = 'header-view'
- publishVersion = "${var.version}"
desc = 'Create an header for android.support.design.widget.NavigationView'
+ website = 'https://rebus007.github.io/HeaderView/'
}
\ No newline at end of file
diff --git a/library/src/main/java/rebus/header/view/HeaderView.java b/library/src/main/java/rebus/header/view/HeaderView.java
index f2fcab3..896cf30 100644
--- a/library/src/main/java/rebus/header/view/HeaderView.java
+++ b/library/src/main/java/rebus/header/view/HeaderView.java
@@ -25,7 +25,6 @@
package rebus.header.view;
import android.annotation.SuppressLint;
-import android.app.FragmentManager;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
@@ -54,6 +53,7 @@
import androidx.annotation.IntDef;
import androidx.annotation.IntRange;
import androidx.annotation.RestrictTo;
+import androidx.fragment.app.FragmentManager;
import de.hdodenhof.circleimageview.CircleImageView;
import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP;
diff --git a/library/src/main/java/rebus/header/view/ProfileChooserFragment.java b/library/src/main/java/rebus/header/view/ProfileChooserFragment.java
index 4f46c82..48f0db3 100644
--- a/library/src/main/java/rebus/header/view/ProfileChooserFragment.java
+++ b/library/src/main/java/rebus/header/view/ProfileChooserFragment.java
@@ -25,7 +25,6 @@
package rebus.header.view;
import android.annotation.SuppressLint;
-import android.app.DialogFragment;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.SparseArray;
@@ -41,6 +40,7 @@
import java.util.List;
import androidx.annotation.Nullable;
+import androidx.fragment.app.DialogFragment;
/**
* Created by raphaelbussa on 21/01/17.
diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml
index 8c39ecb..761872a 100644
--- a/sample/src/main/AndroidManifest.xml
+++ b/sample/src/main/AndroidManifest.xml
@@ -43,6 +43,8 @@
+
+
\ No newline at end of file
diff --git a/sample/src/main/java/rebus/header/view/sample/CompactHeaderActivity.java b/sample/src/main/java/rebus/header/view/sample/CompactHeaderActivity.java
new file mode 100644
index 0000000..151c9d0
--- /dev/null
+++ b/sample/src/main/java/rebus/header/view/sample/CompactHeaderActivity.java
@@ -0,0 +1,182 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Raphaël Bussa
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package rebus.header.view.sample;
+
+import android.os.Bundle;
+import android.util.Log;
+import android.widget.Toast;
+
+import com.google.android.material.navigation.NavigationView;
+
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+import androidx.core.content.ContextCompat;
+import androidx.core.view.GravityCompat;
+import androidx.drawerlayout.widget.DrawerLayout;
+import rebus.header.view.HeaderCallback;
+import rebus.header.view.HeaderView;
+import rebus.header.view.Item;
+import rebus.header.view.Profile;
+//import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
+
+public class CompactHeaderActivity extends AppCompatActivity {
+
+ private static final String TAG = CompactHeaderActivity.class.getName();
+
+ private HeaderView headerView;
+ private DrawerLayout drawerLayout;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_compact_header);
+ Toolbar toolbar = findViewById(R.id.toolbar);
+ toolbar.setTitle(getString(R.string.app_name));
+ toolbar.setNavigationOnClickListener(view -> {
+ if (drawerLayout != null && !drawerLayout.isDrawerOpen(GravityCompat.START)) {
+ drawerLayout.openDrawer(GravityCompat.START);
+ }
+ });
+ drawerLayout = findViewById(R.id.drawer_layout);
+ NavigationView navigationView = findViewById(R.id.nav_view);
+ headerView = navigationView.getHeaderView(0).findViewById(R.id.header_view);
+
+ Profile profile = new Profile.Builder()
+ .setId(2)
+ .setUsername("Raphaël Bussa")
+ .setEmail("raphaelbussa@gmail.com")
+ .setAvatar("https://github.com/rebus007.png?size=512")
+ .setBackground("https://images.unsplash.com/photo-1473220464492-452fb02e6221?dpr=2&auto=format&fit=crop&w=767&h=512&q=80&cs=tinysrgb&crop=")
+ .build();
+
+ Profile profile2 = new Profile.Builder()
+ .setId(4)
+ .setUsername("Federico Gentile")
+ .setEmail("fgentile95dev@icloud.com")
+ .setAvatar("https://github.com/FedeGens.png?size=512")
+ .setBackground("https://images.unsplash.com/photo-1469173479606-ada03df615ac?dpr=2&auto=format&fit=crop&w=767&h=511&q=80&cs=tinysrgb&crop=")
+ .build();
+
+ Profile profile3 = new Profile.Builder()
+ .setId(6)
+ .setUsername("Luca Rurio")
+ .setEmail("rurio.luca@gmail.com")
+ .setAvatar("https://github.com/RurioLuca.png?size=512")
+ .setBackground("https://images.unsplash.com/photo-1473789810014-375ed569d0ed?dpr=2&auto=format&fit=crop&w=767&h=511&q=80&cs=tinysrgb&crop=")
+ .build();
+
+ Profile profile4 = new Profile.Builder()
+ .setId(8)
+ .setUsername("Krzysztof Klimkiewicz")
+ .setEmail("krzkz94@gmail.com")
+ .setAvatar("https://github.com/krzykz.png?size=512")
+ .setBackground("https://images.unsplash.com/photo-1452509133926-2b180c6d6245?dpr=2&auto=format&fit=crop&w=767&h=431&q=80&cs=tinysrgb&crop=")
+ .build();
+
+ Item item = new Item.Builder()
+ .setId(1)
+ .setTitle("Remove all profile")
+ .build();
+
+ Item item2 = new Item.Builder()
+ .setId(2)
+ .setTitle("Remove active profile")
+ .build();
+
+
+ headerView.setStyle(HeaderView.STYLE_COMPACT);
+ headerView.setTheme(HeaderView.THEME_LIGHT);
+ headerView.setShowGradient(true);
+ headerView.setHighlightColor(ContextCompat.getColor(this, R.color.colorAccent));
+ headerView.addProfile(profile, profile2, profile3, profile4);
+ headerView.addDialogItem(item, item2);
+ headerView.setShowAddButton(true);
+ //headerView.setAddIconDrawable(R.drawable.ic_action_settings);
+ headerView.setDialogTitle("Choose account");
+ headerView.setShowArrow(true);
+ headerView.setOnHeaderClickListener(v -> drawerLayout.closeDrawer(GravityCompat.START, true));
+ headerView.setFragmentManager(getSupportFragmentManager());
+ headerView.setCallback(new HeaderCallback() {
+
+ @Override
+ public boolean onSelect(int id, boolean isActive) {
+ Log.d(TAG, "profile selected [" + id + "] isActive [" + isActive + "]");
+ Toast.makeText(CompactHeaderActivity.this, "profile selected [" + id + "] isActive [" + isActive + "]", Toast.LENGTH_SHORT).show();
+ drawerLayout.closeDrawer(GravityCompat.START, true);
+ return true;
+ }
+
+ @Override
+ public boolean onItem(int id) {
+ switch (id) {
+ case 1:
+ headerView.clearProfile();
+ break;
+ case 2:
+ int profileId = headerView.getProfileActive();
+ headerView.removeProfile(profileId);
+ break;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean onAdd() {
+ Profile newProfile = new Profile.Builder()
+ .setId(100)
+ .setUsername("Mattia Novelli")
+ .setEmail("nove.mattia@gmail.com")
+ .setAvatar("https://github.com/mattinove.png?size=512")
+ .setBackground("https://images.unsplash.com/photo-1478194409487-fa5c1eb18622?dpr=2&auto=format&fit=crop&w=767&h=496&q=80&cs=tinysrgb&crop=")
+ .build();
+ headerView.addProfile(newProfile);
+ headerView.setProfileActive(100);
+ headerView.dismissProfileChooser();
+ return false;
+ }
+
+ });
+
+ //headerView.addProfile(profile, profile2, profile3);
+
+ }
+
+ @Override
+ public void onBackPressed() {
+ if (drawerLayout != null && drawerLayout.isDrawerOpen(GravityCompat.START)) {
+ drawerLayout.closeDrawer(GravityCompat.START);
+ return;
+ }
+ super.onBackPressed();
+ }
+
+/*
+ @Override
+ protected void attachBaseContext(Context newBase) {
+ super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
+ }
+*/
+
+}
diff --git a/sample/src/main/java/rebus/header/view/sample/MainActivity.java b/sample/src/main/java/rebus/header/view/sample/MainActivity.java
index 04576d0..3fdcf85 100644
--- a/sample/src/main/java/rebus/header/view/sample/MainActivity.java
+++ b/sample/src/main/java/rebus/header/view/sample/MainActivity.java
@@ -1,192 +1,44 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2017 Raphaël Bussa
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
package rebus.header.view.sample;
+import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
-import android.util.Log;
import android.view.MenuItem;
+import android.view.Window;
+import android.view.WindowManager;
import android.widget.TextView;
-import android.widget.Toast;
-
-import com.google.android.material.navigation.NavigationView;
+import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
-import androidx.core.view.GravityCompat;
-import androidx.drawerlayout.widget.DrawerLayout;
-import rebus.header.view.HeaderCallback;
-import rebus.header.view.HeaderView;
-import rebus.header.view.Item;
-import rebus.header.view.Profile;
-//import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
public class MainActivity extends AppCompatActivity implements Toolbar.OnMenuItemClickListener {
- private static final String TAG = MainActivity.class.getName();
-
- private HeaderView headerView;
- private DrawerLayout drawerLayout;
-
@Override
- protected void onCreate(Bundle savedInstanceState) {
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setTitle(getString(R.string.app_name));
toolbar.inflateMenu(R.menu.menu_main);
toolbar.setOnMenuItemClickListener(this);
- toolbar.setNavigationOnClickListener(view -> {
- if (drawerLayout != null && !drawerLayout.isDrawerOpen(GravityCompat.START)) {
- drawerLayout.openDrawer(GravityCompat.START);
- }
- });
- drawerLayout = findViewById(R.id.drawer_layout);
- NavigationView navigationView = findViewById(R.id.nav_view);
- headerView = navigationView.getHeaderView(0).findViewById(R.id.header_view);
-
- Profile profile = new Profile.Builder()
- .setId(2)
- .setUsername("Raphaël Bussa")
- .setEmail("raphaelbussa@gmail.com")
- .setAvatar("https://github.com/rebus007.png?size=512")
- .setBackground("https://images.unsplash.com/photo-1473220464492-452fb02e6221?dpr=2&auto=format&fit=crop&w=767&h=512&q=80&cs=tinysrgb&crop=")
- .build();
-
- Profile profile2 = new Profile.Builder()
- .setId(4)
- .setUsername("Federico Gentile")
- .setEmail("fgentile95dev@icloud.com")
- .setAvatar("https://github.com/FedeGens.png?size=512")
- .setBackground("https://images.unsplash.com/photo-1469173479606-ada03df615ac?dpr=2&auto=format&fit=crop&w=767&h=511&q=80&cs=tinysrgb&crop=")
- .build();
-
- Profile profile3 = new Profile.Builder()
- .setId(6)
- .setUsername("Luca Rurio")
- .setEmail("rurio.luca@gmail.com")
- .setAvatar("https://github.com/RurioLuca.png?size=512")
- .setBackground("https://images.unsplash.com/photo-1473789810014-375ed569d0ed?dpr=2&auto=format&fit=crop&w=767&h=511&q=80&cs=tinysrgb&crop=")
- .build();
-
- Profile profile4 = new Profile.Builder()
- .setId(8)
- .setUsername("Krzysztof Klimkiewicz")
- .setEmail("krzkz94@gmail.com")
- .setAvatar("https://github.com/krzykz.png?size=512")
- .setBackground("https://images.unsplash.com/photo-1452509133926-2b180c6d6245?dpr=2&auto=format&fit=crop&w=767&h=431&q=80&cs=tinysrgb&crop=")
- .build();
-
- Item item = new Item.Builder()
- .setId(1)
- .setTitle("Remove all profile")
- .build();
-
- Item item2 = new Item.Builder()
- .setId(2)
- .setTitle("Remove active profile")
- .build();
-
-
- headerView.setStyle(HeaderView.STYLE_COMPACT);
- headerView.setTheme(HeaderView.THEME_LIGHT);
- headerView.setShowGradient(true);
- headerView.setHighlightColor(ContextCompat.getColor(this, R.color.colorAccent));
- headerView.addProfile(profile, profile2, profile3, profile4);
- headerView.addDialogItem(item, item2);
- headerView.setShowAddButton(true);
- //headerView.setAddIconDrawable(R.drawable.ic_action_settings);
- headerView.setDialogTitle("Choose account");
- headerView.setShowArrow(true);
- headerView.setOnHeaderClickListener(v -> drawerLayout.closeDrawer(GravityCompat.START, true));
- headerView.setFragmentManager(getFragmentManager());
- headerView.setCallback(new HeaderCallback() {
-
- @Override
- public boolean onSelect(int id, boolean isActive) {
- Log.d(TAG, "profile selected [" + id + "] isActive [" + isActive + "]");
- Toast.makeText(MainActivity.this, "profile selected [" + id + "] isActive [" + isActive + "]", Toast.LENGTH_SHORT).show();
- drawerLayout.closeDrawer(GravityCompat.START, true);
- return true;
- }
- @Override
- public boolean onItem(int id) {
- switch (id) {
- case 1:
- headerView.clearProfile();
- break;
- case 2:
- int profileId = headerView.getProfileActive();
- headerView.removeProfile(profileId);
- break;
- }
- return true;
- }
-
- @Override
- public boolean onAdd() {
- Profile newProfile = new Profile.Builder()
- .setId(100)
- .setUsername("Mattia Novelli")
- .setEmail("nove.mattia@gmail.com")
- .setAvatar("https://github.com/mattinove.png?size=512")
- .setBackground("https://images.unsplash.com/photo-1478194409487-fa5c1eb18622?dpr=2&auto=format&fit=crop&w=767&h=496&q=80&cs=tinysrgb&crop=")
- .build();
- headerView.addProfile(newProfile);
- headerView.setProfileActive(100);
- headerView.dismissProfileChooser();
- return false;
- }
-
- });
-
- //headerView.addProfile(profile, profile2, profile3);
-
- }
-
- @Override
- public void onBackPressed() {
- if (drawerLayout != null && drawerLayout.isDrawerOpen(GravityCompat.START)) {
- drawerLayout.closeDrawer(GravityCompat.START);
- return;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ Window window = getWindow();
+ window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
+ window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+ window.setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
}
- super.onBackPressed();
- }
-/*
- @Override
- protected void attachBaseContext(Context newBase) {
- super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
+ findViewById(R.id.normal_drawer).setOnClickListener(v -> startActivity(new Intent(MainActivity.this, NormalHeaderActivity.class)));
+ findViewById(R.id.compact_drawer).setOnClickListener(v -> startActivity(new Intent(MainActivity.this, CompactHeaderActivity.class)));
}
-*/
+
@SuppressWarnings("deprecation")
private Spanned fromHtml(String value) {
@@ -219,4 +71,5 @@ public boolean onMenuItemClick(MenuItem item) {
return false;
}
}
+
}
diff --git a/sample/src/main/java/rebus/header/view/sample/NormalHeaderActivity.java b/sample/src/main/java/rebus/header/view/sample/NormalHeaderActivity.java
new file mode 100644
index 0000000..f0f7e50
--- /dev/null
+++ b/sample/src/main/java/rebus/header/view/sample/NormalHeaderActivity.java
@@ -0,0 +1,183 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Raphaël Bussa
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package rebus.header.view.sample;
+
+import android.os.Bundle;
+import android.util.Log;
+import android.widget.Toast;
+
+import com.google.android.material.navigation.NavigationView;
+
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+import androidx.core.content.ContextCompat;
+import androidx.core.view.GravityCompat;
+import androidx.drawerlayout.widget.DrawerLayout;
+import rebus.header.view.HeaderCallback;
+import rebus.header.view.HeaderView;
+import rebus.header.view.Item;
+import rebus.header.view.Profile;
+//import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
+
+public class NormalHeaderActivity extends AppCompatActivity {
+
+ private static final String TAG = NormalHeaderActivity.class.getName();
+
+ private HeaderView headerView;
+ private DrawerLayout drawerLayout;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_normal_header);
+ Toolbar toolbar = findViewById(R.id.toolbar);
+ toolbar.setTitle(getString(R.string.app_name));
+ toolbar.inflateMenu(R.menu.menu_main);
+ toolbar.setNavigationOnClickListener(view -> {
+ if (drawerLayout != null && !drawerLayout.isDrawerOpen(GravityCompat.START)) {
+ drawerLayout.openDrawer(GravityCompat.START);
+ }
+ });
+ drawerLayout = findViewById(R.id.drawer_layout);
+ NavigationView navigationView = findViewById(R.id.nav_view);
+ headerView = navigationView.getHeaderView(0).findViewById(R.id.header_view);
+
+ Profile profile = new Profile.Builder()
+ .setId(2)
+ .setUsername("Raphaël Bussa")
+ .setEmail("raphaelbussa@gmail.com")
+ .setAvatar("https://github.com/rebus007.png?size=512")
+ .setBackground("https://images.unsplash.com/photo-1473220464492-452fb02e6221?dpr=2&auto=format&fit=crop&w=767&h=512&q=80&cs=tinysrgb&crop=")
+ .build();
+
+ Profile profile2 = new Profile.Builder()
+ .setId(4)
+ .setUsername("Federico Gentile")
+ .setEmail("fgentile95dev@icloud.com")
+ .setAvatar("https://github.com/FedeGens.png?size=512")
+ .setBackground("https://images.unsplash.com/photo-1469173479606-ada03df615ac?dpr=2&auto=format&fit=crop&w=767&h=511&q=80&cs=tinysrgb&crop=")
+ .build();
+
+ Profile profile3 = new Profile.Builder()
+ .setId(6)
+ .setUsername("Luca Rurio")
+ .setEmail("rurio.luca@gmail.com")
+ .setAvatar("https://github.com/RurioLuca.png?size=512")
+ .setBackground("https://images.unsplash.com/photo-1473789810014-375ed569d0ed?dpr=2&auto=format&fit=crop&w=767&h=511&q=80&cs=tinysrgb&crop=")
+ .build();
+
+ Profile profile4 = new Profile.Builder()
+ .setId(8)
+ .setUsername("Krzysztof Klimkiewicz")
+ .setEmail("krzkz94@gmail.com")
+ .setAvatar("https://github.com/krzykz.png?size=512")
+ .setBackground("https://images.unsplash.com/photo-1452509133926-2b180c6d6245?dpr=2&auto=format&fit=crop&w=767&h=431&q=80&cs=tinysrgb&crop=")
+ .build();
+
+ Item item = new Item.Builder()
+ .setId(1)
+ .setTitle("Remove all profile")
+ .build();
+
+ Item item2 = new Item.Builder()
+ .setId(2)
+ .setTitle("Remove active profile")
+ .build();
+
+
+ headerView.setStyle(HeaderView.STYLE_NORMAL);
+ headerView.setTheme(HeaderView.THEME_LIGHT);
+ headerView.setShowGradient(true);
+ headerView.setHighlightColor(ContextCompat.getColor(this, R.color.colorAccent));
+ headerView.addProfile(profile, profile2, profile3, profile4);
+ headerView.addDialogItem(item, item2);
+ headerView.setShowAddButton(true);
+ //headerView.setAddIconDrawable(R.drawable.ic_action_settings);
+ headerView.setDialogTitle("Choose account");
+ headerView.setShowArrow(true);
+ headerView.setOnHeaderClickListener(v -> drawerLayout.closeDrawer(GravityCompat.START, true));
+ headerView.setFragmentManager(getSupportFragmentManager());
+ headerView.setCallback(new HeaderCallback() {
+
+ @Override
+ public boolean onSelect(int id, boolean isActive) {
+ Log.d(TAG, "profile selected [" + id + "] isActive [" + isActive + "]");
+ Toast.makeText(NormalHeaderActivity.this, "profile selected [" + id + "] isActive [" + isActive + "]", Toast.LENGTH_SHORT).show();
+ drawerLayout.closeDrawer(GravityCompat.START, true);
+ return true;
+ }
+
+ @Override
+ public boolean onItem(int id) {
+ switch (id) {
+ case 1:
+ headerView.clearProfile();
+ break;
+ case 2:
+ int profileId = headerView.getProfileActive();
+ headerView.removeProfile(profileId);
+ break;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean onAdd() {
+ Profile newProfile = new Profile.Builder()
+ .setId(100)
+ .setUsername("Mattia Novelli")
+ .setEmail("nove.mattia@gmail.com")
+ .setAvatar("https://github.com/mattinove.png?size=512")
+ .setBackground("https://images.unsplash.com/photo-1478194409487-fa5c1eb18622?dpr=2&auto=format&fit=crop&w=767&h=496&q=80&cs=tinysrgb&crop=")
+ .build();
+ headerView.addProfile(newProfile);
+ headerView.setProfileActive(100);
+ headerView.dismissProfileChooser();
+ return false;
+ }
+
+ });
+
+ //headerView.addProfile(profile, profile2, profile3);
+
+ }
+
+ @Override
+ public void onBackPressed() {
+ if (drawerLayout != null && drawerLayout.isDrawerOpen(GravityCompat.START)) {
+ drawerLayout.closeDrawer(GravityCompat.START);
+ return;
+ }
+ super.onBackPressed();
+ }
+
+/*
+ @Override
+ protected void attachBaseContext(Context newBase) {
+ super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
+ }
+*/
+
+}
diff --git a/sample/src/main/res/layout/activity_compact_header.xml b/sample/src/main/res/layout/activity_compact_header.xml
new file mode 100644
index 0000000..f549983
--- /dev/null
+++ b/sample/src/main/res/layout/activity_compact_header.xml
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml
index a89a4b4..202eca7 100644
--- a/sample/src/main/res/layout/activity_main.xml
+++ b/sample/src/main/res/layout/activity_main.xml
@@ -1,69 +1,36 @@
-
-
-
+
+ android:layout_height="match_parent">
-
+ android:layout_height="wrap_content"
+ android:background="@color/colorPrimary"
+ android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
-
+
+
+ android:text="@string/normal_drawer" />
-
-
-
-
-
-
-
+ android:layout_height="wrap_content"
+ android:text="@string/compact_drawer" />
-
+
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/sample/src/main/res/layout/activity_normal_header.xml b/sample/src/main/res/layout/activity_normal_header.xml
new file mode 100644
index 0000000..1c63422
--- /dev/null
+++ b/sample/src/main/res/layout/activity_normal_header.xml
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sample/src/main/res/layout/header_drawer.xml b/sample/src/main/res/layout/compact_header_drawer.xml
similarity index 100%
rename from sample/src/main/res/layout/header_drawer.xml
rename to sample/src/main/res/layout/compact_header_drawer.xml
diff --git a/sample/src/main/res/layout/normal_header_drawer.xml b/sample/src/main/res/layout/normal_header_drawer.xml
new file mode 100644
index 0000000..951b0d4
--- /dev/null
+++ b/sample/src/main/res/layout/normal_header_drawer.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml
index 4f4730d..8530910 100644
--- a/sample/src/main/res/values/strings.xml
+++ b/sample/src/main/res/values/strings.xml
@@ -13,4 +13,7 @@
Close
Open Drawer
+ Compact drawer
+ Normal drawer
+