diff options
author | Richard MacGregor <rmacgregor@cyngn.com> | 2016-03-23 13:43:34 -0700 |
---|---|---|
committer | Richard MacGregor <rmacgregor@cyngn.com> | 2016-04-08 10:42:51 -0700 |
commit | 7823a59c3ddae3b733512b564edeeee09b03ae37 (patch) | |
tree | 333a877b356d552a970dfb1a3d183847f5e15cc9 | |
parent | 18a593c44d990290f5236dea9a92655f964cc848 (diff) | |
download | packages_apps_PhoneCommon-7823a59c3ddae3b733512b564edeeee09b03ae37.tar.gz packages_apps_PhoneCommon-7823a59c3ddae3b733512b564edeeee09b03ae37.tar.bz2 packages_apps_PhoneCommon-7823a59c3ddae3b733512b564edeeee09b03ae37.zip |
InCall: add low credit warnings
CD-262
Change-Id: I42c546bd2d4cc83885b0d06a8b3a3090827f05ff
-rw-r--r-- | res/values/cm_colors.xml | 1 | ||||
-rw-r--r-- | src-ambient/incall/CreditBarHelper.java | 38 |
2 files changed, 25 insertions, 14 deletions
diff --git a/res/values/cm_colors.xml b/res/values/cm_colors.xml index 36ed0ae..d4ce5c8 100644 --- a/res/values/cm_colors.xml +++ b/res/values/cm_colors.xml @@ -14,4 +14,5 @@ <color name="credit_banner_background">#effafe</color> <color name="credit_banner_text">#00adef</color> + <color name="credit_banner_alert_color">#f5a623</color> </resources>
\ No newline at end of file diff --git a/src-ambient/incall/CreditBarHelper.java b/src-ambient/incall/CreditBarHelper.java index 2a55eb6..6ebec2e 100644 --- a/src-ambient/incall/CreditBarHelper.java +++ b/src-ambient/incall/CreditBarHelper.java @@ -6,6 +6,7 @@ import android.text.TextUtils; import android.util.Log; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.TextView; import com.android.phone.common.R; @@ -26,31 +27,40 @@ public class CreditBarHelper { } public static void clearCallRateInformation(ViewGroup v, CreditBarVisibilityListener cpvl) { - setCallRateInformation(v, null, null, null, cpvl); + setCallRateInformation(null, v, null, null, null, false, cpvl); } - public static void setCallRateInformation(ViewGroup creditsBar, String countryName, - String displayRate, final PendingIntent p, - CreditBarVisibilityListener cpvl) { - if (TextUtils.isEmpty(countryName) && TextUtils.isEmpty(displayRate) && - p == null) { + public static void setCallRateInformation(Resources res, ViewGroup creditsBar, + String creditText, String buttonText, final PendingIntent buttonIntent, + boolean warnIfLow, CreditBarVisibilityListener cpvl) { + if (TextUtils.isEmpty(creditText) && TextUtils.isEmpty(buttonText) && + buttonIntent == null) { creditsBar.setVisibility(View.GONE); cpvl.creditsBarVisibilityChanged(View.GONE); return; } creditsBar.setVisibility(View.VISIBLE); cpvl.creditsBarVisibilityChanged(View.VISIBLE); - TextView ildCountry = (TextView) creditsBar.findViewById(R.id.ild_country); - TextView ildRate = (TextView) creditsBar.findViewById(R.id.ild_rate); - ildCountry.setText(countryName); - ildRate.setText(displayRate); - ildRate.setOnClickListener(new View.OnClickListener() { + // These views already exist, we are hijacking them. + TextView credit = (TextView) creditsBar.findViewById(R.id.ild_country); + TextView button = (TextView) creditsBar.findViewById(R.id.ild_rate); + + if (res != null) { + int color = warnIfLow ? + res.getColor(R.color.credit_banner_alert_color) : + res.getColor(R.color.credit_banner_text); + credit.setTextColor(color); + } + + credit.setText(creditText); + button.setText(buttonText); + button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { - if (p != null) { - p.send(); + if (buttonIntent != null) { + buttonIntent.send(); } else { Log.wtf(TAG, "The intent we attempted to fire was null"); } @@ -88,6 +98,6 @@ public class CreditBarHelper { button = cmi.mLoginIntent; } } - setCallRateInformation(v, creditText, buttonText, button, cpvl); + setCallRateInformation(r, v, creditText, buttonText, button, warnIfLow, cpvl); } } |