Skip to content

Commit

Permalink
version 3.0.0
Browse files Browse the repository at this point in the history
- update libs
  • Loading branch information
raphaelbussa committed Sep 21, 2018
1 parent a345a06 commit 759e2b9
Show file tree
Hide file tree
Showing 14 changed files with 604 additions and 228 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ buildscript {
minSdk : 14,
targetSdk : 28,
version : "3.0.0",
supportLib: "1.0.0-rc01"
supportLib: "1.0.0-rc02"
]
}

Expand All @@ -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'
}
}

Expand Down
8 changes: 5 additions & 3 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

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

android {

Expand Down Expand Up @@ -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/'
}
2 changes: 1 addition & 1 deletion library/src/main/java/rebus/header/view/HeaderView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -41,6 +40,7 @@
import java.util.List;

import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;

/**
* Created by raphaelbussa on 21/01/17.
Expand Down
2 changes: 2 additions & 0 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".CompactHeaderActivity" />
<activity android:name=".NormalHeaderActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -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("[email protected]")
.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("[email protected]")
.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("[email protected]")
.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("[email protected]")
.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("[email protected]")
.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));
}
*/

}
Loading

0 comments on commit 759e2b9

Please sign in to comment.