diff --git a/app/app.iml b/app/app.iml
index 22867c0..2f7fabd 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -66,14 +66,6 @@
-
-
-
-
-
-
-
-
@@ -82,8 +74,17 @@
+
+
+
+
+
+
+
+
+
@@ -105,6 +106,8 @@
+
+
diff --git a/app/build.gradle b/app/build.gradle
index 96dc9b6..eb259fa 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -8,7 +8,7 @@ android {
minSdkVersion 14
targetSdkVersion 24
versionCode 3
- versionName '1.0.7'
+ versionName '1.0.8'
}
buildTypes {
release {
diff --git a/app/src/main/java/it/lorenzo/clw/core/Core.java b/app/src/main/java/it/lorenzo/clw/core/Core.java
index 1699ea8..c06ea29 100644
--- a/app/src/main/java/it/lorenzo/clw/core/Core.java
+++ b/app/src/main/java/it/lorenzo/clw/core/Core.java
@@ -19,12 +19,14 @@
import java.util.ArrayList;
import it.lorenzo.clw.core.modules.Agenda;
+import it.lorenzo.clw.core.modules.Image;
import it.lorenzo.clw.core.modules.Module;
import it.lorenzo.clw.core.modules.OsInfo;
import it.lorenzo.clw.core.modules.SystemInfo;
import it.lorenzo.clw.core.modules.TextManager;
import it.lorenzo.clw.core.modules.TopCpu;
import it.lorenzo.clw.core.modules.TopMem;
+import it.lorenzo.clw.core.modules.Utility.BitmapWithPosition;
public class Core {
@@ -45,8 +47,8 @@ public class Core {
private Canvas c;
private ArrayList modules;
private TextManager txtMan;
- private ArrayList> drawCenter;
- private ArrayList> drawRight;
+ private ArrayList> drawCenter;
+ private ArrayList> drawRight;
private int centerLenght;
private int rightLenght;
private int bgColor = 0;
@@ -72,6 +74,7 @@ private Core() {
modules.add(new TopCpu());
modules.add(new TopMem());
modules.add(new Agenda());
+ modules.add(new Image());
drawCenter = new ArrayList<>();
drawRight = new ArrayList<>();
}
@@ -131,10 +134,10 @@ private void printText() {
Canvas c2 = new Canvas(bmp2);
txtMan.drawText(toPrint, c2, txtMan.getBoundsMarginX() / 2, bounds.height());
if (allign == 1) {
- drawCenter.add(new Pair<>(bmp2, 0));
+ drawCenter.add(new Pair<>(new BitmapWithPosition(bmp2), 0));
centerLenght += bmp2.getWidth();
} else {
- drawRight.add(new Pair<>(bmp2, 0));
+ drawRight.add(new Pair<>(new BitmapWithPosition(bmp2), 0));
rightLenght += bmp2.getWidth();
}
} else
@@ -214,40 +217,38 @@ private int drawLine(String line, float y, Context context) {
// module draw
} else if (module.check(key) == Module.Result.draw) {
printText();
- if (allign == 0) {
- Bitmap bitmap = module.GetBmp(key, params,
- maxWidth - currentX, context);
- if (bitmap != null) {
- int newHeight = Math.max(
- bitmap.getHeight(), height);
- bounds = new Rect(0, 0, bitmap.getWidth(),
- newHeight);
+ BitmapWithPosition bitmap = module.GetBmp(key, params, maxWidth - currentX, context);
+ if (!bitmap.getRelative()) {
+ c.drawBitmap(
+ bitmap.getBitmap(),
+ bitmap.getPoint().x,
+ bitmap.getPoint().y, null);
+ bounds = null;
+ } else {
+ if (allign == 0) {
+ bounds = new Rect(0, 0,
+ Math.max(bitmap.getBitmap().getWidth() + bitmap.getPoint().x, 0),
+ Math.max(bitmap.getBitmap().getHeight() + bitmap.getPoint().y, height));
float descent = txtMan.getStrokePaint().getFontMetrics().descent;
c.drawBitmap(
- bitmap,
- currentX,
- y + bounds.height() + descent
- - bitmap.getHeight(), null);
- }
- } else if (allign == 1) {
- Bitmap bitmap = module.GetBmp(key, params, maxWidth - currentX, context);
- if (bitmap != null) {
+ bitmap.getBitmap(),
+ currentX + bitmap.getPoint().x,
+ y + bounds.height() + bitmap.getPoint().y + descent
+ - bitmap.getBitmap().getHeight(), null);
+ } else if (allign == 1) {
int newHeight = Math.max(
- bitmap.getHeight(), height);
+ bitmap.getBitmap().getHeight(), height);
drawCenter.add(new Pair<>(
- bitmap, newHeight
- - bitmap.getHeight()));
- centerLenght += bitmap.getWidth();
- }
- } else {
- Bitmap bitmap = module.GetBmp(key, params, maxWidth - currentX, context);
- if (bitmap != null) {
+ bitmap, newHeight + bitmap.getPoint().y +
+ -bitmap.getBitmap().getHeight()));
+ centerLenght += bitmap.getBitmap().getWidth();
+ } else {
int newHeight = Math.max(
- bitmap.getHeight(), height);
+ bitmap.getBitmap().getHeight(), height);
drawRight.add(new Pair<>(
- bitmap, newHeight
- - bitmap.getHeight()));
- rightLenght += bitmap.getWidth();
+ bitmap, newHeight + bitmap.getPoint().y +
+ -bitmap.getBitmap().getHeight()));
+ rightLenght += bitmap.getBitmap().getWidth();
}
}
break;
@@ -266,21 +267,21 @@ private int drawLine(String line, float y, Context context) {
}
if (!toPrint.equals("") && current >= lenght)
printText();
- }
- if (bounds != null) {
- currentX += bounds.width();
- height = Math.max(height, bounds.height());
+ if (bounds != null) {
+ currentX += bounds.width();
+ height = Math.max(height, bounds.height());
+ }
}
// draw center stuff
if (!drawCenter.isEmpty()) {
int sum = 0;
- for (Pair pair : drawCenter) {
- Bitmap toDraw = pair.first;
- //Log.i("asd", "" + maxWidth + " " + centerLenght + " " + sum);
+ for (Pair pair : drawCenter) {
+ BitmapWithPosition toDraw = pair.first;
int pos = ((maxWidth - centerLenght) / 2) + sum;
- c.drawBitmap(toDraw, pos, y + pair.second, null);
- sum += toDraw.getWidth();
+ c.drawBitmap(toDraw.getBitmap(), pos + toDraw.getPoint().x, y
+ + pair.second + toDraw.getPoint().y, null);
+ sum += toDraw.getBitmap().getWidth() + toDraw.getPoint().x;
}
}
drawCenter.clear();
@@ -288,11 +289,11 @@ private int drawLine(String line, float y, Context context) {
//draw right stuff
if (!drawRight.isEmpty()) {
int sum = 0;
- for (Pair pair : drawRight) {
- Bitmap toDraw = pair.first;
- c.drawBitmap(toDraw, maxWidth - xOffsetRight - rightLenght + sum, y
- + pair.second, null);
- sum += toDraw.getWidth();
+ for (Pair pair : drawRight) {
+ BitmapWithPosition toDraw = pair.first;
+ c.drawBitmap(toDraw.getBitmap(), maxWidth - xOffsetRight - rightLenght + sum + toDraw.getPoint().x, y
+ + pair.second + toDraw.getPoint().y, null);
+ sum += toDraw.getBitmap().getWidth() + toDraw.getPoint().x;
}
}
drawRight.clear();
@@ -322,8 +323,6 @@ private void readConfigFile(String path) throws IOException {
}
}
//if (!done)
-
-
}
}
// text
diff --git a/app/src/main/java/it/lorenzo/clw/core/modules/AbstractModule.java b/app/src/main/java/it/lorenzo/clw/core/modules/AbstractModule.java
index 3ad3d5f..e13d033 100644
--- a/app/src/main/java/it/lorenzo/clw/core/modules/AbstractModule.java
+++ b/app/src/main/java/it/lorenzo/clw/core/modules/AbstractModule.java
@@ -1,7 +1,11 @@
package it.lorenzo.clw.core.modules;
+import android.content.Context;
+
import java.util.HashMap;
+import it.lorenzo.clw.core.modules.Utility.BitmapWithPosition;
+
/**
* Created by lorenzo on 21/02/15.
*/
@@ -24,4 +28,9 @@ public Result check(String key) {
return Result.no;
return res;
}
+
+ @Override
+ public BitmapWithPosition GetBmp(String key, String[] params, int maxWidth, Context context) {
+ return null;
+ }
}
diff --git a/app/src/main/java/it/lorenzo/clw/core/modules/AbstractTop.java b/app/src/main/java/it/lorenzo/clw/core/modules/AbstractTop.java
index d47c277..5644dfd 100644
--- a/app/src/main/java/it/lorenzo/clw/core/modules/AbstractTop.java
+++ b/app/src/main/java/it/lorenzo/clw/core/modules/AbstractTop.java
@@ -3,13 +3,13 @@
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.PackageManager;
-import android.graphics.Bitmap;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import it.lorenzo.clw.core.modules.Utility.BitmapWithPosition;
import it.lorenzo.clw.core.modules.Utility.CommonUtility;
/**
@@ -111,7 +111,7 @@ public void initialize(Context context) {
}
@Override
- public Bitmap GetBmp(String key, String[] params, int maxWidth, Context context) {
+ public BitmapWithPosition GetBmp(String key, String[] params, int maxWidth, Context context) {
return null;
}
diff --git a/app/src/main/java/it/lorenzo/clw/core/modules/Agenda.java b/app/src/main/java/it/lorenzo/clw/core/modules/Agenda.java
index 924f1f2..daec999 100644
--- a/app/src/main/java/it/lorenzo/clw/core/modules/Agenda.java
+++ b/app/src/main/java/it/lorenzo/clw/core/modules/Agenda.java
@@ -3,7 +3,6 @@
import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
-import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.provider.CalendarContract;
@@ -15,6 +14,8 @@
import java.util.GregorianCalendar;
import java.util.Locale;
+import it.lorenzo.clw.core.modules.Utility.BitmapWithPosition;
+
/**
* Created by lorenzo on 24/03/15.
*/
@@ -146,7 +147,7 @@ public void changeSetting(String key, String[] params, Context context) {
}
@Override
- public Bitmap GetBmp(String key, String[] params, int maxWidth, Context context) {
+ public BitmapWithPosition GetBmp(String key, String[] params, int maxWidth, Context context) {
return null;
}
diff --git a/app/src/main/java/it/lorenzo/clw/core/modules/Image.java b/app/src/main/java/it/lorenzo/clw/core/modules/Image.java
new file mode 100644
index 0000000..c841382
--- /dev/null
+++ b/app/src/main/java/it/lorenzo/clw/core/modules/Image.java
@@ -0,0 +1,74 @@
+package it.lorenzo.clw.core.modules;
+
+import android.content.Context;
+import android.graphics.BitmapFactory;
+import android.graphics.Point;
+
+import java.util.StringTokenizer;
+
+import it.lorenzo.clw.core.modules.Utility.BitmapWithPosition;
+
+
+/**
+ * Created by lorenzo on 09/11/16.
+ */
+
+public class Image extends AbstractModule {
+
+ public static final String IMAGE = "image";
+
+ public Image() {
+ keys.put(IMAGE, Result.draw);
+ }
+
+ @Override
+ public BitmapWithPosition GetBmp(String key, String[] params, int maxWidth, Context context) {
+ BitmapWithPosition bmp = new BitmapWithPosition();
+ bmp.setPoint(new Point(0, 0));
+ if (key.equals(IMAGE)) {
+ bmp.setBitmap(BitmapFactory.decodeFile(params[0]));
+ for (int i = 1; i < params.length; i++) {
+
+ StringTokenizer str;
+ switch (params[i]) {
+ case "p":
+ str = new StringTokenizer(params[i + 1], ",");
+ if (str.countTokens() > 1)
+ bmp.setPoint(new Point(Integer.parseInt(str.nextToken()), Integer.parseInt(str.nextToken())));
+ break;
+ case "s":
+ str = new StringTokenizer(params[i + 1], "x");
+ if (str.countTokens() > 1) {
+ bmp.setBitmap(android.graphics.Bitmap.createScaledBitmap(bmp.getBitmap(),
+ Integer.parseInt(str.nextToken()),
+ Integer.parseInt(str.nextToken()),
+ false));
+ }
+ break;
+ case "relative":
+ bmp.setRelative(true);
+ break;
+ case "fixed":
+ bmp.setRelative(false);
+ break;
+ }
+ }
+ }
+ return bmp;
+ }
+
+ @Override
+ public void initialize(Context context) {
+
+ }
+
+ @Override
+ public void changeSetting(String key, String[] params, Context context) {
+
+ }
+
+ @Override
+ public String getString(String key, String[] params, Context context) {
+ return null;
+ }
+}
diff --git a/app/src/main/java/it/lorenzo/clw/core/modules/Module.java b/app/src/main/java/it/lorenzo/clw/core/modules/Module.java
index 2a5fe6b..f15c18a 100644
--- a/app/src/main/java/it/lorenzo/clw/core/modules/Module.java
+++ b/app/src/main/java/it/lorenzo/clw/core/modules/Module.java
@@ -5,7 +5,8 @@
*/
import android.content.Context;
-import android.graphics.Bitmap;
+
+import it.lorenzo.clw.core.modules.Utility.BitmapWithPosition;
public interface Module {
@@ -15,7 +16,7 @@ public interface Module {
void changeSetting(String key, String[] params, Context context);
- Bitmap GetBmp(String key, String[] params, int maxWidth, Context context);
+ BitmapWithPosition GetBmp(String key, String[] params, int maxWidth, Context context);
void initialize(Context context);
diff --git a/app/src/main/java/it/lorenzo/clw/core/modules/OsInfo.java b/app/src/main/java/it/lorenzo/clw/core/modules/OsInfo.java
index 1fe8760..c94f3bb 100644
--- a/app/src/main/java/it/lorenzo/clw/core/modules/OsInfo.java
+++ b/app/src/main/java/it/lorenzo/clw/core/modules/OsInfo.java
@@ -1,9 +1,9 @@
package it.lorenzo.clw.core.modules;
import android.content.Context;
-import android.graphics.Bitmap;
import android.os.Build;
+import it.lorenzo.clw.core.modules.Utility.BitmapWithPosition;
import it.lorenzo.clw.core.modules.Utility.CommonUtility;
/**
@@ -74,7 +74,7 @@ public void changeSetting(String key, String[] params, Context context) {
}
@Override
- public Bitmap GetBmp(String key, String[] params, int maxWidth, Context context) {
+ public BitmapWithPosition GetBmp(String key, String[] params, int maxWidth, Context context) {
return null;
}
diff --git a/app/src/main/java/it/lorenzo/clw/core/modules/SystemInfo.java b/app/src/main/java/it/lorenzo/clw/core/modules/SystemInfo.java
index 14838b4..17749c1 100644
--- a/app/src/main/java/it/lorenzo/clw/core/modules/SystemInfo.java
+++ b/app/src/main/java/it/lorenzo/clw/core/modules/SystemInfo.java
@@ -9,7 +9,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.graphics.Bitmap;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
@@ -28,6 +27,7 @@
import java.util.regex.Pattern;
import it.lorenzo.clw.core.modules.Utility.BarDrawer;
+import it.lorenzo.clw.core.modules.Utility.BitmapWithPosition;
import it.lorenzo.clw.core.modules.Utility.CommonUtility;
public class SystemInfo extends AbstractModule {
@@ -137,7 +137,7 @@ public void initialize(Context context) {
}
@Override
- public Bitmap GetBmp(String key, String[] params, int maxWidth, Context context) {
+ public BitmapWithPosition GetBmp(String key, String[] params, int maxWidth, Context context) {
try {
int start = 0;
if (key.equals(FS_BAR))
diff --git a/app/src/main/java/it/lorenzo/clw/core/modules/TextManager.java b/app/src/main/java/it/lorenzo/clw/core/modules/TextManager.java
index 35b7260..39e1dd2 100644
--- a/app/src/main/java/it/lorenzo/clw/core/modules/TextManager.java
+++ b/app/src/main/java/it/lorenzo/clw/core/modules/TextManager.java
@@ -5,7 +5,6 @@
*/
import android.content.Context;
-import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
@@ -14,6 +13,8 @@
import android.graphics.Rect;
import android.graphics.Typeface;
+import it.lorenzo.clw.core.modules.Utility.BitmapWithPosition;
+
public class TextManager implements Module {
public static final String FONT_SIZE = "fontSize";
@@ -325,7 +326,7 @@ public void initialize(Context context) {
}
@Override
- public Bitmap GetBmp(String key, String[] params, int maxWidth, Context context) {
+ public BitmapWithPosition GetBmp(String key, String[] params, int maxWidth, Context context) {
return null;
}
diff --git a/app/src/main/java/it/lorenzo/clw/core/modules/Utility/BarDrawer.java b/app/src/main/java/it/lorenzo/clw/core/modules/Utility/BarDrawer.java
index c6ba379..552194b 100644
--- a/app/src/main/java/it/lorenzo/clw/core/modules/Utility/BarDrawer.java
+++ b/app/src/main/java/it/lorenzo/clw/core/modules/Utility/BarDrawer.java
@@ -14,8 +14,8 @@
public class BarDrawer {
- static public Bitmap getBar(int width, int height, TextManager txtMan,
- int percent) {
+ static public BitmapWithPosition getBar(int width, int height, TextManager txtMan,
+ int percent) {
Paint fillPaint = txtMan.getFillPaint();
Paint.FontMetrics fontMetrics = fillPaint.getFontMetrics();
float descent = fontMetrics.descent;
@@ -47,6 +47,6 @@ static public Bitmap getBar(int width, int height, TextManager txtMan,
fillPaint.setStyle(Paint.Style.STROKE);
c.drawRect(x1, y1, x2, y2, fillPaint);
- return bmp;
+ return new BitmapWithPosition(bmp);
}
}
diff --git a/app/src/main/java/it/lorenzo/clw/core/modules/Utility/BitmapWithPosition.java b/app/src/main/java/it/lorenzo/clw/core/modules/Utility/BitmapWithPosition.java
new file mode 100644
index 0000000..702916d
--- /dev/null
+++ b/app/src/main/java/it/lorenzo/clw/core/modules/Utility/BitmapWithPosition.java
@@ -0,0 +1,58 @@
+package it.lorenzo.clw.core.modules.Utility;
+
+import android.graphics.Bitmap;
+import android.graphics.Point;
+
+/**
+ * Created by lorenzo on 09/11/16.
+ */
+
+public class BitmapWithPosition {
+
+ private boolean relative;
+ private Point point;
+ private Bitmap bmp;
+
+ public BitmapWithPosition() {
+ relative = true;
+ }
+
+ public BitmapWithPosition(Bitmap bmp) {
+ this(bmp, new Point(0, 0), true);
+ }
+
+ public BitmapWithPosition(Bitmap bmp, Point point) {
+ this(bmp, point, true);
+ }
+
+ public BitmapWithPosition(Bitmap bmp, Point point, boolean relative) {
+ this.bmp = bmp;
+ this.point = point;
+ this.relative = relative;
+ }
+
+ public boolean getRelative() {
+ return relative;
+ }
+
+ public void setRelative(boolean relative) {
+ this.relative = relative;
+ }
+
+ public Point getPoint() {
+ return point;
+ }
+
+ public void setPoint(Point point) {
+ this.point = point;
+ }
+
+ public Bitmap getBitmap() {
+ return bmp;
+ }
+
+ public void setBitmap(Bitmap bitmap) {
+ this.bmp = bitmap;
+ }
+
+}
diff --git a/build.gradle b/build.gradle
index 573f4fd..ef7ae5a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.2.1'
+ classpath 'com.android.tools.build:gradle:2.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/release/clw-1.0.8.apk b/release/clw-1.0.8.apk
new file mode 100644
index 0000000..0b2dc48
Binary files /dev/null and b/release/clw-1.0.8.apk differ