diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceDesignerActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceDesignerActivity.java index 5c01e775e..244841a12 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceDesignerActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceDesignerActivity.java @@ -155,6 +155,9 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem findViewById(R.id.button_set_background).setOnClickListener(this); findViewById(R.id.button_add_widget).setOnClickListener(this); findViewById(R.id.button_watchface_settings).setOnClickListener(this); + findViewById(R.id.watchface_rotate_left).setOnClickListener(this); + findViewById(R.id.watchface_rotate_right).setOnClickListener(this); + } @Override @@ -236,6 +239,18 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem } else if (v.getId() == R.id.button_watchface_settings) { showWatchfaceSettingsPopup(); } + else if (v.getId() == R.id.watchface_rotate_left) { + if (selectedBackgroundImage != null) { + selectedBackgroundImage = BitmapUtil.rotateImage(selectedBackgroundImage, -90); + renderWatchfacePreview(); + } + } + else if (v.getId() == R.id.watchface_rotate_right) { + if (selectedBackgroundImage != null) { + selectedBackgroundImage = BitmapUtil.rotateImage(selectedBackgroundImage, 90); + renderWatchfacePreview(); + } + } } @Override diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/BitmapUtil.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/BitmapUtil.java index d8dd6714e..184df4bf1 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/BitmapUtil.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/BitmapUtil.java @@ -21,6 +21,7 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.ColorMatrix; import android.graphics.ColorMatrixColorFilter; +import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; @@ -177,4 +178,16 @@ public class BitmapUtil { // Return the circular bitmap return dstBitmap; } + + /** + * Rotates a given Bitmap + * @param bitmap input bitmap + * @param degree int Degree of rotation + * @return new bitmap + */ + public static Bitmap rotateImage(Bitmap bitmap, int degree) { + Matrix matrix = new Matrix(); + matrix.postRotate(degree); + return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); + } } diff --git a/app/src/main/res/layout/activity_hybridhr_watchface_designer.xml b/app/src/main/res/layout/activity_hybridhr_watchface_designer.xml index 674b7be64..0e1c83040 100644 --- a/app/src/main/res/layout/activity_hybridhr_watchface_designer.xml +++ b/app/src/main/res/layout/activity_hybridhr_watchface_designer.xml @@ -42,17 +42,37 @@ android:text="@string/button_watchface_edit_name" /> - + android:layout_height="match_parent" + android:orientation="horizontal"> + + + + + + +