Fossil Hybrid HR: Add icon for inverting colors of background image

This commit is contained in:
Arjan Schrijver 2021-07-22 13:09:00 +02:00
parent c91403fce3
commit ba5c87e7a8
3 changed files with 44 additions and 7 deletions

View File

@ -87,6 +87,7 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
private String watchfaceName = "NewWatchface";
final private ArrayList<HybridHRWatchfaceWidget> widgets = new ArrayList<>();
private HybridHRWatchfaceSettings watchfaceSettings = new HybridHRWatchfaceSettings();
private int defaultWidgetColor = HybridHRWatchfaceWidget.COLOR_WHITE;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -114,6 +115,7 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
backgroundImageView.setOnDragListener(this);
findViewById(R.id.watchface_widget_delete_droparea).setOnDragListener(this);
findViewById(R.id.watchface_invert_colors).setOnClickListener(this);
findViewById(R.id.button_edit_name).setOnClickListener(this);
findViewById(R.id.button_set_background).setOnClickListener(this);
findViewById(R.id.button_add_widget).setOnClickListener(this);
@ -179,6 +181,16 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
})
.setTitle(R.string.watchface_dialog_title_set_name)
.show();
} else if (v.getId() == R.id.watchface_invert_colors) {
if (selectedBackgroundImage != null) {
selectedBackgroundImage = BitmapUtil.invertBitmapColors(selectedBackgroundImage);
renderWatchfacePreview();
if (defaultWidgetColor == HybridHRWatchfaceWidget.COLOR_WHITE) {
defaultWidgetColor = HybridHRWatchfaceWidget.COLOR_BLACK;
} else {
defaultWidgetColor = HybridHRWatchfaceWidget.COLOR_WHITE;
}
}
} else if (v.getId() == R.id.button_set_background) {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
@ -437,6 +449,8 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
colorSpinner.setAdapter(widgetColorAdapter);
if (widget != null) {
colorSpinner.setSelection(widget.getColor());
} else {
colorSpinner.setSelection(defaultWidgetColor);
}
// Set X coordinate
final EditText posX = layout.findViewById(R.id.watchface_widget_pos_x);

View 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="#FF000000"
android:pathData="M17.66,7.93L12,2.27 6.34,7.93c-3.12,3.12 -3.12,8.19 0,11.31C7.9,20.8 9.95,21.58 12,21.58c2.05,0 4.1,-0.78 5.66,-2.34 3.12,-3.12 3.12,-8.19 0,-11.31zM12,19.59c-1.6,0 -3.11,-0.62 -4.24,-1.76C6.62,16.69 6,15.19 6,13.59s0.62,-3.11 1.76,-4.24L12,5.1v14.49z"/>
</vector>

View File

@ -34,16 +34,29 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/watchface_preview_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp">
android:layout_height="wrap_content">
<ImageView
android:id="@+id/hybridhr_background_image"
android:layout_width="wrap_content"
android:id="@+id/watchface_invert_colors"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignStart="@+id/watchface_preview_layout"
app:srcCompat="@drawable/ic_invert_colors" />
<RelativeLayout
android:id="@+id/watchface_preview_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" />
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp">
<ImageView
android:id="@+id/hybridhr_background_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout