mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-29 13:26:50 +01:00
Fossil Hybrid HR: Add button for removing the watchface background image
This commit is contained in:
parent
21ea7b6cc2
commit
c15833f149
@ -159,7 +159,7 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
|
||||
findViewById(R.id.button_watchface_settings).setOnClickListener(this);
|
||||
findViewById(R.id.watchface_rotate_left).setOnClickListener(this);
|
||||
findViewById(R.id.watchface_rotate_right).setOnClickListener(this);
|
||||
|
||||
findViewById(R.id.watchface_remove_image).setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -242,18 +242,19 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
|
||||
showWidgetEditPopup(-1);
|
||||
} else if (v.getId() == R.id.button_watchface_settings) {
|
||||
showWatchfaceSettingsPopup();
|
||||
}
|
||||
else if (v.getId() == R.id.watchface_rotate_left) {
|
||||
} 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) {
|
||||
} else if (v.getId() == R.id.watchface_rotate_right) {
|
||||
if (selectedBackgroundImage != null) {
|
||||
selectedBackgroundImage = BitmapUtil.rotateImage(selectedBackgroundImage, 90);
|
||||
renderWatchfacePreview();
|
||||
}
|
||||
} else if (v.getId() == R.id.watchface_remove_image) {
|
||||
deleteWatchfaceBackground();
|
||||
renderWatchfacePreview();
|
||||
}
|
||||
}
|
||||
|
||||
@ -453,15 +454,7 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
|
||||
}
|
||||
}
|
||||
if (selectedBackgroundImage == null) {
|
||||
processedBackgroundImage = Bitmap.createBitmap(displayImageSize, displayImageSize, Bitmap.Config.ARGB_8888);
|
||||
// Paint a gray circle around the watchface
|
||||
Canvas backgroundImageCanvas = new Canvas(processedBackgroundImage);
|
||||
Paint circlePaint = new Paint();
|
||||
circlePaint.setColor(Color.GRAY);
|
||||
circlePaint.setAntiAlias(true);
|
||||
circlePaint.setStrokeWidth(3);
|
||||
circlePaint.setStyle(Paint.Style.STROKE);
|
||||
backgroundImageCanvas.drawCircle(displayImageSize/2f + 2, displayImageSize/2f + 2, displayImageSize/2f - 5, circlePaint);
|
||||
deleteWatchfaceBackground();
|
||||
} else {
|
||||
processedBackgroundImage = Bitmap.createScaledBitmap(selectedBackgroundImage, displayImageSize, displayImageSize, true);
|
||||
}
|
||||
@ -482,6 +475,14 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
|
||||
onlyPreviewIsRemaining = true;
|
||||
}
|
||||
}
|
||||
// Paint a gray circle around the watchface
|
||||
Canvas backgroundImageCanvas = new Canvas(processedBackgroundImage);
|
||||
Paint circlePaint = new Paint();
|
||||
circlePaint.setColor(Color.GRAY);
|
||||
circlePaint.setAntiAlias(true);
|
||||
circlePaint.setStrokeWidth(3);
|
||||
circlePaint.setStyle(Paint.Style.STROKE);
|
||||
backgroundImageCanvas.drawCircle(displayImageSize/2f, displayImageSize/2f, displayImageSize/2f - 2, circlePaint);
|
||||
// Dynamically add an ImageView for each widget
|
||||
Paint widgetPaint = new Paint();
|
||||
widgetPaint.setColor(Color.RED);
|
||||
@ -695,6 +696,12 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
|
||||
return BitmapUtil.convertToGrayscale(BitmapUtil.getCircularBitmap(bitmap));
|
||||
}
|
||||
|
||||
private void deleteWatchfaceBackground() {
|
||||
selectedBackgroundImage = Bitmap.createBitmap(displayImageSize, displayImageSize, Bitmap.Config.ARGB_8888);
|
||||
selectedBackgroundImage.eraseColor(Color.BLACK);
|
||||
selectedBackgroundImage = BitmapUtil.getCircularBitmap(selectedBackgroundImage);
|
||||
}
|
||||
|
||||
private void sendToWatch(boolean preview) {
|
||||
HybridHRWatchfaceFactory wfFactory;
|
||||
if (preview) {
|
||||
|
10
app/src/main/res/drawable/ic_remove_image.xml
Normal file
10
app/src/main/res/drawable/ic_remove_image.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="#7E7E7E">
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M21.9,21.9l-8.49,-8.49l0,0L3.59,3.59l0,0L2.1,2.1L0.69,3.51L3,5.83V19c0,1.1 0.9,2 2,2h13.17l2.31,2.31L21.9,21.9zM5,18l3.5,-4.5l2.5,3.01L12.17,15l3,3H5zM21,18.17L5.83,3H19c1.1,0 2,0.9 2,2V18.17z"/>
|
||||
</vector>
|
@ -67,6 +67,13 @@
|
||||
android:layout_alignStart="@+id/watchface_rotate_left"
|
||||
android:rotationY="180"
|
||||
app:srcCompat="@drawable/ic_rotate_left" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/watchface_remove_image"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignStart="@+id/watchface_rotate_right"
|
||||
app:srcCompat="@drawable/ic_remove_image" />
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
|
Loading…
Reference in New Issue
Block a user