mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-29 05:16:51 +01:00
Small improvements for the install activity #30
Now starts the service if not already running
This commit is contained in:
parent
2a2eae068a
commit
64298fc9af
@ -18,11 +18,11 @@ import android.widget.Toast;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.DeviceCommunicationService;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.service.DeviceCommunicationService;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ public class FwAppInstallerActivity extends Activity implements InstallActivity
|
|||||||
GB.toast(FwAppInstallerActivity.this, getString(R.string.connecting), Toast.LENGTH_SHORT, GB.INFO);
|
GB.toast(FwAppInstallerActivity.this, getString(R.string.connecting), Toast.LENGTH_SHORT, GB.INFO);
|
||||||
connect();
|
connect();
|
||||||
} else {
|
} else {
|
||||||
setInfoText(getString(R.string.not_connected));
|
setInfoText(device.getStateString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
validateInstallation();
|
validateInstallation();
|
||||||
@ -63,9 +63,12 @@ public class FwAppInstallerActivity extends Activity implements InstallActivity
|
|||||||
};
|
};
|
||||||
|
|
||||||
private void connect() {
|
private void connect() {
|
||||||
|
mayConnect = false; // only do that once per #onCreate
|
||||||
Intent startIntent = new Intent(FwAppInstallerActivity.this, DeviceCommunicationService.class);
|
Intent startIntent = new Intent(FwAppInstallerActivity.this, DeviceCommunicationService.class);
|
||||||
startIntent.setAction(DeviceCommunicationService.ACTION_CONNECT);
|
startIntent.setAction(DeviceCommunicationService.ACTION_CONNECT);
|
||||||
startIntent.putExtra(GBDevice.EXTRA_DEVICE, device);
|
if (device != null) {
|
||||||
|
startIntent.putExtra(GBDevice.EXTRA_DEVICE, device);
|
||||||
|
}
|
||||||
startService(startIntent);
|
startService(startIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +83,10 @@ public class FwAppInstallerActivity extends Activity implements InstallActivity
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_appinstaller);
|
setContentView(R.layout.activity_appinstaller);
|
||||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
GBDevice dev = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE);
|
||||||
|
if (dev != null) {
|
||||||
|
device = dev;
|
||||||
|
}
|
||||||
mayConnect = true;
|
mayConnect = true;
|
||||||
fwAppInstallTextView = (TextView) findViewById(R.id.debugTextView);
|
fwAppInstallTextView = (TextView) findViewById(R.id.debugTextView);
|
||||||
installButton = (Button) findViewById(R.id.installButton);
|
installButton = (Button) findViewById(R.id.installButton);
|
||||||
@ -109,9 +115,12 @@ public class FwAppInstallerActivity extends Activity implements InstallActivity
|
|||||||
setInstallEnabled(false);
|
setInstallEnabled(false);
|
||||||
|
|
||||||
// needed to get the device
|
// needed to get the device
|
||||||
Intent connectIntent = new Intent(this, DeviceCommunicationService.class);
|
if (device == null || !device.isConnected()) {
|
||||||
connectIntent.setAction(DeviceCommunicationService.ACTION_CONNECT);
|
Intent startIntent = new Intent(this, DeviceCommunicationService.class);
|
||||||
startService(connectIntent);
|
startIntent.setAction(DeviceCommunicationService.ACTION_START);
|
||||||
|
startService(startIntent);
|
||||||
|
connect();
|
||||||
|
}
|
||||||
|
|
||||||
Intent versionInfoIntent = new Intent(this, DeviceCommunicationService.class);
|
Intent versionInfoIntent = new Intent(this, DeviceCommunicationService.class);
|
||||||
versionInfoIntent.setAction(DeviceCommunicationService.ACTION_REQUEST_VERSIONINFO);
|
versionInfoIntent.setAction(DeviceCommunicationService.ACTION_REQUEST_VERSIONINFO);
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.devices;
|
package nodomain.freeyourgadget.gadgetbridge.devices;
|
||||||
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.FwAppInstallerActivity;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity;
|
import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user