Skip to content

Commit

Permalink
version 1.1.6
Browse files Browse the repository at this point in the history
- added dark theme
  • Loading branch information
raphaelbussa committed Jul 10, 2016
1 parent 903bb6f commit 195f1c8
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ public void run() {

private HeaderView headerView() {
HeaderView headerView = new HeaderView(HeaderActivity.this, false);
headerView.background().setBackgroundColor(getResources().getColor(R.color.primary_dark));
Picasso.with(HeaderActivity.this)
headerView.background().setBackgroundColor(getResources().getColor(R.color.accent));
headerView.theme(true);
/*Picasso.with(HeaderActivity.this)
.load(getString(R.string.url_img_header))
.into(headerView.background());
.into(headerView.background());*/
Picasso.with(HeaderActivity.this)
.load(getString(R.string.url_img_profile))
.into(headerView.avatar());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ public void run() {

private HeaderCompactView headerView() {
HeaderCompactView headerView = new HeaderCompactView(HeaderCompactActivity.this, false);
headerView.background().setBackgroundColor(getResources().getColor(R.color.primary_dark));
Picasso.with(HeaderCompactActivity.this)
.load(getString(R.string.url_img_header))
.into(headerView.background());
headerView.theme(true);
headerView.background().setBackgroundColor(getResources().getColor(R.color.accent));
// Picasso.with(HeaderCompactActivity.this)
// .load(getString(R.string.url_img_header))
// .into(headerView.background());
Picasso.with(HeaderCompactActivity.this)
.load(getString(R.string.url_img_profile))
.into(headerView.avatar());
Expand Down
8 changes: 4 additions & 4 deletions headerview/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.library'
apply plugin: 'bintray-release'
android {
compileSdkVersion 23
compileSdkVersion 24
buildToolsVersion '23.0.3'

defaultConfig {
minSdkVersion 8
targetSdkVersion 23
targetSdkVersion 24
versionCode 7
versionName "1.1.5"
versionName "1.1.6"
}
buildTypes {
release {
Expand All @@ -21,7 +21,7 @@ android {
userOrg = 'raphaelbussa'
groupId = 'rebus'
artifactId = 'header-view'
publishVersion = '1.1.5'
publishVersion = '1.1.6'
}

}
Expand Down
22 changes: 18 additions & 4 deletions headerview/src/main/java/rebus/header/view/HeaderCompactView.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Build;
import android.text.Spannable;
Expand Down Expand Up @@ -54,6 +53,9 @@ public class HeaderCompactView extends RelativeLayout {
private View headerGradient;
private ImageView arrowImage;

private int arrow = R.drawable.ic_arrow;
private int color = R.color.text_color;

public HeaderCompactView(Context context, boolean belowToolbar) {
super(context);
this.belowToolbar = belowToolbar;
Expand All @@ -64,6 +66,18 @@ public HeaderCompactView(Context context, boolean belowToolbar) {
addView(headerUserContainer());
}

public void theme(boolean dark) {
if (dark) {
arrow = R.drawable.ic_arrow_dark;
color = R.color.text_color_dark;
} else {
arrow = R.drawable.ic_arrow;
color = R.color.text_color;
}
userEmail.setTextColor(getContext().getResources().getColor(color));
userName.setTextColor(getContext().getResources().getColor(color));
}

public void setOnHeaderClickListener(HeaderInterface.OnHeaderClickListener onHeaderClickListener) {
this.onHeaderClickListener = onHeaderClickListener;
}
Expand Down Expand Up @@ -126,7 +140,7 @@ public void setArrow(final HeaderInterface.OnArrowClickListener onArrowClickList
}
LayoutParams arrowParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
arrowImage = new ImageView(getContext());
arrowImage.setImageDrawable(getResources().getDrawable(R.drawable.ic_arrow));
arrowImage.setImageDrawable(getResources().getDrawable(arrow));
arrowImage.setLayoutParams(arrowParams);
arrowImage.setPadding(marginSize, marginTop, marginSize, marginSize);
arrowImage.setOnClickListener(new OnClickListener() {
Expand All @@ -152,14 +166,14 @@ private LinearLayout headerUserInfo() {
linearLayout.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, textSize);
userName = new TextView(getContext());
userName.setTextColor(Color.WHITE);
userName.setTextColor(getContext().getResources().getColor(color));
userName.setTypeface(Typeface.DEFAULT_BOLD);
userName.setGravity(Gravity.CENTER_VERTICAL);
userName.setSingleLine();
userName.setEllipsize(TextUtils.TruncateAt.END);
userName.setLayoutParams(textParams);
userEmail = new TextView(getContext());
userEmail.setTextColor(Color.WHITE);
userEmail.setTextColor(getContext().getResources().getColor(color));
userEmail.setGravity(Gravity.CENTER_VERTICAL);
userEmail.setSingleLine();
userEmail.setEllipsize(TextUtils.TruncateAt.END);
Expand Down
22 changes: 18 additions & 4 deletions headerview/src/main/java/rebus/header/view/HeaderView.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Build;
import android.text.Spannable;
Expand Down Expand Up @@ -54,6 +53,9 @@ public class HeaderView extends RelativeLayout {
private View headerGradient;
private ImageView arrowImage;

private int arrow = R.drawable.ic_arrow;
private int color = R.color.text_color;

public HeaderView(Context context, boolean belowToolbar) {
super(context);
this.belowToolbar = belowToolbar;
Expand All @@ -64,6 +66,18 @@ public HeaderView(Context context, boolean belowToolbar) {
addView(headerUserContainer());
}

public void theme(boolean dark) {
if (dark) {
arrow = R.drawable.ic_arrow_dark;
color = R.color.text_color_dark;
} else {
arrow = R.drawable.ic_arrow;
color = R.color.text_color;
}
userEmail.setTextColor(getContext().getResources().getColor(color));
userName.setTextColor(getContext().getResources().getColor(color));
}

public void setOnHeaderClickListener(HeaderInterface.OnHeaderClickListener onHeaderClickListener) {
this.onHeaderClickListener = onHeaderClickListener;
}
Expand All @@ -80,7 +94,7 @@ public void setArrow(final HeaderInterface.OnArrowClickListener onArrowClickList
int marginSize = getResources().getDimensionPixelSize(R.dimen.margin);
LayoutParams arrowParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
arrowImage = new ImageView(getContext());
arrowImage.setImageDrawable(getResources().getDrawable(R.drawable.ic_arrow));
arrowImage.setImageDrawable(getResources().getDrawable(arrow));
arrowImage.setLayoutParams(arrowParams);
arrowImage.setPadding(marginSize, marginSize, marginSize, marginSize);
arrowImage.setOnClickListener(new OnClickListener() {
Expand Down Expand Up @@ -147,14 +161,14 @@ private LinearLayout headerUserContainer() {
linearLayout.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, textSize);
userName = new TextView(getContext());
userName.setTextColor(Color.WHITE);
userName.setTextColor(getContext().getResources().getColor(color));
userName.setTypeface(Typeface.DEFAULT_BOLD);
userName.setGravity(Gravity.CENTER_VERTICAL);
userName.setSingleLine();
userName.setEllipsize(TextUtils.TruncateAt.END);
userName.setLayoutParams(textParams);
userEmail = new TextView(getContext());
userEmail.setTextColor(Color.WHITE);
userEmail.setTextColor(getContext().getResources().getColor(color));
userEmail.setGravity(Gravity.CENTER_VERTICAL);
userEmail.setSingleLine();
userEmail.setEllipsize(TextUtils.TruncateAt.END);
Expand Down
Binary file removed headerview/src/main/res/drawable-hdpi/Thumbs.db
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed headerview/src/main/res/drawable-mdpi/Thumbs.db
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions headerview/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<color name="text_color_dark">#212121</color>
<color name="text_color">#FFFFFF</color>

</resources>

0 comments on commit 195f1c8

Please sign in to comment.