mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-29 13:26:50 +01:00
add_rotate_watchface_button_hybridhr (#2408)
This adds a button which rotates the selected watchface by 90 degrees counter-clockwise to the hybridqr. I did not manage to fix the autoorientation. Reviewed-on: https://codeberg.org/Freeyourgadget/Gadgetbridge/pulls/2408 Co-authored-by: HelloCodeberg <hellocodeberg@noreply.codeberg.org> Co-committed-by: HelloCodeberg <hellocodeberg@noreply.codeberg.org>
This commit is contained in:
parent
9168c46afe
commit
ca4f996e9b
@ -155,6 +155,9 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
|
|||||||
findViewById(R.id.button_set_background).setOnClickListener(this);
|
findViewById(R.id.button_set_background).setOnClickListener(this);
|
||||||
findViewById(R.id.button_add_widget).setOnClickListener(this);
|
findViewById(R.id.button_add_widget).setOnClickListener(this);
|
||||||
findViewById(R.id.button_watchface_settings).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
|
@Override
|
||||||
@ -236,6 +239,18 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
|
|||||||
} else if (v.getId() == R.id.button_watchface_settings) {
|
} else if (v.getId() == R.id.button_watchface_settings) {
|
||||||
showWatchfaceSettingsPopup();
|
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
|
@Override
|
||||||
|
@ -21,6 +21,7 @@ import android.graphics.Bitmap;
|
|||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.ColorMatrix;
|
import android.graphics.ColorMatrix;
|
||||||
import android.graphics.ColorMatrixColorFilter;
|
import android.graphics.ColorMatrixColorFilter;
|
||||||
|
import android.graphics.Matrix;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.PorterDuffXfermode;
|
import android.graphics.PorterDuffXfermode;
|
||||||
@ -177,4 +178,16 @@ public class BitmapUtil {
|
|||||||
// Return the circular bitmap
|
// Return the circular bitmap
|
||||||
return dstBitmap;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,17 +42,37 @@
|
|||||||
android:text="@string/button_watchface_edit_name" />
|
android:text="@string/button_watchface_edit_name" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/watchface_invert_colors"
|
android:id="@+id/watchface_invert_colors"
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:layout_alignStart="@+id/watchface_preview_layout"
|
|
||||||
app:srcCompat="@drawable/ic_invert_colors" />
|
app:srcCompat="@drawable/ic_invert_colors" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/watchface_rotate_left"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:layout_alignStart="@+id/watchface_invert_colors"
|
||||||
|
app:srcCompat="@drawable/ic_rotate_left" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/watchface_rotate_right"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:layout_alignStart="@+id/watchface_rotate_left"
|
||||||
|
android:rotationY="180"
|
||||||
|
app:srcCompat="@drawable/ic_rotate_left" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/watchface_preview_layout"
|
android:id="@+id/watchface_preview_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Loading…
Reference in New Issue
Block a user