android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
- android:gravity="bottom"
- android:background="#30000000"
>
+ <!-- Entire display region (everything but bottom buttons) -->
<LinearLayout
android:orientation="vertical"
android:layout_gravity="left"
+ android:layout_weight="1"
android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginBottom="15dip"
- android:layout_marginLeft="15dip"
- android:layout_marginRight="15dip"
- android:paddingTop="20dip"
- android:paddingBottom="20dip"
+ android:layout_height="fill_parent"
+ android:layout_marginLeft="20dip"
+ android:layout_marginTop="20dip"
+ android:layout_marginRight="14dip"
+ android:layout_marginBottom="14dip"
>
- <TextView android:id="@+id/carrier"
+ <!-- across the top: next alarm, nightmode button -->
+ <LinearLayout
+ android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:gravity="right"
- android:textSize="34sp"
- />
+ android:layout_weight="0"
+ android:layout_marginBottom="6dip"
+ >
+ <TextView android:id="@+id/nextAlarm"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="left"
+ android:textSize="18sp"
+ android:textColor="#FFFFFFFF"
+ android:drawablePadding="6dip"
+ android:drawableLeft="@android:drawable/ic_lock_idle_alarm"
+ android:shadowColor="#C0000000"
+ android:shadowDx="0"
+ android:shadowDy="0"
+ android:shadowRadius="3.0"
+ />
+ <Button android:id="@+id/nightmode_button"
+ android:layout_weight="0"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:text="@string/nightmode_button_title_placeholder"
+ />
+ </LinearLayout>
- <!-- digital clock -->
- <com.android.deskclock.DigitalClock android:id="@+id/time"
- android:layout_width="wrap_content"
+
+ <!-- digital clock & date, together -->
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="30dip"
+ android:layout_weight="1"
+ android:gravity="left|center_vertical"
android:layout_marginBottom="12dip"
- android:layout_marginLeft="-8dip"
>
- <!-- negative left margin above accounts for Clockopia's
- generous glyph padding -->
- <TextView android:id="@+id/timeDisplay"
+ <com.android.deskclock.DigitalClock android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:gravity="center"
- android:textSize="100sp"
- android:textColor="@color/white"
- />
-
-
- <TextView android:id="@+id/am_pm"
+ android:layout_marginBottom="12dip"
+ android:layout_marginLeft="-8dip"
+ >
+ <!-- negative left margin above accounts for Clockopia's
+ generous glyph padding -->
+
+ <TextView android:id="@+id/timeDisplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:textSize="100sp"
+ android:textColor="#FFFFFFFF"
+ android:shadowColor="#C0000000"
+ android:shadowDx="0"
+ android:shadowDy="0"
+ android:shadowRadius="3.0"
+ />
+
+
+ <TextView android:id="@+id/am_pm"
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:gravity="bottom"
+ android:textSize="28sp"
+ android:singleLine="true"
+ android:layout_marginLeft="3dip"
+ android:textColor="#FFFFFFFF"
+ android:shadowColor="#C0000000"
+ android:shadowDx="0"
+ android:shadowDy="0"
+ android:shadowRadius="3.0"
+ />
+
+ </com.android.deskclock.DigitalClock>
+
+ <TextView android:id="@+id/date"
android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:gravity="bottom"
- android:textSize="28sp"
- android:layout_marginLeft="3dip"
- android:textColor="@color/white"
+ android:layout_height="wrap_content"
+ android:gravity="left"
+ android:textSize="18sp"
+ android:textColor="#FFFFFFFF"
+ android:shadowColor="#C0000000"
+ android:shadowDx="0"
+ android:shadowDy="0"
+ android:shadowRadius="3.0"
/>
-
- </com.android.deskclock.DigitalClock>
-
- <TextView android:id="@+id/date"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="left"
- android:textSize="18sp"
- android:textColor="@color/white"
- />
+
+ </LinearLayout>
<!-- TODO: weather -->
<View android:id="@+id/weather"
- android:layout_width="wrap_content"
- android:layout_height="100dip"
- />
-
- <TextView android:id="@+id/nextAlarm"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="left"
- android:textSize="18sp"
- android:textColor="@color/white"
- android:drawablePadding="6dip"
- android:drawableLeft="@android:drawable/ic_lock_idle_alarm"
- />
+ android:layout_width="wrap_content"
+ android:layout_height="100dip"
+ android:layout_weight="0"
+ android:background="#C0FF8000"
+ android:layout_marginBottom="12dip"
+ />
+
+ <!-- battery/charge status -->
+ <TextView android:id="@+id/battery"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0"
+ android:gravity="right"
+ android:textSize="18sp"
+ android:textColor="#FFFFFFFF"
+ android:drawablePadding="6dip"
+ android:shadowColor="#C0000000"
+ android:shadowDx="0"
+ android:shadowDy="0"
+ android:shadowRadius="3.0"
+ />
</LinearLayout>
- <!-- TODO: buttons -->
+ <!-- buttons -->
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
+ android:layout_weight="0"
>
<!--
android:background="@null"
android:layout_weight=".25"
android:text="@string/music_button_title_placeholder"
/>
- <Button android:id="@+id/nightmode_button"
+ <Button android:id="@+id/home_button"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight=".25"
- android:text="@string/nightmode_button_title_placeholder"
+ android:text="@string/home_button_title_placeholder"
/>
</LinearLayout>
import android.widget.TextView;
import android.widget.CheckBox;
+import static android.os.BatteryManager.BATTERY_STATUS_CHARGING;
+import static android.os.BatteryManager.BATTERY_STATUS_FULL;
+import static android.os.BatteryManager.BATTERY_STATUS_UNKNOWN;
+
import java.text.DateFormat;
import java.util.Date;
private TextView mNextAlarm = null;
private TextView mDate;
+ private TextView mBatteryDisplay;
private DigitalClock mTime;
private boolean mDimmed = false;
private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- refreshDate();
+ final String action = intent.getAction();
+ if (Intent.ACTION_DATE_CHANGED.equals(action)) {
+ refreshDate();
+ } else if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
+ handleBatteryUpdate(
+ intent.getIntExtra("status", BATTERY_STATUS_UNKNOWN),
+ intent.getIntExtra("level", 0));
+ }
}
};
private DateFormat mDateFormat;
+
+ private int mBatteryLevel;
+ private boolean mPluggedIn;
+
+ // Adapted from KeyguardUpdateMonitor.java
+ private void handleBatteryUpdate(int plugStatus, int batteryLevel) {
+ final boolean pluggedIn = (plugStatus == BATTERY_STATUS_CHARGING || plugStatus == BATTERY_STATUS_FULL);
+ if (pluggedIn != mPluggedIn || batteryLevel != mBatteryLevel) {
+ mBatteryLevel = batteryLevel;
+ mPluggedIn = pluggedIn;
+ refreshBattery();
+ }
+ }
+
+ private void refreshBattery() {
+ if (mPluggedIn /* || mBatteryLevel < LOW_BATTERY_THRESHOLD */) {
+ mBatteryDisplay.setCompoundDrawablesWithIntrinsicBounds(
+ 0, 0, android.R.drawable.ic_lock_idle_charging, 0);
+ mBatteryDisplay.setText(
+ getString(R.string.battery_charging_level, mBatteryLevel));
+ mBatteryDisplay.setVisibility(View.VISIBLE);
+ } else {
+ mBatteryDisplay.setVisibility(View.INVISIBLE);
+ }
+ }
private void refreshDate() {
mDate.setText(mDateFormat.format(new Date()));
Window win = getWindow();
WindowManager.LayoutParams winParams = win.getAttributes();
+
+ // dim the wallpaper somewhat (how much is determined below)
+ winParams.flags |= (WindowManager.LayoutParams.FLAG_DIM_BEHIND);
+
if (mDimmed) {
winParams.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
+// winParams.flags &= (~WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
+ winParams.dimAmount = 0.5f; // pump up contrast in dim mode
+
+ // show the window tint
tintView.startAnimation(AnimationUtils.loadAnimation(this, R.anim.dim));
} else {
winParams.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
+// winParams.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
+ winParams.dimAmount = 0.2f; // lower contrast in normal mode
+
+ // hide the window tint
tintView.startAnimation(AnimationUtils.loadAnimation(this, R.anim.undim));
}
-
+
win.setAttributes(winParams);
}
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_DATE_CHANGED);
+ filter.addAction(Intent.ACTION_BATTERY_CHANGED);
registerReceiver(mIntentReceiver, filter);
doDim();
refreshDate();
refreshAlarm();
+ refreshBattery();
}
@Override
mTime = (DigitalClock) findViewById(R.id.time);
mDate = (TextView) findViewById(R.id.date);
+ mBatteryDisplay = (TextView) findViewById(R.id.battery);
mNextAlarm = (TextView) findViewById(R.id.nextAlarm);