From d28cccb078ee16f0a44450e864623411e0f9413b Mon Sep 17 00:00:00 2001 From: Florianisme Date: Fri, 5 Apr 2024 14:42:37 +0200 Subject: [PATCH 1/3] Rename methods --- .../wakeonlan/quickaccess/StatefulControlService.java | 4 ++-- .../wakeonlan/quicksettings/DeviceTileService.java | 4 ++-- .../wakeonlan/ui/list/status/pool/PingStatusTesterPool.java | 6 +++--- .../wakeonlan/ui/list/status/pool/StatusTesterPool.java | 6 +++--- .../wakeonlan/ui/list/viewholder/DeviceItemViewHolder.java | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) 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..f3b8327 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,7 @@ public void onStartListening() { @Override public void onStopListening() { super.onStopListening(); - statusTesterPool.stopStatusTest(device, StatusTestType.TILE); + 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..c203212 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 @@ -38,7 +38,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 +69,7 @@ public void scheduleStatusTest(Device device, DeviceStatusListener deviceStatusL } @Override - public void stopStatusTest(Device device, StatusTestType testType) { + public void stopSingle(Device device, StatusTestType testType) { Log.d(getClass().getSimpleName(), "Stopping status checks for device " + device.name + " of type " + testType); synchronized (STATUS_LOCK) { @@ -86,7 +86,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..d45a408 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 @@ -5,11 +5,11 @@ 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(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 From 18d4d22993ea414fe1b127dadb9a59e28c1a069c Mon Sep 17 00:00:00 2001 From: Florianisme Date: Thu, 11 Apr 2024 19:58:26 +0200 Subject: [PATCH 2/3] Fix NPE when attempting to stop status pings of unconfigured Quick tile --- .../wakeonlan/quicksettings/DeviceTileService.java | 4 +++- .../wakeonlan/ui/list/status/pool/PingStatusTesterPool.java | 4 +++- .../wakeonlan/ui/list/status/pool/StatusTesterPool.java | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) 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 f3b8327..cb861de 100644 --- a/app/src/main/java/de/florianisme/wakeonlan/quicksettings/DeviceTileService.java +++ b/app/src/main/java/de/florianisme/wakeonlan/quicksettings/DeviceTileService.java @@ -96,7 +96,9 @@ public void onStartListening() { @Override public void onStopListening() { super.onStopListening(); - statusTesterPool.stopSingle(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 c203212..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; @@ -69,7 +71,7 @@ public void schedule(Device device, DeviceStatusListener deviceStatusListener, S } @Override - public void stopSingle(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) { 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 d45a408..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,5 +1,7 @@ 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; @@ -7,7 +9,7 @@ public interface StatusTesterPool { void schedule(Device device, DeviceStatusListener deviceStatusListener, StatusTestType testType); - void stopSingle(Device device, StatusTestType testType); + void stopSingle(@NonNull Device device, StatusTestType testType); void stopAllForType(StatusTestType testType); From a71ede393ff8e9c59cc660fe3f25cfcda3120ad4 Mon Sep 17 00:00:00 2001 From: Florianisme Date: Thu, 11 Apr 2024 20:17:31 +0200 Subject: [PATCH 3/3] Increase Version code/name --- app/build.gradle | 2 +- shared-build.gradle | 2 +- wear/build.gradle | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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/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 } }