Also modified canadiancow's battery percentage to never show 100 since it wraps wierd on the dream.
public static final String ACCELEROMETER_ROTATION = "accelerometer_rotation";
/**
+ * Toggles whether to display the PLMN field on the Lockscreen
+ * @hide
+ */
+ public static final String SHOW_PLMN_LS = "show_plmn_ls";
+
+ /**
+ * Toggles whether to display the SPN field on the Lockscreen
+ * @hide
+ */
+ public static final String SHOW_SPN_LS = "show_spn_ls";
+
+ /**
+ * Toggles whether to display the PLMN field on the Notification bar
+ * @hide
+ */
+ public static final String SHOW_PLMN_SB = "show_plmn_sb";
+
+ /**
+ * Toggles whether to display the SPN field on the Notification bar
+ * @hide
+ */
+ public static final String SHOW_SPN_SB = "show_spn_sb";
+
+ /**
+ * Specifies whether to show or hide clock
+ * @hide
+ */
+ public static final String SHOW_STATUS_CLOCK = "show_status_clock";
+
+ /**
+ * Specifies the clock color
+ * @hide
+ */
+ public static final String CLOCK_COLOR = "clock_color";
+
+ /**
+ * Specifies notification count color
+ * @hide
+ */
+ public static final String NOTIF_COUNT_COLOR = "notifications_count_color";
+
+ /**
+ * Specifies the date color
+ * @hide
+ */
+ public static final String DATE_COLOR = "date_color";
+
+ /**
+ * Specifies new notification ticker color
+ * @hide
+ */
+ public static final String NEW_NOTIF_TICKER_COLOR = "new_notifications_ticker_color";
+
+ /**
+ * Specifies no notifications color
+ * @hide
+ */
+ public static final String NO_NOTIF_COLOR = "no_notifications_color";
+
+ /**
+ * Specifies latest nofitication color
+ * @hide
+ */
+ public static final String LATEST_NOTIF_COLOR = "latest_notifications_color";
+
+ /**
+ * Specifies ongoing notification color
+ * @hide
+ */
+ public static final String ONGOING_NOTIF_COLOR = "ongoing_notifications_color";
+
+ /**
+ * Specifies spn label color
+ * @hide
+ */
+ public static final String SPN_LABEL_COLOR = "spn_label_color";
+
+ /**
+ * Specifies plmn color
+ * @hide
+ */
+ public static final String PLMN_LABEL_COLOR = "plmn_label_color";
+
+ /**
+ * Specifies clear button color
+ * @hide
+ */
+ public static final String CLEAR_BUTTON_LABEL_COLOR = "clear_button_label_color";
+
+ /**
+ * Specifies notification item title color.
+ * @hide
+ */
+ public static final String NOTIF_ITEM_TITLE_COLOR = "notifications_title_color";
+
+ /**
+ * Specifies notification item text color.
+ * @hide
+ */
+ public static final String NOTIF_ITEM_TEXT_COLOR = "notifications_text_color";
+
+ /**
+ * Specifies notification item time color.
+ * @hide
+ */
+ public static final String NOTIF_ITEM_TIME_COLOR = "notifications_time_color";
+
+ /**
+ * Whether to show the battery level percentage overlayed on the icon.
+ * @hide
+ */
+ public static final String BATTERY_PERCENTAGE_STATUS_ICON = "battery_percentage_status_icon";
+
+ /**
+ * Specifies battery percentage status color
+ * @hide
+ */
+ public static final String BATTERY_PERCENTAGE_STATUS_COLOR = "battery_status_color_title";
+
+ /**
* Whether the audible DTMF tones are played by the dialer when dialing. The value is
* boolean (1 or 0).
*/
public static final int ICON = 2;
/**
+ * Indicates ths item represents an integer displayed on top of an icon.
+ */
+ public static final int ICON_NUMBER = 3;
+
+ /**
* The type of this item. One of TEXT, ICON, or LEVEL_ICON.
*/
public int type;
return data;
}
+ public static IconData makeIconNumber(String slot,
+ String iconPackage, int iconId, int iconLevel, int number) {
+ IconData data = new IconData();
+ data.type = ICON_NUMBER;
+ data.slot = slot;
+ data.iconPackage = iconPackage;
+ data.iconId = iconId;
+ data.iconLevel = iconLevel;
+ data.number = number;
+ return data;
+ }
+
public void copyFrom(IconData that) {
this.type = that.type;
this.slot = that.slot;
+ " iconId=" + Integer.toHexString(this.iconId)
+ " iconLevel=" + this.iconLevel + ")";
}
+ else if (this.type == ICON_NUMBER) {
+ return "IconData(slot=" + (this.slot != null ? "'" + this.slot + "'" : "null")
+ + " package=" + this.iconPackage
+ + " iconId=" + Integer.toHexString(this.iconId)
+ + " iconLevel=" + this.iconLevel
+ + " number='" + this.number + "')";
+ }
else {
return "IconData(type=" + type + ")";
}
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
+import android.graphics.drawable.AnimationDrawable;
+import android.provider.Settings;
+import android.view.WindowManager;
+import android.widget.FrameLayout;
+import android.util.DisplayMetrics;
class StatusBarIcon {
// TODO: get this from a resource
private TextView mTextView;
private AnimatedImageView mImageView;
private TextView mNumberView;
+ private int clockColor = 0xff000000;
+ private int batteryPercentColor = 0xffffffff;
+ private int notifCountColor = 0xffffffff;
+ private Context mContext;
public StatusBarIcon(Context context, IconData data, ViewGroup parent) {
+ mContext = context;
mData = data.clone();
switch (data.type) {
mTextView = t;
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.MATCH_PARENT);
+ LinearLayout.LayoutParams.FILL_PARENT);
t.setTextSize(16);
- t.setTextColor(0xff000000);
t.setTypeface(Typeface.DEFAULT_BOLD);
t.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
t.setPadding(6, 0, 0, 0);
t.setLayoutParams(layoutParams);
t.setText(data.text);
this.view = t;
+
+ clockColor = Settings.System.getInt(mContext.getContentResolver(), Settings.System.CLOCK_COLOR, clockColor);
+ t.setTextColor(clockColor);
+
+ if (getBoolean(Settings.System.SHOW_STATUS_CLOCK, true)) {
+ t.setVisibility(View.VISIBLE);
+ } else {
+ t.setVisibility(View.GONE);
+ }
+
break;
}
mNumberView = nv;
if (data.number > 0) {
nv.setText("" + data.number);
+ notifCountColor = Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.NOTIF_COUNT_COLOR, notifCountColor);
+ nv.setTextColor(notifCountColor);
nv.setVisibility(View.VISIBLE);
} else {
nv.setVisibility(View.GONE);
}
break;
}
+ case IconData.ICON_NUMBER: {
+ // container
+ LayoutInflater inflater = (LayoutInflater)context.getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ View v = inflater.inflate(com.android.internal.R.layout.status_bar_icon, parent, false);
+ this.view = v;
+
+ // icon
+ AnimatedImageView im = (AnimatedImageView)v.findViewById(com.android.internal.R.id.image);
+ im.setImageDrawable(getIcon(context, data));
+ im.setImageLevel(data.iconLevel);
+ mImageView = im;
+
+ // number
+ TextView nv = (TextView)v.findViewById(com.android.internal.R.id.number);
+ mNumberView = nv;
+
+ //remove background, center, and change gravity of text
+ // attempt to correct position on both hdpi and mdpi
+ DisplayMetrics dm = new DisplayMetrics();
+ ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(dm);
+
+ if (DisplayMetrics.DENSITY_HIGH == dm.densityDpi) {
+ mNumberView.setLayoutParams(
+ new FrameLayout.LayoutParams(
+ FrameLayout.LayoutParams.WRAP_CONTENT,
+ FrameLayout.LayoutParams.WRAP_CONTENT,
+ Gravity.RIGHT | Gravity.CENTER_VERTICAL));
+
+ mNumberView.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
+ } else {
+ mNumberView.setLayoutParams(
+ new FrameLayout.LayoutParams(
+ FrameLayout.LayoutParams.WRAP_CONTENT,
+ FrameLayout.LayoutParams.WRAP_CONTENT,
+ Gravity.CENTER | Gravity.CENTER_VERTICAL));
+
+ mNumberView.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
+ }
+
+ mNumberView.setBackgroundDrawable(null);
+ batteryPercentColor = Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.BATTERY_PERCENTAGE_STATUS_COLOR, batteryPercentColor);
+ mNumberView.setTextColor(batteryPercentColor);
+ mNumberView.setTextSize(12);
+
+ if (data.number >= 0) {
+ nv.setText("" + data.number);
+ } else {
+ nv.setText("");
+ }
+ break;
+ }
}
}
}
break;
case IconData.ICON:
+ case IconData.ICON_NUMBER:
if (((mData.iconPackage != null && data.iconPackage != null)
&& !mData.iconPackage.equals(data.iconPackage))
|| mData.iconId != data.iconId
int getNumber() {
return mData.number;
}
+ private boolean getBoolean(String systemSettingKey, boolean defaultValue) {
+ return 1 == android.provider.Settings.System.getInt(mContext.getContentResolver(), systemSettingKey, defaultValue ? 1 : 0);
+ }
}
new com.android.server.status.StorageNotification(context));
// battery
- mBatteryData = IconData.makeIcon("battery",
+ mBatteryData = IconData.makeIconNumber("battery",
null, com.android.internal.R.drawable.stat_sys_battery_unknown, 0, 0);
mBatteryIcon = service.addIcon(mBatteryData, null);
private final void updateBattery(Intent intent) {
mBatteryData.iconId = intent.getIntExtra("icon-small", 0);
mBatteryData.iconLevel = intent.getIntExtra("level", 0);
- mService.updateIcon(mBatteryIcon, mBatteryData, null);
boolean plugged = intent.getIntExtra("plugged", 0) != 0;
int level = intent.getIntExtra("level", -1);
+
+ // show battery percentage if not plugged in
+ if (plugged || level >= 100) {
+ mBatteryData.number = -1;
+ } else {
+ mBatteryData.number = level;
+ }
+
+ mService.updateIcon(mBatteryIcon, mBatteryData, null);
+
if (false) {
Slog.d(TAG, "updateBattery level=" + level
+ " plugged=" + plugged
import java.util.HashMap;
import java.util.Set;
+import android.provider.Settings;
+import java.lang.reflect.Field;
+
/**
* The public (ok, semi-public) service for the status bar.
static final String TAG = "StatusBar";
static final boolean SPEW = false;
+ private boolean mShowPlmnSb;
+ private boolean mShowSpnSb;
+
static final int EXPANDED_LEAVE_ALONE = -10000;
static final int EXPANDED_FULL_OPEN = -10001;
private Ticker mTicker;
private View mTickerView;
private boolean mTicking;
+ private TickerView tickerView;
// Tracking finger for opening/closing.
int mEdgeBorder; // corresponds to R.dimen.status_bar_edge_ignore
boolean mAnimatingReveal = false;
int mViewDelta;
int[] mAbsPos = new int[2];
+ private int blackColor = 0xff000000;
+ private int whiteColor = 0xffffffff;
+ private int notificationTitleColor = blackColor;
+ private int notificationTextColor = blackColor;
+ private int notificationTimeColor = blackColor;
// for disabling the status bar
ArrayList<DisableRecord> mDisableRecords = new ArrayList<DisableRecord>();
*/
public StatusBarService(Context context) {
mContext = context;
+ notificationTitleColor = Settings.System.getInt(mContext.getContentResolver(), Settings.System.NOTIF_ITEM_TITLE_COLOR, blackColor);
+ notificationTextColor = Settings.System.getInt(mContext.getContentResolver(), Settings.System.NOTIF_ITEM_TEXT_COLOR, blackColor);
+ notificationTimeColor = Settings.System.getInt(mContext.getContentResolver(), Settings.System.NOTIF_ITEM_TIME_COLOR, blackColor);
mDisplay = ((WindowManager)context.getSystemService(
Context.WINDOW_SERVICE)).getDefaultDisplay();
makeStatusBarView(context);
+ updateColors();
mUninstallReceiver = new UninstallReceiver();
}
mTicker = new MyTicker(context, sb);
- TickerView tickerView = (TickerView)sb.findViewById(R.id.tickerText);
+ tickerView = (TickerView)sb.findViewById(R.id.tickerText);
tickerView.mTicker = mTicker;
mTrackingView = (TrackingView)View.inflate(context,
Slog.e(TAG, "couldn't inflate view for package " + n.pkg, exception);
return null;
}
+
+ //Try-catch cause it does not work with QuickSettings, possibly other apps too :( (Won't work thru XML as well)
+ try {
+ TextView tv1 = (TextView) child.findViewById(com.android.internal.R.id.title);
+ TextView tv2 = (TextView) child.findViewById(com.android.internal.R.id.text);
+ TextView tv3 = (TextView) child.findViewById(com.android.internal.R.id.time);
+ tv1.setTextColor(notificationTitleColor);
+ tv2.setTextColor(notificationTextColor);
+ tv3.setTextColor(notificationTimeColor);
+ }
+ catch (Exception e) {
+ }
+
content.addView(child);
row.setDrawingCacheEnabled(true);
}
}
+ private void updateColors() {
+ mDateView.setTextColor(Settings.System.getInt(mContext.getContentResolver(), Settings.System.DATE_COLOR, blackColor));
+ mNoNotificationsTitle.setTextColor(Settings.System.getInt(mContext.getContentResolver(), Settings.System.NO_NOTIF_COLOR, whiteColor));
+ mLatestTitle.setTextColor(Settings.System.getInt(mContext.getContentResolver(), Settings.System.LATEST_NOTIF_COLOR, whiteColor));
+ mOngoingTitle.setTextColor(Settings.System.getInt(mContext.getContentResolver(), Settings.System.ONGOING_NOTIF_COLOR, whiteColor));
+ mSpnLabel.setTextColor(Settings.System.getInt(mContext.getContentResolver(), Settings.System.SPN_LABEL_COLOR, blackColor));
+ mPlmnLabel.setTextColor(Settings.System.getInt(mContext.getContentResolver(), Settings.System.PLMN_LABEL_COLOR, blackColor));
+ mClearButton.setTextColor(Settings.System.getInt(mContext.getContentResolver(), Settings.System.CLEAR_BUTTON_LABEL_COLOR, blackColor));
+ tickerView.updateColors(Settings.System.getInt(mContext.getContentResolver(), Settings.System.NEW_NOTIF_TICKER_COLOR, blackColor));
+ }
+
private View.OnClickListener mClearButtonListener = new View.OnClickListener() {
public void onClick(View v) {
mNotificationCallbacks.onClearAll();
};
void updateNetworkName(boolean showSpn, String spn, boolean showPlmn, String plmn) {
+ // Double carrier
+ mShowPlmnSb = (Settings.System.getInt(mContext.getContentResolver(), Settings.System.SHOW_PLMN_SB, 1) == 1);
+ mShowSpnSb = (Settings.System.getInt(mContext.getContentResolver(), Settings.System.SHOW_SPN_SB, 1) == 1);
if (false) {
Slog.d(TAG, "updateNetworkName showSpn=" + showSpn + " spn=" + spn
+ " showPlmn=" + showPlmn + " plmn=" + plmn);
}
boolean something = false;
- if (showPlmn) {
+ // Double carrier - bcrook
+ if (showPlmn && mShowPlmnSb) {
mPlmnLabel.setVisibility(View.VISIBLE);
if (plmn != null) {
mPlmnLabel.setText(plmn);
mPlmnLabel.setText("");
mPlmnLabel.setVisibility(View.GONE);
}
- if (showSpn && spn != null) {
+ // Double carrier - bcrook, refinements from Wysie
+ if (showSpn && spn != null && mShowSpnSb) {
mSpnLabel.setText(spn);
mSpnLabel.setVisibility(View.VISIBLE);
something = true;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextSwitcher;
+import android.widget.TextView;
public class TickerView extends TextSwitcher
{
Ticker mTicker;
+ private int textColor = 0xFF000000;
public TickerView(Context context, AttributeSet attrs) {
super(context, attrs);
super.onSizeChanged(w, h, oldw, oldh);
mTicker.reflowText();
}
+
+ @Override
+ public void setText(CharSequence text) {
+ final TextView t = (TextView) getNextView();
+ t.setTextColor(textColor);
+ t.setText(text);
+ showNext();
+ }
+
+ @Override
+ public void setCurrentText(CharSequence text) {
+ final TextView t = (TextView) getCurrentView();
+ t.setTextColor(textColor);
+ t.setText(text);
+ }
+
+ public void updateColors(int color) {
+ textColor = color;
+ }
}