Skip to content

Commit 195f1c8

Browse files
committed
version 1.1.6
- added dark theme
1 parent 903bb6f commit 195f1c8

14 files changed

Lines changed: 56 additions & 19 deletions

File tree

app/src/main/java/rebus/header/view/sample/HeaderActivity.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@ public void run() {
6767

6868
private HeaderView headerView() {
6969
HeaderView headerView = new HeaderView(HeaderActivity.this, false);
70-
headerView.background().setBackgroundColor(getResources().getColor(R.color.primary_dark));
71-
Picasso.with(HeaderActivity.this)
70+
headerView.background().setBackgroundColor(getResources().getColor(R.color.accent));
71+
headerView.theme(true);
72+
/*Picasso.with(HeaderActivity.this)
7273
.load(getString(R.string.url_img_header))
73-
.into(headerView.background());
74+
.into(headerView.background());*/
7475
Picasso.with(HeaderActivity.this)
7576
.load(getString(R.string.url_img_profile))
7677
.into(headerView.avatar());

app/src/main/java/rebus/header/view/sample/HeaderCompactActivity.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ public void run() {
6868

6969
private HeaderCompactView headerView() {
7070
HeaderCompactView headerView = new HeaderCompactView(HeaderCompactActivity.this, false);
71-
headerView.background().setBackgroundColor(getResources().getColor(R.color.primary_dark));
72-
Picasso.with(HeaderCompactActivity.this)
73-
.load(getString(R.string.url_img_header))
74-
.into(headerView.background());
71+
headerView.theme(true);
72+
headerView.background().setBackgroundColor(getResources().getColor(R.color.accent));
73+
// Picasso.with(HeaderCompactActivity.this)
74+
// .load(getString(R.string.url_img_header))
75+
// .into(headerView.background());
7576
Picasso.with(HeaderCompactActivity.this)
7677
.load(getString(R.string.url_img_profile))
7778
.into(headerView.avatar());

headerview/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
apply plugin: 'com.android.library'
22
apply plugin: 'bintray-release'
33
android {
4-
compileSdkVersion 23
4+
compileSdkVersion 24
55
buildToolsVersion '23.0.3'
66

77
defaultConfig {
88
minSdkVersion 8
9-
targetSdkVersion 23
9+
targetSdkVersion 24
1010
versionCode 7
11-
versionName "1.1.5"
11+
versionName "1.1.6"
1212
}
1313
buildTypes {
1414
release {
@@ -21,7 +21,7 @@ android {
2121
userOrg = 'raphaelbussa'
2222
groupId = 'rebus'
2323
artifactId = 'header-view'
24-
publishVersion = '1.1.5'
24+
publishVersion = '1.1.6'
2525
}
2626

2727
}

headerview/src/main/java/rebus/header/view/HeaderCompactView.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import android.annotation.SuppressLint;
2828
import android.content.Context;
29-
import android.graphics.Color;
3029
import android.graphics.Typeface;
3130
import android.os.Build;
3231
import android.text.Spannable;
@@ -54,6 +53,9 @@ public class HeaderCompactView extends RelativeLayout {
5453
private View headerGradient;
5554
private ImageView arrowImage;
5655

56+
private int arrow = R.drawable.ic_arrow;
57+
private int color = R.color.text_color;
58+
5759
public HeaderCompactView(Context context, boolean belowToolbar) {
5860
super(context);
5961
this.belowToolbar = belowToolbar;
@@ -64,6 +66,18 @@ public HeaderCompactView(Context context, boolean belowToolbar) {
6466
addView(headerUserContainer());
6567
}
6668

69+
public void theme(boolean dark) {
70+
if (dark) {
71+
arrow = R.drawable.ic_arrow_dark;
72+
color = R.color.text_color_dark;
73+
} else {
74+
arrow = R.drawable.ic_arrow;
75+
color = R.color.text_color;
76+
}
77+
userEmail.setTextColor(getContext().getResources().getColor(color));
78+
userName.setTextColor(getContext().getResources().getColor(color));
79+
}
80+
6781
public void setOnHeaderClickListener(HeaderInterface.OnHeaderClickListener onHeaderClickListener) {
6882
this.onHeaderClickListener = onHeaderClickListener;
6983
}
@@ -126,7 +140,7 @@ public void setArrow(final HeaderInterface.OnArrowClickListener onArrowClickList
126140
}
127141
LayoutParams arrowParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
128142
arrowImage = new ImageView(getContext());
129-
arrowImage.setImageDrawable(getResources().getDrawable(R.drawable.ic_arrow));
143+
arrowImage.setImageDrawable(getResources().getDrawable(arrow));
130144
arrowImage.setLayoutParams(arrowParams);
131145
arrowImage.setPadding(marginSize, marginTop, marginSize, marginSize);
132146
arrowImage.setOnClickListener(new OnClickListener() {
@@ -152,14 +166,14 @@ private LinearLayout headerUserInfo() {
152166
linearLayout.setOrientation(LinearLayout.VERTICAL);
153167
LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, textSize);
154168
userName = new TextView(getContext());
155-
userName.setTextColor(Color.WHITE);
169+
userName.setTextColor(getContext().getResources().getColor(color));
156170
userName.setTypeface(Typeface.DEFAULT_BOLD);
157171
userName.setGravity(Gravity.CENTER_VERTICAL);
158172
userName.setSingleLine();
159173
userName.setEllipsize(TextUtils.TruncateAt.END);
160174
userName.setLayoutParams(textParams);
161175
userEmail = new TextView(getContext());
162-
userEmail.setTextColor(Color.WHITE);
176+
userEmail.setTextColor(getContext().getResources().getColor(color));
163177
userEmail.setGravity(Gravity.CENTER_VERTICAL);
164178
userEmail.setSingleLine();
165179
userEmail.setEllipsize(TextUtils.TruncateAt.END);

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import android.annotation.SuppressLint;
2828
import android.content.Context;
29-
import android.graphics.Color;
3029
import android.graphics.Typeface;
3130
import android.os.Build;
3231
import android.text.Spannable;
@@ -54,6 +53,9 @@ public class HeaderView extends RelativeLayout {
5453
private View headerGradient;
5554
private ImageView arrowImage;
5655

56+
private int arrow = R.drawable.ic_arrow;
57+
private int color = R.color.text_color;
58+
5759
public HeaderView(Context context, boolean belowToolbar) {
5860
super(context);
5961
this.belowToolbar = belowToolbar;
@@ -64,6 +66,18 @@ public HeaderView(Context context, boolean belowToolbar) {
6466
addView(headerUserContainer());
6567
}
6668

69+
public void theme(boolean dark) {
70+
if (dark) {
71+
arrow = R.drawable.ic_arrow_dark;
72+
color = R.color.text_color_dark;
73+
} else {
74+
arrow = R.drawable.ic_arrow;
75+
color = R.color.text_color;
76+
}
77+
userEmail.setTextColor(getContext().getResources().getColor(color));
78+
userName.setTextColor(getContext().getResources().getColor(color));
79+
}
80+
6781
public void setOnHeaderClickListener(HeaderInterface.OnHeaderClickListener onHeaderClickListener) {
6882
this.onHeaderClickListener = onHeaderClickListener;
6983
}
@@ -80,7 +94,7 @@ public void setArrow(final HeaderInterface.OnArrowClickListener onArrowClickList
8094
int marginSize = getResources().getDimensionPixelSize(R.dimen.margin);
8195
LayoutParams arrowParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
8296
arrowImage = new ImageView(getContext());
83-
arrowImage.setImageDrawable(getResources().getDrawable(R.drawable.ic_arrow));
97+
arrowImage.setImageDrawable(getResources().getDrawable(arrow));
8498
arrowImage.setLayoutParams(arrowParams);
8599
arrowImage.setPadding(marginSize, marginSize, marginSize, marginSize);
86100
arrowImage.setOnClickListener(new OnClickListener() {
@@ -147,14 +161,14 @@ private LinearLayout headerUserContainer() {
147161
linearLayout.setOrientation(LinearLayout.VERTICAL);
148162
LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, textSize);
149163
userName = new TextView(getContext());
150-
userName.setTextColor(Color.WHITE);
164+
userName.setTextColor(getContext().getResources().getColor(color));
151165
userName.setTypeface(Typeface.DEFAULT_BOLD);
152166
userName.setGravity(Gravity.CENTER_VERTICAL);
153167
userName.setSingleLine();
154168
userName.setEllipsize(TextUtils.TruncateAt.END);
155169
userName.setLayoutParams(textParams);
156170
userEmail = new TextView(getContext());
157-
userEmail.setTextColor(Color.WHITE);
171+
userEmail.setTextColor(getContext().getResources().getColor(color));
158172
userEmail.setGravity(Gravity.CENTER_VERTICAL);
159173
userEmail.setSingleLine();
160174
userEmail.setEllipsize(TextUtils.TruncateAt.END);
-2.5 KB
Binary file not shown.
249 Bytes
Loading
-2.5 KB
Binary file not shown.
219 Bytes
Loading
349 Bytes
Loading

0 commit comments

Comments
 (0)