Skip to content

Commit

Permalink
Statusbar clock font style (1/2)
Browse files Browse the repository at this point in the history
PS1: Initial
PS2: Int settings

Change-Id: Iafb811b9f819a100940fdeeaa2c657483c039950

Conflicts:
	core/java/android/provider/Settings.java
	packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java

Conflicts:
	core/java/android/provider/Settings.java

Conflicts:
	packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java
  • Loading branch information
daxxmax authored and ThatKawaiiGuy committed Aug 11, 2014
1 parent d8a17ba commit e7cbd25
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 7 deletions.
6 changes: 6 additions & 0 deletions core/java/android/provider/Settings.java
Expand Up @@ -4333,6 +4333,12 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
*/
public static final String CALL_FLIP_ACTION_KEY = "call_flip_action_key";

/**
* Settings for clock font style
* @hide
*/
public static final String STATUSBAR_CLOCK_FONT_STYLE = "statusbar_clock_font_style";

/**
* Settings to backup. This is here so that it's in the same place as the settings
* keys and easy to update.
Expand Down
Expand Up @@ -24,6 +24,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Handler;
import android.os.UserHandle;
Expand Down Expand Up @@ -82,9 +83,14 @@ public class Clock extends TextView implements DemoMode, OnClickListener, OnLong
public static final int STYLE_CLOCK_RIGHT = 0;
public static final int STYLE_CLOCK_CENTER = 1;

public static final int FONT_BOLD = 0;
public static final int FONT_LIGHT = 1;
public static final int FONT_NORMAL = 2;

protected int mClockDateDisplay = CLOCK_DATE_DISPLAY_GONE;
protected int mClockDateStyle = CLOCK_DATE_STYLE_UPPERCASE;
protected int mClockStyle = STYLE_CLOCK_RIGHT;
protected int mClockFontStyle = FONT_NORMAL;
protected boolean mShowClock;

private int mAmPmStyle;
Expand All @@ -105,17 +111,32 @@ void observe() {
.getUriFor(Settings.System.STATUSBAR_CLOCK_AM_PM_STYLE),
false, this, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System
.getUriFor(Settings.System.STATUSBAR_CLOCK_STYLE), false,
this, UserHandle.USER_ALL);
.getUriFor(Settings.System.STATUSBAR_CLOCK_STYLE),
false, this, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System
.getUriFor(Settings.System.STATUSBAR_CLOCK_DATE_DISPLAY), false,
this, UserHandle.USER_ALL);
.getUriFor(Settings.System.STATUSBAR_CLOCK_FONT_STYLE),
false, this, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System
.getUriFor(Settings.System.STATUSBAR_CLOCK_DATE_STYLE), false,
this, UserHandle.USER_ALL);
.getUriFor(Settings.System.STATUSBAR_CLOCK_COLOR),
false, this, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System
.getUriFor(Settings.System.STATUSBAR_CLOCK_DATE_DISPLAY),
false, this, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System
.getUriFor(Settings.System.STATUSBAR_CLOCK_DATE_STYLE),
false, this, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System
.getUriFor(Settings.System.STATUSBAR_CLOCK_DATE_FORMAT),
false, this, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System
.getUriFor(Settings.System.CUSTOM_SYSTEM_ICON_COLOR),
false, this, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System
.getUriFor(Settings.System.STATUSBAR_CLOCK_DATE_FORMAT), false,
this, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System
.getUriFor(Settings.System.SYSTEM_ICON_COLOR),
false, this, UserHandle.USER_ALL);
updateSettings();
}

Expand Down Expand Up @@ -369,12 +390,30 @@ public void run()
mClockDateStyle = Settings.System.getIntForUser(resolver,
Settings.System.STATUSBAR_CLOCK_DATE_STYLE, CLOCK_DATE_STYLE_UPPERCASE,
UserHandle.USER_CURRENT);
mClockFontStyle = Settings.System.getIntForUser(resolver,
Settings.System.STATUSBAR_CLOCK_FONT_STYLE, FONT_NORMAL,
UserHandle.USER_CURRENT);

if (mAttached) {
getFontStyle(mClockFontStyle);
updateClockVisibility();
updateClock();
}
}

public void getFontStyle(int font) {
switch (font) {
case FONT_BOLD:
setTypeface(Typeface.create("sans-serif", Typeface.BOLD));
break;
case FONT_LIGHT:
setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL));
break;
case FONT_NORMAL:
default:
setTypeface(Typeface.create("sans-serif", Typeface.NORMAL));
break;
}
}

protected void updateClockVisibility() {
Expand Down Expand Up @@ -448,4 +487,3 @@ public void dispatchDemoCommand(String command, Bundle args) {
}
}
}

0 comments on commit e7cbd25

Please sign in to comment.