Skip to content

Commit 759e2b9

Browse files
committed
version 3.0.0
- update libs
1 parent a345a06 commit 759e2b9

File tree

14 files changed

+604
-228
lines changed

14 files changed

+604
-228
lines changed

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ buildscript {
3030
minSdk : 14,
3131
targetSdk : 28,
3232
version : "3.0.0",
33-
supportLib: "1.0.0-rc01"
33+
supportLib: "1.0.0-rc02"
3434
]
3535
}
3636

@@ -41,8 +41,8 @@ buildscript {
4141
}
4242

4343
dependencies {
44-
classpath 'com.android.tools.build:gradle:3.3.0-alpha06'
45-
classpath 'com.novoda:bintray-release:0.8.1'
44+
classpath 'com.android.tools.build:gradle:3.3.0-alpha11'
45+
classpath 'guru.stefma.bintrayrelease:bintrayrelease:1.0.0'
4646
}
4747
}
4848

library/build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424

2525
apply plugin: 'com.android.library'
26-
apply plugin: 'com.novoda.bintray-release'
26+
apply plugin: "guru.stefma.bintrayrelease"
2727

2828
android {
2929

@@ -59,12 +59,14 @@ android {
5959

6060
dependencies {
6161
implementation "androidx.annotation:annotation:${var.supportLib}"
62+
implementation "androidx.fragment:fragment:${var.supportLib}"
6263
}
6364

65+
version = '3.0.0'
66+
group = 'rebus'
6467
publish {
6568
userOrg = 'raphaelbussa'
66-
groupId = 'rebus'
6769
artifactId = 'header-view'
68-
publishVersion = "${var.version}"
6970
desc = 'Create an header for android.support.design.widget.NavigationView'
71+
website = 'https://rebus007.github.io/HeaderView/'
7072
}

library/src/main/java/rebus/header/view/HeaderView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
package rebus.header.view;
2626

2727
import android.annotation.SuppressLint;
28-
import android.app.FragmentManager;
2928
import android.content.Context;
3029
import android.content.res.TypedArray;
3130
import android.graphics.Color;
@@ -54,6 +53,7 @@
5453
import androidx.annotation.IntDef;
5554
import androidx.annotation.IntRange;
5655
import androidx.annotation.RestrictTo;
56+
import androidx.fragment.app.FragmentManager;
5757
import de.hdodenhof.circleimageview.CircleImageView;
5858

5959
import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP;

library/src/main/java/rebus/header/view/ProfileChooserFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
package rebus.header.view;
2626

2727
import android.annotation.SuppressLint;
28-
import android.app.DialogFragment;
2928
import android.graphics.Typeface;
3029
import android.os.Bundle;
3130
import android.util.SparseArray;
@@ -41,6 +40,7 @@
4140
import java.util.List;
4241

4342
import androidx.annotation.Nullable;
43+
import androidx.fragment.app.DialogFragment;
4444

4545
/**
4646
* Created by raphaelbussa on 21/01/17.

sample/src/main/AndroidManifest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
<category android:name="android.intent.category.LAUNCHER" />
4444
</intent-filter>
4545
</activity>
46+
<activity android:name=".CompactHeaderActivity" />
47+
<activity android:name=".NormalHeaderActivity" />
4648
</application>
4749

4850
</manifest>
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2017 Raphaël Bussa
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
package rebus.header.view.sample;
26+
27+
import android.os.Bundle;
28+
import android.util.Log;
29+
import android.widget.Toast;
30+
31+
import com.google.android.material.navigation.NavigationView;
32+
33+
import androidx.appcompat.app.AppCompatActivity;
34+
import androidx.appcompat.widget.Toolbar;
35+
import androidx.core.content.ContextCompat;
36+
import androidx.core.view.GravityCompat;
37+
import androidx.drawerlayout.widget.DrawerLayout;
38+
import rebus.header.view.HeaderCallback;
39+
import rebus.header.view.HeaderView;
40+
import rebus.header.view.Item;
41+
import rebus.header.view.Profile;
42+
//import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
43+
44+
public class CompactHeaderActivity extends AppCompatActivity {
45+
46+
private static final String TAG = CompactHeaderActivity.class.getName();
47+
48+
private HeaderView headerView;
49+
private DrawerLayout drawerLayout;
50+
51+
@Override
52+
protected void onCreate(Bundle savedInstanceState) {
53+
super.onCreate(savedInstanceState);
54+
setContentView(R.layout.activity_compact_header);
55+
Toolbar toolbar = findViewById(R.id.toolbar);
56+
toolbar.setTitle(getString(R.string.app_name));
57+
toolbar.setNavigationOnClickListener(view -> {
58+
if (drawerLayout != null && !drawerLayout.isDrawerOpen(GravityCompat.START)) {
59+
drawerLayout.openDrawer(GravityCompat.START);
60+
}
61+
});
62+
drawerLayout = findViewById(R.id.drawer_layout);
63+
NavigationView navigationView = findViewById(R.id.nav_view);
64+
headerView = navigationView.getHeaderView(0).findViewById(R.id.header_view);
65+
66+
Profile profile = new Profile.Builder()
67+
.setId(2)
68+
.setUsername("Raphaël Bussa")
69+
.setEmail("raphaelbussa@gmail.com")
70+
.setAvatar("https://github.com/rebus007.png?size=512")
71+
.setBackground("https://images.unsplash.com/photo-1473220464492-452fb02e6221?dpr=2&auto=format&fit=crop&w=767&h=512&q=80&cs=tinysrgb&crop=")
72+
.build();
73+
74+
Profile profile2 = new Profile.Builder()
75+
.setId(4)
76+
.setUsername("Federico Gentile")
77+
.setEmail("fgentile95dev@icloud.com")
78+
.setAvatar("https://github.com/FedeGens.png?size=512")
79+
.setBackground("https://images.unsplash.com/photo-1469173479606-ada03df615ac?dpr=2&auto=format&fit=crop&w=767&h=511&q=80&cs=tinysrgb&crop=")
80+
.build();
81+
82+
Profile profile3 = new Profile.Builder()
83+
.setId(6)
84+
.setUsername("Luca Rurio")
85+
.setEmail("rurio.luca@gmail.com")
86+
.setAvatar("https://github.com/RurioLuca.png?size=512")
87+
.setBackground("https://images.unsplash.com/photo-1473789810014-375ed569d0ed?dpr=2&auto=format&fit=crop&w=767&h=511&q=80&cs=tinysrgb&crop=")
88+
.build();
89+
90+
Profile profile4 = new Profile.Builder()
91+
.setId(8)
92+
.setUsername("Krzysztof Klimkiewicz")
93+
.setEmail("krzkz94@gmail.com")
94+
.setAvatar("https://github.com/krzykz.png?size=512")
95+
.setBackground("https://images.unsplash.com/photo-1452509133926-2b180c6d6245?dpr=2&auto=format&fit=crop&w=767&h=431&q=80&cs=tinysrgb&crop=")
96+
.build();
97+
98+
Item item = new Item.Builder()
99+
.setId(1)
100+
.setTitle("Remove all profile")
101+
.build();
102+
103+
Item item2 = new Item.Builder()
104+
.setId(2)
105+
.setTitle("Remove active profile")
106+
.build();
107+
108+
109+
headerView.setStyle(HeaderView.STYLE_COMPACT);
110+
headerView.setTheme(HeaderView.THEME_LIGHT);
111+
headerView.setShowGradient(true);
112+
headerView.setHighlightColor(ContextCompat.getColor(this, R.color.colorAccent));
113+
headerView.addProfile(profile, profile2, profile3, profile4);
114+
headerView.addDialogItem(item, item2);
115+
headerView.setShowAddButton(true);
116+
//headerView.setAddIconDrawable(R.drawable.ic_action_settings);
117+
headerView.setDialogTitle("Choose account");
118+
headerView.setShowArrow(true);
119+
headerView.setOnHeaderClickListener(v -> drawerLayout.closeDrawer(GravityCompat.START, true));
120+
headerView.setFragmentManager(getSupportFragmentManager());
121+
headerView.setCallback(new HeaderCallback() {
122+
123+
@Override
124+
public boolean onSelect(int id, boolean isActive) {
125+
Log.d(TAG, "profile selected [" + id + "] isActive [" + isActive + "]");
126+
Toast.makeText(CompactHeaderActivity.this, "profile selected [" + id + "] isActive [" + isActive + "]", Toast.LENGTH_SHORT).show();
127+
drawerLayout.closeDrawer(GravityCompat.START, true);
128+
return true;
129+
}
130+
131+
@Override
132+
public boolean onItem(int id) {
133+
switch (id) {
134+
case 1:
135+
headerView.clearProfile();
136+
break;
137+
case 2:
138+
int profileId = headerView.getProfileActive();
139+
headerView.removeProfile(profileId);
140+
break;
141+
}
142+
return true;
143+
}
144+
145+
@Override
146+
public boolean onAdd() {
147+
Profile newProfile = new Profile.Builder()
148+
.setId(100)
149+
.setUsername("Mattia Novelli")
150+
.setEmail("nove.mattia@gmail.com")
151+
.setAvatar("https://github.com/mattinove.png?size=512")
152+
.setBackground("https://images.unsplash.com/photo-1478194409487-fa5c1eb18622?dpr=2&auto=format&fit=crop&w=767&h=496&q=80&cs=tinysrgb&crop=")
153+
.build();
154+
headerView.addProfile(newProfile);
155+
headerView.setProfileActive(100);
156+
headerView.dismissProfileChooser();
157+
return false;
158+
}
159+
160+
});
161+
162+
//headerView.addProfile(profile, profile2, profile3);
163+
164+
}
165+
166+
@Override
167+
public void onBackPressed() {
168+
if (drawerLayout != null && drawerLayout.isDrawerOpen(GravityCompat.START)) {
169+
drawerLayout.closeDrawer(GravityCompat.START);
170+
return;
171+
}
172+
super.onBackPressed();
173+
}
174+
175+
/*
176+
@Override
177+
protected void attachBaseContext(Context newBase) {
178+
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
179+
}
180+
*/
181+
182+
}

0 commit comments

Comments
 (0)