mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Add FileInstallerActivity
This commit is contained in:
parent
d4e34c5982
commit
0c876f2c86
@ -211,6 +211,11 @@
|
||||
android:name=".activities.FwAppInstallerActivity"
|
||||
android:label="@string/title_activity_fw_app_insaller"
|
||||
android:parentActivityName=".activities.ControlCenterv2"
|
||||
android:exported="true" />
|
||||
<activity
|
||||
android:name=".activities.FileInstallerActivity"
|
||||
android:label="@string/title_activity_file_installer"
|
||||
android:parentActivityName=".activities.ControlCenterv2"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
@ -0,0 +1,129 @@
|
||||
/* Copyright (C) 2015-2024 Andreas Shimokawa, Carsten Pfeiffer, Daniel
|
||||
Dakhno, Daniele Gobbetti, José Rebelo, Lem Dulfo, Petr Vaněk, Taavi Eomäe
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.activities;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
|
||||
/**
|
||||
* An entrypoint activity to install a file to a device. This activity will find the compatible
|
||||
* {@link InstallHandler} and pass the corresponding {@link DeviceType} to the corresponding install
|
||||
* activity.
|
||||
*/
|
||||
public class FileInstallerActivity extends AbstractGBActivity {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(FileInstallerActivity.class);
|
||||
|
||||
private Uri uri;
|
||||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_file_installer);
|
||||
|
||||
uri = getIntent().getData();
|
||||
if (uri == null) { // For "share" intent
|
||||
uri = getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
}
|
||||
|
||||
new FindInstallHandlerTask().execute(uri);
|
||||
}
|
||||
|
||||
private List<DeviceType> getAllDeviceTypesConnectedFirst() {
|
||||
final Set<DeviceCoordinator> connectedCoordinators = GBApplication.app().getDeviceManager()
|
||||
.getSelectedDevices().stream()
|
||||
.filter(GBDevice::isConnected)
|
||||
.map(GBDevice::getDeviceCoordinator)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
return Arrays.stream(DeviceType.values())
|
||||
.sorted((d1, d2) -> {
|
||||
final DeviceCoordinator c1 = d1.getDeviceCoordinator();
|
||||
final DeviceCoordinator c2 = d2.getDeviceCoordinator();
|
||||
if (connectedCoordinators.contains(c1)) {
|
||||
return -1;
|
||||
} else if (connectedCoordinators.contains(c2)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private class FindInstallHandlerTask extends AsyncTask<Uri, Void, FindInstallHandlerTask.Result> {
|
||||
@Override
|
||||
protected Result doInBackground(final Uri... uris) {
|
||||
for (final DeviceType deviceType : getAllDeviceTypesConnectedFirst()) {
|
||||
final DeviceCoordinator coordinator = deviceType.getDeviceCoordinator();
|
||||
final InstallHandler handler = coordinator.findInstallHandler(uris[0], FileInstallerActivity.this);
|
||||
if (handler != null) {
|
||||
LOG.info("Found install handler {} from {}", handler.getClass(), coordinator.getClass());
|
||||
return new Result(deviceType, handler);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final Result result) {
|
||||
final Intent intent;
|
||||
if (result != null) {
|
||||
if (result.installHandler.getInstallActivity() != null) {
|
||||
intent = new Intent(FileInstallerActivity.this, result.installHandler.getInstallActivity());
|
||||
} else {
|
||||
intent = new Intent(FileInstallerActivity.this, FwAppInstallerActivity.class);
|
||||
}
|
||||
intent.putExtra(FwAppInstallerActivity.EXTRA_DEVICE_TYPE_NAME, result.deviceType.name());
|
||||
} else {
|
||||
intent = new Intent(FileInstallerActivity.this, FwAppInstallerActivity.class);
|
||||
}
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME);
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(uri, null);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
private class Result {
|
||||
private final DeviceType deviceType;
|
||||
private final InstallHandler installHandler;
|
||||
|
||||
private Result(final DeviceType deviceType, final InstallHandler installHandler) {
|
||||
this.deviceType = deviceType;
|
||||
this.installHandler = installHandler;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -33,6 +33,7 @@ import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.NavUtils;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
@ -53,7 +54,6 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ItemWithDetails;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
|
||||
@ -62,6 +62,8 @@ public class FwAppInstallerActivity extends AbstractGBActivity implements Instal
|
||||
private static final Logger LOG = LoggerFactory.getLogger(FwAppInstallerActivity.class);
|
||||
private static final String ITEM_DETAILS = "details";
|
||||
|
||||
public static final String EXTRA_DEVICE_TYPE_NAME = "deviceTypeName";
|
||||
|
||||
private TextView fwAppInstallTextView;
|
||||
private ImageView previewImage;
|
||||
private Button installButton;
|
||||
@ -214,14 +216,24 @@ public class FwAppInstallerActivity extends AbstractGBActivity implements Instal
|
||||
if (uri == null) { // For "share" intent
|
||||
uri = getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
}
|
||||
installHandler = findInstallHandlerFor(uri);
|
||||
if (device != null) {
|
||||
installHandler = device.getDeviceCoordinator().findInstallHandler(uri, this);
|
||||
} else {
|
||||
String deviceTypeName = getIntent().getStringExtra(EXTRA_DEVICE_TYPE_NAME);
|
||||
if (deviceTypeName != null) {
|
||||
installHandler = DeviceType.fromName(deviceTypeName).getDeviceCoordinator().findInstallHandler(uri, this);
|
||||
} else {
|
||||
installHandler = findInstallHandlerFor(uri);
|
||||
}
|
||||
}
|
||||
|
||||
if (installHandler == null) {
|
||||
setInfoText(getString(R.string.installer_activity_unable_to_find_handler));
|
||||
} else {
|
||||
setInfoText(getString(R.string.installer_activity_wait_while_determining_status));
|
||||
|
||||
List<GBDevice> selectedDevices = GBApplication.app().getDeviceManager().getSelectedDevices();
|
||||
if(selectedDevices.size() == 0){
|
||||
if(selectedDevices.isEmpty()){
|
||||
GB.toast(getString(R.string.open_fw_installer_connect_minimum_one_device), Toast.LENGTH_LONG, GB.ERROR);
|
||||
finish();
|
||||
return;
|
||||
@ -243,7 +255,7 @@ public class FwAppInstallerActivity extends AbstractGBActivity implements Instal
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putParcelableArrayList(ITEM_DETAILS, details);
|
||||
}
|
||||
@ -271,14 +283,10 @@ public class FwAppInstallerActivity extends AbstractGBActivity implements Instal
|
||||
List<GBDevice> devices = deviceManager.getSelectedDevices();
|
||||
for(GBDevice connectedDevice : devices){
|
||||
if (connectedDevice.isConnected()) {
|
||||
DeviceCoordinator coordinator = connectedDevice.getDeviceCoordinator();
|
||||
if (coordinator != null) {
|
||||
connectedCoordinators.add(coordinator);
|
||||
}
|
||||
connectedCoordinators.add(connectedDevice.getDeviceCoordinator());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sortedCoordinators.addAll(connectedCoordinators);
|
||||
for (DeviceCoordinator coordinator : allCoordinators) {
|
||||
if (!connectedCoordinators.contains(coordinator)) {
|
||||
|
@ -209,6 +209,7 @@ public class AppManagerActivity extends AbstractGBFragmentActivity {
|
||||
super.onActivityResult(requestCode, resultCode, resultData);
|
||||
if (requestCode == READ_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
|
||||
Intent startIntent = new Intent(AppManagerActivity.this, FwAppInstallerActivity.class);
|
||||
startIntent.putExtra(GBDevice.EXTRA_DEVICE, mGBDevice);
|
||||
startIntent.setAction(Intent.ACTION_VIEW);
|
||||
startIntent.setDataAndType(resultData.getData(), null);
|
||||
startActivity(startIntent);
|
||||
|
@ -16,6 +16,8 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
|
||||
@ -25,6 +27,8 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
*/
|
||||
public interface InstallHandler {
|
||||
|
||||
Class<? extends Activity> getInstallActivity();
|
||||
|
||||
/**
|
||||
* Returns true if this handler is able to install the element.
|
||||
* #validateInstallation may only be called if this method returned true.
|
||||
|
@ -17,9 +17,11 @@
|
||||
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.divoom;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.FwAppInstallerActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
@ -33,6 +35,11 @@ public class PixooInstallHandler implements InstallHandler {
|
||||
mUri = uri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Activity> getInstallActivity() {
|
||||
return FwAppInstallerActivity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return true;
|
||||
|
@ -16,6 +16,9 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.garmin;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.vivomovehr.GarminCapability.COURSE_DOWNLOAD;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
@ -27,6 +30,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.FwAppInstallerActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
@ -36,8 +40,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.GpxRouteF
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.UriHelper;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.vivomovehr.GarminCapability.COURSE_DOWNLOAD;
|
||||
|
||||
public class GarminGpxRouteInstallHandler implements InstallHandler {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GarminGpxRouteInstallHandler.class);
|
||||
|
||||
@ -67,6 +69,11 @@ public class GarminGpxRouteInstallHandler implements InstallHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Activity> getInstallActivity() {
|
||||
return FwAppInstallerActivity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return gpxRouteFileConverter != null;
|
||||
@ -88,7 +95,7 @@ public class GarminGpxRouteInstallHandler implements InstallHandler {
|
||||
return;
|
||||
}
|
||||
final GarminCoordinator garminCoordinator = (GarminCoordinator) coordinator;
|
||||
if (!garminCoordinator.supports(device, COURSE_DOWNLOAD)) {
|
||||
if (garminCoordinator.supports(device, COURSE_DOWNLOAD)) {
|
||||
installActivity.setInfoText(mContext.getString(R.string.fwapp_install_device_not_supported));
|
||||
installActivity.setInstallEnabled(false);
|
||||
return;
|
||||
|
@ -16,6 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
@ -27,6 +28,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.FwAppInstallerActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
@ -65,6 +67,11 @@ public class ZeppOsAgpsInstallHandler implements InstallHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Activity> getInstallActivity() {
|
||||
return FwAppInstallerActivity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return file != null;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
@ -27,6 +28,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.FwAppInstallerActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
@ -63,6 +65,11 @@ public class ZeppOsGpxRouteInstallHandler implements InstallHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Activity> getInstallActivity() {
|
||||
return FwAppInstallerActivity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return file != null;
|
||||
|
@ -17,16 +17,18 @@
|
||||
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.huawei;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.FwAppInstallerActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiAppManager;
|
||||
@ -154,6 +156,11 @@ public class HuaweiInstallHandler implements InstallHandler {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Activity> getInstallActivity() {
|
||||
return FwAppInstallerActivity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return helper.isValid();
|
||||
|
@ -17,6 +17,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.miband;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
@ -26,15 +27,14 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.IOException;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.FwAppInstallerActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType.AGPS_UIHH;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType.WATCHFACE;
|
||||
|
||||
public abstract class AbstractMiBandFWInstallHandler implements InstallHandler {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractMiBandFWInstallHandler.class);
|
||||
@ -151,6 +151,11 @@ public abstract class AbstractMiBandFWInstallHandler implements InstallHandler {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Activity> getInstallActivity() {
|
||||
return FwAppInstallerActivity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return helper != null;
|
||||
|
@ -17,6 +17,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.pebble;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
@ -34,6 +35,7 @@ import java.io.InputStream;
|
||||
import java.io.Writer;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.FwAppInstallerActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.appmanager.AppManagerActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
@ -203,6 +205,10 @@ public class PBWInstallHandler implements InstallHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Class<? extends Activity> getInstallActivity() {
|
||||
return FwAppInstallerActivity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
|
@ -16,6 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.pinetime;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
@ -30,13 +31,14 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.FwAppInstallerActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.UriHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GBZipFile;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.UriHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.ZipFileException;
|
||||
|
||||
public class PineTimeInstallHandler implements InstallHandler {
|
||||
@ -112,6 +114,11 @@ public class PineTimeInstallHandler implements InstallHandler {
|
||||
public void onStartInstall(GBDevice device) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Activity> getInstallActivity() {
|
||||
return FwAppInstallerActivity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return dfuPackageManifest != null &&
|
||||
|
@ -17,6 +17,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.qhybrid;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
@ -37,6 +38,7 @@ import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.FwAppInstallerActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.appmanager.AbstractAppManagerFragment;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||
@ -45,7 +47,6 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
@ -182,6 +183,11 @@ public class FossilHRInstallHandler implements InstallHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Activity> getInstallActivity() {
|
||||
return FwAppInstallerActivity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return fossilFile.isValid();
|
||||
|
@ -16,6 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.qhybrid;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
@ -26,6 +27,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.FwAppInstallerActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
@ -104,6 +106,11 @@ public class FossilInstallHandler implements InstallHandler {
|
||||
public void onStartInstall(GBDevice device) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Activity> getInstallActivity() {
|
||||
return FwAppInstallerActivity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return mIsValid;
|
||||
|
@ -16,10 +16,12 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.FwAppInstallerActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
@ -36,6 +38,11 @@ public class XiaomiInstallHandler implements InstallHandler {
|
||||
this.helper = new XiaomiFWHelper(uri, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Activity> getInstallActivity() {
|
||||
return FwAppInstallerActivity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return helper.isValid();
|
||||
|
@ -16,10 +16,12 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.cmfwatchpro;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.FwAppInstallerActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
@ -36,6 +38,11 @@ public class CmfInstallHandler implements InstallHandler {
|
||||
this.helper = new CmfFwHelper(uri, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Activity> getInstallActivity() {
|
||||
return FwAppInstallerActivity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return helper.isValid();
|
||||
|
@ -18,10 +18,13 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType.AGPS_UIHH;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -58,6 +61,12 @@ public class ZeppOsFwInstallHandler implements InstallHandler {
|
||||
mHelper = new ZeppOsFwHelper(uri, context, deviceName, deviceSources);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Class<? extends Activity> getInstallActivity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return mHelper.isValid();
|
||||
|
39
app/src/main/res/layout/activity_file_installer.xml
Normal file
39
app/src/main/res/layout/activity_file_installer.xml
Normal file
@ -0,0 +1,39 @@
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:animateLayoutChanges="true"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context="nodomain.freeyourgadget.gadgetbridge.activities.FileInstallerActivity"
|
||||
tools:ignore="ScrollViewSize">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/fileInstallerLoadingProgress"
|
||||
style="?android:attr/progressBarStyle"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminate="true" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/fileInstallerLoadingProgress"
|
||||
android:layout_alignParentStart="false"
|
||||
android:layout_alignParentEnd="false"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/loading" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</ScrollView>
|
@ -134,6 +134,7 @@
|
||||
<!-- Strings related to CalBlacklist -->
|
||||
<string name="title_activity_calblacklist">Blacklisted Calendars</string>
|
||||
<!-- Strings related to FwAppInstaller -->
|
||||
<string name="title_activity_file_installer">File installer</string>
|
||||
<string name="title_activity_fw_app_insaller">FW/App installer</string>
|
||||
<string name="fw_upgrade_notice">You are about to install the %s.</string>
|
||||
<string name="fw_upgrade_notice_amazfitbip">You are about to install the %s firmware on your Amazfit Bip.\n\nPlease make sure to install the .fw file, then the .res file, and finally the .gps file. Your watch will reboot after installing the .fw file.\n\nNote: You do not have to install .res and .gps if these files are exactly the same as the ones previously installed.\n\nPROCEED AT YOUR OWN RISK!</string>
|
||||
|
Loading…
Reference in New Issue
Block a user