diff --git a/app/build.gradle b/app/build.gradle index 2d693d5..5d9a04b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,7 +3,7 @@ apply from: "$rootProject.projectDir/shared-build.gradle" android { defaultConfig { - versionCode 107 + versionCode 111 wearAppUnbundled true } buildFeatures { diff --git a/app/src/main/java/de/florianisme/wakeonlan/quickaccess/StatefulControlService.java b/app/src/main/java/de/florianisme/wakeonlan/quickaccess/StatefulControlService.java index 04a5afe..258774e 100644 --- a/app/src/main/java/de/florianisme/wakeonlan/quickaccess/StatefulControlService.java +++ b/app/src/main/java/de/florianisme/wakeonlan/quickaccess/StatefulControlService.java @@ -36,7 +36,7 @@ static void createAndUpdateStatefulControls(List deviceIds, ReplayProces .collect(Collectors.toList()); for (Device device : filteredDevices) { - STATUS_TESTER_POOL.scheduleStatusTest(device, deviceStatus -> { + STATUS_TESTER_POOL.schedule(device, deviceStatus -> { Control control = mapDeviceToStatefulControl(device, deviceStatus == DeviceStatus.ONLINE, context); processor.onNext(control); }, StatusTestType.QUICK_ACCESS); @@ -60,6 +60,6 @@ private static Control mapDeviceToStatefulControl(Device device, boolean toggleO } public static void stopAllStatusTesters() { - STATUS_TESTER_POOL.stopAllStatusTesters(StatusTestType.QUICK_ACCESS); + STATUS_TESTER_POOL.stopAllForType(StatusTestType.QUICK_ACCESS); } } diff --git a/app/src/main/java/de/florianisme/wakeonlan/quicksettings/DeviceTileService.java b/app/src/main/java/de/florianisme/wakeonlan/quicksettings/DeviceTileService.java index 2e6c662..cb861de 100644 --- a/app/src/main/java/de/florianisme/wakeonlan/quicksettings/DeviceTileService.java +++ b/app/src/main/java/de/florianisme/wakeonlan/quicksettings/DeviceTileService.java @@ -44,7 +44,7 @@ private void updateTileState() { if (optionalMachine.isPresent()) { Device device = optionalMachine.get(); this.device = device; - statusTesterPool.scheduleStatusTest(device, this, StatusTestType.TILE); + statusTesterPool.schedule(device, this, StatusTestType.TILE); tile.setLabel(device.name); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { @@ -96,7 +96,9 @@ public void onStartListening() { @Override public void onStopListening() { super.onStopListening(); - statusTesterPool.stopStatusTest(device, StatusTestType.TILE); + if (device != null) { + statusTesterPool.stopSingle(device, StatusTestType.TILE); + } } abstract int machineAtIndex(); diff --git a/app/src/main/java/de/florianisme/wakeonlan/ui/list/status/pool/PingStatusTesterPool.java b/app/src/main/java/de/florianisme/wakeonlan/ui/list/status/pool/PingStatusTesterPool.java index 8b56846..bad1bbe 100644 --- a/app/src/main/java/de/florianisme/wakeonlan/ui/list/status/pool/PingStatusTesterPool.java +++ b/app/src/main/java/de/florianisme/wakeonlan/ui/list/status/pool/PingStatusTesterPool.java @@ -2,6 +2,8 @@ import android.util.Log; +import androidx.annotation.NonNull; + import java.util.HashMap; import java.util.Map; import java.util.concurrent.Executors; @@ -38,7 +40,7 @@ public static synchronized StatusTesterPool getInstance() { } @Override - public void scheduleStatusTest(Device device, DeviceStatusListener deviceStatusListener, StatusTestType statusTestType) { + public void schedule(Device device, DeviceStatusListener deviceStatusListener, StatusTestType statusTestType) { synchronized (STATUS_LOCK) { StatusTestItem statusTestItem; @@ -69,7 +71,7 @@ public void scheduleStatusTest(Device device, DeviceStatusListener deviceStatusL } @Override - public void stopStatusTest(Device device, StatusTestType testType) { + public void stopSingle(@NonNull Device device, StatusTestType testType) { Log.d(getClass().getSimpleName(), "Stopping status checks for device " + device.name + " of type " + testType); synchronized (STATUS_LOCK) { @@ -86,7 +88,7 @@ public void stopStatusTest(Device device, StatusTestType testType) { } @Override - public void stopAllStatusTesters(StatusTestType testType) { + public void stopAllForType(StatusTestType testType) { Log.d(getClass().getSimpleName(), "Stopping all status checks of type " + testType); Map updatedList = new HashMap<>(8); diff --git a/app/src/main/java/de/florianisme/wakeonlan/ui/list/status/pool/StatusTesterPool.java b/app/src/main/java/de/florianisme/wakeonlan/ui/list/status/pool/StatusTesterPool.java index ae794b7..7432e31 100644 --- a/app/src/main/java/de/florianisme/wakeonlan/ui/list/status/pool/StatusTesterPool.java +++ b/app/src/main/java/de/florianisme/wakeonlan/ui/list/status/pool/StatusTesterPool.java @@ -1,15 +1,17 @@ package de.florianisme.wakeonlan.ui.list.status.pool; +import androidx.annotation.NonNull; + import de.florianisme.wakeonlan.persistence.models.Device; import de.florianisme.wakeonlan.ui.list.status.DeviceStatusListener; public interface StatusTesterPool { - void scheduleStatusTest(Device device, DeviceStatusListener deviceStatusListener, StatusTestType testType); + void schedule(Device device, DeviceStatusListener deviceStatusListener, StatusTestType testType); - void stopStatusTest(Device device, StatusTestType testType); + void stopSingle(@NonNull Device device, StatusTestType testType); - void stopAllStatusTesters(StatusTestType testType); + void stopAllForType(StatusTestType testType); void pauseAllForType(StatusTestType testType); diff --git a/app/src/main/java/de/florianisme/wakeonlan/ui/list/viewholder/DeviceItemViewHolder.java b/app/src/main/java/de/florianisme/wakeonlan/ui/list/viewholder/DeviceItemViewHolder.java index 74b6cc5..b4c832e 100644 --- a/app/src/main/java/de/florianisme/wakeonlan/ui/list/viewholder/DeviceItemViewHolder.java +++ b/app/src/main/java/de/florianisme/wakeonlan/ui/list/viewholder/DeviceItemViewHolder.java @@ -102,7 +102,7 @@ public void startDeviceStatusQuery(Device device) { deviceStatus.clearAnimation(); deviceStatus.setBackground(AppCompatResources.getDrawable(itemView.getContext(), R.drawable.device_status_unknown)); - statusTesterPool.scheduleStatusTest(device, status -> { + statusTesterPool.schedule(device, status -> { if (status == DeviceStatus.ONLINE) { setAlphaAnimationIfNotSet(); setStatusDrawable(R.drawable.device_status_online); @@ -140,7 +140,7 @@ private void setAlphaAnimationIfNotSet() { public void cancelStatusUpdates() { if (statusTesterPool != null && device != null) { - statusTesterPool.stopStatusTest(device, StatusTestType.LIST); + statusTesterPool.stopSingle(device, StatusTestType.LIST); } } } \ No newline at end of file diff --git a/shared-build.gradle b/shared-build.gradle index 83707d2..4bcbe9a 100644 --- a/shared-build.gradle +++ b/shared-build.gradle @@ -33,7 +33,7 @@ android { applicationId "de.florianisme.wakeonlan" minSdk 24 targetSdk 34 - versionName "1.9.7" + versionName "1.9.8" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/wear/build.gradle b/wear/build.gradle index 3553257..203ecec 100644 --- a/wear/build.gradle +++ b/wear/build.gradle @@ -5,7 +5,7 @@ android { compileSdk 33 defaultConfig { targetSdk 33 - versionCode 106 + versionCode 110 } }