1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-24 02:46:50 +01:00

Fossil Hybrid HR: Confirm overwriting cached watchface

This commit is contained in:
Arjan Schrijver 2021-07-21 21:27:58 +02:00
parent fb02fa2ee0
commit dcf869b988
2 changed files with 26 additions and 5 deletions

View File

@ -71,6 +71,7 @@ import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractGBActivity;
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp;
import nodomain.freeyourgadget.gadgetbridge.util.BitmapUtil;
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
@ -151,7 +152,6 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
int id = item.getItemId();
if (id == R.id.button_save_watchface) {
sendToWatch(false);
finish();
} else if (id == R.id.button_preview_watchface) {
sendToWatch(true);
}
@ -603,18 +603,38 @@ public class HybridHRWatchfaceDesignerActivity extends AbstractGBActivity implem
bos.write(wfFactory.getWapp(this));
bos.close();
fos.close();
Uri tempAppFileUri = Uri.fromFile(tempFile);
GBApplication.deviceService().onInstallApp(tempAppFileUri);
final Uri tempAppFileUri = Uri.fromFile(tempFile);
if (preview) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
GBApplication.deviceService().onInstallApp(tempAppFileUri);
GBApplication.deviceService().onAppDelete(UUID.nameUUIDFromBytes("previewWatchface".getBytes(StandardCharsets.UTF_8)));
}
}, 10000);
} else {
FossilFileReader fossilFile = new FossilFileReader(tempAppFileUri, this);
FossilHRInstallHandler.saveAppInCache(fossilFile, processedBackgroundImage, mCoordinator, this);
final FossilFileReader fossilFile = new FossilFileReader(tempAppFileUri, this);
GBDeviceApp app = fossilFile.getGBDeviceApp();
File cacheDir = mCoordinator.getAppCacheDir();
File destFile = new File(cacheDir, app.getUUID().toString() + mCoordinator.getAppFileExtension());
if (destFile.exists()) {
new AlertDialog.Builder(this)
.setMessage(R.string.watchface_cache_confirm_overwrite)
.setNegativeButton(R.string.no, null)
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
GBApplication.deviceService().onInstallApp(tempAppFileUri);
FossilHRInstallHandler.saveAppInCache(fossilFile, processedBackgroundImage, mCoordinator, HybridHRWatchfaceDesignerActivity.this);
finish();
}
})
.show();
} else {
GBApplication.deviceService().onInstallApp(tempAppFileUri);
FossilHRInstallHandler.saveAppInCache(fossilFile, processedBackgroundImage, mCoordinator, HybridHRWatchfaceDesignerActivity.this);
finish();
}
}
} catch (IOException e) {
LOG.warn("Error while creating and uploading watchface", e);

View File

@ -1241,4 +1241,5 @@
<string name="watchface_setting_wrist_flick_hour">Hour hand (-360 to 360):</string>
<string name="watchface_setting_wrist_flick_minute">Minute hand (-360 to 360):</string>
<string name="watchface_setting_wrist_flick_duration">Duration (in ms):</string>
<string name="watchface_cache_confirm_overwrite">A watchface with this name already exists in the cache. Do you want to overwrite it?</string>
</resources>