summaryrefslogtreecommitdiff
path: root/library/main/src/com
diff options
context:
space:
mode:
authorMaurice Lam <yukl@google.com>2016-01-20 17:18:22 -0800
committerMaurice Lam <yukl@google.com>2016-01-20 18:25:55 -0800
commitac40f3676511e1c7c09a948f5cb8481e5ea12d57 (patch)
tree2865ab32ea385e691bd70cca292ee3e76ef18f30 /library/main/src/com
parentd6708911f6f2fa7dd060536a118b5efb3c5e174f (diff)
downloadsetupwizard-ac40f3676511e1c7c09a948f5cb8481e5ea12d57.tar.gz
[SetupWizard] Add GlifLayout.setPrimaryColor
Bug: 26458108 Change-Id: Ia7be66fcf1efd60e65a759006f72b3a0589d0401
Diffstat (limited to 'library/main/src/com')
-rw-r--r--library/main/src/com/android/setupwizardlib/GlifLayout.java56
1 files changed, 43 insertions, 13 deletions
diff --git a/library/main/src/com/android/setupwizardlib/GlifLayout.java b/library/main/src/com/android/setupwizardlib/GlifLayout.java
index 0590a81..bf06bf5 100644
--- a/library/main/src/com/android/setupwizardlib/GlifLayout.java
+++ b/library/main/src/com/android/setupwizardlib/GlifLayout.java
@@ -29,6 +29,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.widget.ImageView;
+import android.widget.ProgressBar;
import android.widget.ScrollView;
import android.widget.TextView;
@@ -56,6 +57,8 @@ public class GlifLayout extends TemplateLayout {
private static final String TAG = "GlifLayout";
+ private ColorStateList mPrimaryColor;
+
public GlifLayout(Context context) {
this(context, 0, 0);
}
@@ -106,20 +109,11 @@ public class GlifLayout extends TemplateLayout {
setHeaderText(headerText);
}
- a.recycle();
+ final ColorStateList primaryColor =
+ a.getColorStateList(R.styleable.SuwGlifLayout_android_colorPrimary);
+ setPrimaryColor(primaryColor);
- if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
- setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
- final View patternBg = findViewById(R.id.suw_pattern_bg);
- if (patternBg != null) {
- final GlifPatternDrawable background = GlifPatternDrawable.getDefault(getContext());
- if (patternBg instanceof StatusBarBackgroundLayout) {
- ((StatusBarBackgroundLayout) patternBg).setStatusBarBackground(background);
- } else {
- patternBg.setBackground(background);
- }
- }
- }
+ a.recycle();
}
@Override
@@ -191,6 +185,32 @@ public class GlifLayout extends TemplateLayout {
return (ImageView) findViewById(R.id.suw_layout_icon);
}
+ public void setPrimaryColor(ColorStateList color) {
+ mPrimaryColor = color;
+ setGlifPatternColor(color);
+ setProgressBarColor(color);
+ }
+
+ public ColorStateList getPrimaryColor() {
+ return mPrimaryColor;
+ }
+
+ private void setGlifPatternColor(ColorStateList color) {
+ if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
+ setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
+ final View patternBg = findViewById(R.id.suw_pattern_bg);
+ if (patternBg != null) {
+ final GlifPatternDrawable background =
+ new GlifPatternDrawable(color.getDefaultColor());
+ if (patternBg instanceof StatusBarBackgroundLayout) {
+ ((StatusBarBackgroundLayout) patternBg).setStatusBarBackground(background);
+ } else {
+ patternBg.setBackground(background);
+ }
+ }
+ }
+ }
+
public boolean isProgressBarShown() {
final View progressBar = findViewById(R.id.suw_layout_progress);
return progressBar != null && progressBar.getVisibility() == View.VISIBLE;
@@ -208,10 +228,20 @@ public class GlifLayout extends TemplateLayout {
progressBarStub.inflate();
}
}
+ setProgressBarColor(mPrimaryColor);
} else {
if (progressBar != null) {
progressBar.setVisibility(View.GONE);
}
}
}
+
+ private void setProgressBarColor(ColorStateList color) {
+ if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
+ final ProgressBar bar = (ProgressBar) findViewById(R.id.suw_layout_progress);
+ if (bar != null) {
+ bar.setIndeterminateTintList(color);
+ }
+ }
+ }
}