Skip to content

Commit

Permalink
Added ability to remove Weather line.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedlar committed Oct 22, 2011
1 parent f92264d commit d1fa1d7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 25 deletions.
Binary file removed assets/Thumbs.db
Binary file not shown.
6 changes: 6 additions & 0 deletions res/layout/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@
android:numeric="integer"
android:defaultValue="5"
/>
<CheckBoxPreference
android:title="Disable Weather"
android:key="DisableWeather"
android:summary="Disable weaather on idle screen"
android:defaultValue="false"
/>
<CheckBoxPreference
android:title="Music Controls (Beta)"
android:key="IdleMusicControls"
Expand Down
55 changes: 30 additions & 25 deletions src/org/metawatch/manager/Idle.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

package org.metawatch.manager;

import org.metawatch.manager.MetaWatchService.Preferences;
import org.metawatch.manager.Monitors.WeatherData;

import android.content.Context;
Expand Down Expand Up @@ -67,30 +68,30 @@ static Bitmap createLcdIdle(Context context) {
canvas.drawColor(Color.WHITE);

canvas = drawLine(canvas, 32);

if (WeatherData.received) {
// condition
canvas.save();
TextPaint paint = new TextPaint(paintSmall);
StaticLayout layout = new StaticLayout(WeatherData.condition, paint, 36, android.text.Layout.Alignment.ALIGN_NORMAL, 1.3f, 0, false);
canvas.translate(3, 40); //position the text
layout.draw(canvas);
canvas.restore();
if(!Preferences.disableWeather) {
if (WeatherData.received) {
// condition
canvas.save();
TextPaint paint = new TextPaint(paintSmall);
StaticLayout layout = new StaticLayout(WeatherData.condition, paint, 36, android.text.Layout.Alignment.ALIGN_NORMAL, 1.3f, 0, false);
canvas.translate(3, 40); //position the text
layout.draw(canvas);
canvas.restore();

// icon
Bitmap image = Utils.loadBitmapFromAssets(context, WeatherData.icon);
canvas.drawBitmap(image, 38, 37, null);
// icon
Bitmap image = Utils.loadBitmapFromAssets(context, WeatherData.icon);
canvas.drawBitmap(image, 38, 37, null);

// temperatures
canvas.drawText(WeatherData.temp, 64, 46, paintLarge);
canvas.drawText(WeatherData.tempHigh, 64, 54, paintSmall);
canvas.drawText(WeatherData.tempLow, 64, 62, paintSmall);
} else {
canvas.drawText("no data", 34, 50, paintSmall);
// temperatures
canvas.drawText(WeatherData.temp, 64, 46, paintLarge);
canvas.drawText(WeatherData.tempHigh, 64, 54, paintSmall);
canvas.drawText(WeatherData.tempLow, 64, 62, paintSmall);
} else {
canvas.drawText("no data", 34, 50, paintSmall);
}
canvas = drawLine(canvas, 64);
}

canvas = drawLine(canvas, 64);

// icons row
//Bitmap imageI = Utils.loadBitmapFromAssets(context, "idle_icons_row.bmp");
//canvas.drawBitmap(imageI, 0, 66, null);
Expand All @@ -102,21 +103,21 @@ static Bitmap createLcdIdle(Context context) {
else
rows = 2;
*/
int yPos = !Preferences.disableWeather ? 67 : 36;
// icons
for (int i = 0; i < rows; i++) {
int slotSpace = 96/rows;
int slotX = slotSpace/2-12;
int iconX = slotSpace*i + slotX;
switch (i) {
case 0:
canvas.drawBitmap(Utils.loadBitmapFromAssets(context, "idle_call.bmp"), iconX, 67, null);
canvas.drawBitmap(Utils.loadBitmapFromAssets(context, "idle_call.bmp"), iconX, yPos, null);
break;
case 1:
canvas.drawBitmap(Utils.loadBitmapFromAssets(context, "idle_sms.bmp"), iconX, 67, null);
canvas.drawBitmap(Utils.loadBitmapFromAssets(context, "idle_sms.bmp"), iconX, yPos, null);
break;
case 2:
canvas.drawBitmap(Utils.loadBitmapFromAssets(context, "idle_gmail.bmp"), iconX, 67, null);
canvas.drawBitmap(Utils.loadBitmapFromAssets(context, "idle_gmail.bmp"), iconX, yPos, null);
break;
}
}
Expand Down Expand Up @@ -145,7 +146,11 @@ static Bitmap createLcdIdle(Context context) {
int slotX = (int) (slotSpace/2-paintSmall.measureText(count)/2);
int countX = slotSpace*i + slotX;

canvas.drawText(count, countX, 92, paintSmall);
canvas.drawText(count, countX, !Preferences.disableWeather ? 92 : 62, paintSmall);
}
if(Preferences.disableWeather) {
canvas = drawLine(canvas, 64);
//Add more icons here in future.
}

/*
Expand Down
2 changes: 2 additions & 0 deletions src/org/metawatch/manager/MetaWatchService.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ static class Preferences {
public static boolean idleMusicControls = false;
public static boolean idleReplay = false;
public static boolean pauseBeforeScrolling = false;
public static boolean disableWeather = false;
}

final class WatchType {
Expand Down Expand Up @@ -169,6 +170,7 @@ public static void loadPreferences(Context context) {
Preferences.idleMusicControls = sharedPreferences.getBoolean("IdleMusicControls", Preferences.idleMusicControls);
Preferences.idleReplay = sharedPreferences.getBoolean("IdleReplay", Preferences.idleReplay);
Preferences.pauseBeforeScrolling = sharedPreferences.getBoolean("pauseBeforeScrolling", Preferences.pauseBeforeScrolling);
Preferences.disableWeather = sharedPreferences.getBoolean("DisableWeather", Preferences.disableWeather);

try {
Preferences.fontSize = Integer.valueOf(sharedPreferences.getString("FontSize", Integer.toString(Preferences.fontSize)));
Expand Down

0 comments on commit d1fa1d7

Please sign in to comment.