1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-04 09:17:29 +01:00

Fossil HR: added button to delete background

This commit is contained in:
Daniel Dakhno 2020-04-08 03:20:39 +02:00
parent 379fa746a3
commit bbf60248c3
3 changed files with 40 additions and 11 deletions

View File

@ -125,6 +125,15 @@ public class HRConfigActivity extends AbstractGBActivity implements View.OnClick
} }
}); });
findViewById(R.id.qhybrid_unset_background).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(QHybridSupport.QHYBRID_COMMAND_SET_BACKGROUND_IMAGE);
intent.putIntegerArrayListExtra("EXTRA_PIXELS", null);
LocalBroadcastManager.getInstance(HRConfigActivity.this).sendBroadcast(intent);
}
});
for (int i = 0; i < widgetButtonsMapping.size(); i++) { for (int i = 0; i < widgetButtonsMapping.size(); i++) {
final int widgetButtonId = widgetButtonsMapping.keyAt(i); final int widgetButtonId = widgetButtonsMapping.keyAt(i);
findViewById(widgetButtonId).setOnClickListener(new View.OnClickListener() { findViewById(widgetButtonId).setOnClickListener(new View.OnClickListener() {

View File

@ -187,13 +187,18 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
@Override @Override
public void setBackgroundImage(byte[] pixels) { public void setBackgroundImage(byte[] pixels) {
this.backGroundImage = AssetImageFactory.createAssetImage(pixels, 0, 0, 0); if(pixels == null){
try { getBackgroundFile().delete();
FileOutputStream fos = new FileOutputStream(getBackgroundFile(), false); this.backGroundImage = null;
fos.write(pixels); }else{
} catch (IOException e) { this.backGroundImage = AssetImageFactory.createAssetImage(pixels, 0, 0, 0);
GB.log("error saving background", GB.ERROR, e); try {
GB.toast("error persistent saving background", Toast.LENGTH_LONG, GB.ERROR); FileOutputStream fos = new FileOutputStream(getBackgroundFile(), false);
fos.write(pixels);
} catch (IOException e) {
GB.log("error saving background", GB.ERROR, e);
GB.toast("error persistent saving background", Toast.LENGTH_LONG, GB.ERROR);
}
} }
renderWidgets(); renderWidgets();
} }

View File

@ -96,11 +96,26 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="add widget" /> android:text="add widget" />
<LinearLayout
<Button
android:id="@+id/qhybrid_set_background"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="set background" /> android:weightSum="2"
android:orientation="horizontal">
<Button
android:id="@+id/qhybrid_unset_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="delete background"
android:layout_weight="1"/>
<Button
android:id="@+id/qhybrid_set_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="set background"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout> </LinearLayout>