Skip to content

Commit

Permalink
Patch some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
norkator committed Oct 29, 2020
1 parent 515cc71 commit 5454b72
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
targetSdkVersion 29

versionCode 29
versionName "1.5.5" // Use Semver
versionName "1.5.6" // Use Semver
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down Expand Up @@ -39,5 +39,5 @@ dependencies {
implementation 'com.google.android.material:material:1.2.1'
implementation 'joda-time:joda-time:2.10.5'
// For the notifications
implementation 'com.google.firebase:firebase-messaging:20.3.0'
implementation 'com.google.firebase:firebase-messaging:21.0.0'
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/nitramite/apcupsdmonitor/UPS.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ else if (line.contains("Status of UPS")) {
// Helper to clean results
private String getCleanLine(final String line, final String containing) {
String[] split = line.split(": "); // See : and space, important
return split[1]; //.substring(1, split[1].length()); // Does not get simpler than this
return split.length > 0 ? split[1] : "";
}


Expand Down
19 changes: 12 additions & 7 deletions app/src/main/java/com/nitramite/apcupsdmonitor/Widget.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,18 @@ private Bitmap createUpsViewBitmap(Context context, ArrayList<UPS> upsArrayList)


private static Bitmap getBitmapFromView(View view) {
view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
Bitmap bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(),
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
view.draw(canvas);
return bitmap;
try {
view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
Bitmap bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(),
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
view.draw(canvas);
return bitmap;
} catch (IllegalArgumentException e) {
Log.i(TAG, e.toString());
return null;
}
}


Expand Down

0 comments on commit 5454b72

Please sign in to comment.