It's appearing
This commit is contained in:
parent
c9c5752281
commit
ee34f6a623
@ -77,6 +77,7 @@ android {
|
|||||||
$$ANDROID_PACKAGE_SOURCE_DIR/gradlew.bat \
|
$$ANDROID_PACKAGE_SOURCE_DIR/gradlew.bat \
|
||||||
$$ANDROID_PACKAGE_SOURCE_DIR/src/io/guh/nymeaapp/NymeaAppActivity.java \
|
$$ANDROID_PACKAGE_SOURCE_DIR/src/io/guh/nymeaapp/NymeaAppActivity.java \
|
||||||
$$ANDROID_PACKAGE_SOURCE_DIR/src/io/guh/nymeaapp/NymeaAppNotificationService.java \
|
$$ANDROID_PACKAGE_SOURCE_DIR/src/io/guh/nymeaapp/NymeaAppNotificationService.java \
|
||||||
|
$$ANDROID_PACKAGE_SOURCE_DIR/src/io/guh/nymeaapp/NymeaAppControlService.java \
|
||||||
$$ANDROID_PACKAGE_SOURCE_DIR/LICENSE
|
$$ANDROID_PACKAGE_SOURCE_DIR/LICENSE
|
||||||
|
|
||||||
# https://bugreports.qt.io/browse/QTBUG-83165
|
# https://bugreports.qt.io/browse/QTBUG-83165
|
||||||
|
|||||||
@ -73,12 +73,11 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service android:name="io.guh.nymeaapp.NymeaHomeControlsService" android:label="nymea:app" android:permission="android.permission.BIND_CONTROLS">
|
<service android:name="io.guh.nymeaapp.NymeaAppControlService" android:permission="android.permission.BIND_CONTROLS" android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.service.controls.ControlProviderService"/>
|
<action android:name="android.service.controls.ControlsProviderService"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|||||||
@ -5,15 +5,12 @@ import android.content.Intent;
|
|||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.provider.Settings.System;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.service.controls.ControlsProviderService;
|
import android.service.controls.ControlsProviderService;
|
||||||
import android.service.controls.actions.ControlAction;
|
import android.service.controls.actions.ControlAction;
|
||||||
import android.service.controls.actions.BooleanAction;
|
import android.service.controls.actions.BooleanAction;
|
||||||
import android.service.controls.Control;
|
import android.service.controls.Control;
|
||||||
import android.service.controls.DeviceTypes;
|
import android.service.controls.DeviceTypes;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.concurrent.Flow.Publisher;
|
import java.util.concurrent.Flow.Publisher;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -22,19 +19,20 @@ import io.reactivex.Flowable;
|
|||||||
import io.reactivex.processors.ReplayProcessor;
|
import io.reactivex.processors.ReplayProcessor;
|
||||||
import org.reactivestreams.FlowAdapters;
|
import org.reactivestreams.FlowAdapters;
|
||||||
|
|
||||||
public class NymeaAppHomeControlsService extends ControlsProviderService {
|
public class NymeaAppControlService extends ControlsProviderService {
|
||||||
|
|
||||||
private ReplayProcessor updatePublisher;
|
private ReplayProcessor updatePublisher;
|
||||||
private PendingIntent pi;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Publisher createPublisherForAllAvailable() {
|
public Publisher createPublisherForAllAvailable() {
|
||||||
|
Log.d("********************************* Creating publishers for all ****************************", "fff");
|
||||||
|
|
||||||
Context context = getBaseContext();
|
Context context = getBaseContext();
|
||||||
Intent i = new Intent();
|
Intent i = new Intent();
|
||||||
// PendingIntent pi = PendingIntent.getActivity(context, 1, i, PendingIntent.FLAG_UPDATE_CURRENT);
|
PendingIntent pi = PendingIntent.getActivity(context, 1, i, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
pi = PendingIntent.getActivity(context, 1, i, PendingIntent.FLAG_UPDATE_CURRENT);
|
// pi = PendingIntent.getActivity(context, 1, i, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
List controls = new ArrayList<>();
|
List controls = new ArrayList<>();
|
||||||
Control control = new Control.StatelessBuilder("123", pi)
|
Control control = new Control.StatelessBuilder("e24b0d95-9982-4f9b-ad8b-2aa6b9aba8fd", pi)
|
||||||
// Required: The name of the control
|
// Required: The name of the control
|
||||||
.setTitle("TestControl")
|
.setTitle("TestControl")
|
||||||
// Required: Usually the room where the control is located
|
// Required: Usually the room where the control is located
|
||||||
@ -42,7 +40,7 @@ public class NymeaAppHomeControlsService extends ControlsProviderService {
|
|||||||
// Optional: Structure where the control is located, an example would be a house
|
// Optional: Structure where the control is located, an example would be a house
|
||||||
.setStructure("TestLocation")
|
.setStructure("TestLocation")
|
||||||
// Required: Type of device, i.e., thermostat, light, switch
|
// Required: Type of device, i.e., thermostat, light, switch
|
||||||
.setDeviceType(DeviceTypes.TYPE_LIGHT) // For example, DeviceTypes.TYPE_THERMOSTAT
|
.setDeviceType(DeviceTypes.TYPE_GENERIC_ON_OFF) // For example, DeviceTypes.TYPE_THERMOSTAT
|
||||||
.build();
|
.build();
|
||||||
controls.add(control);
|
controls.add(control);
|
||||||
// Create more controls here if needed and add it to the ArrayList
|
// Create more controls here if needed and add it to the ArrayList
|
||||||
@ -54,6 +52,10 @@ public class NymeaAppHomeControlsService extends ControlsProviderService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Publisher createPublisherFor(List controlIds) {
|
public Publisher createPublisherFor(List controlIds) {
|
||||||
|
Log.d("********************************* Creating publishers for one ****************************", "..");
|
||||||
|
// for(int i = 0; i < controlIds.size(); i++) {
|
||||||
|
// Log.d("requested control id:", controlIds.get(i));
|
||||||
|
// }
|
||||||
Context context = getBaseContext();
|
Context context = getBaseContext();
|
||||||
/* Fill in details for the activity related to this device. On long press,
|
/* Fill in details for the activity related to this device. On long press,
|
||||||
* this Intent will be launched in a bottomsheet. Please design the activity
|
* this Intent will be launched in a bottomsheet. Please design the activity
|
||||||
@ -66,8 +68,9 @@ public class NymeaAppHomeControlsService extends ControlsProviderService {
|
|||||||
|
|
||||||
// For each controlId in controlIds
|
// For each controlId in controlIds
|
||||||
|
|
||||||
if (controlIds.contains(123)) {
|
if (controlIds.contains("e24b0d95-9982-4f9b-ad8b-2aa6b9aba8fd")) {
|
||||||
Control control = new Control.StatefulBuilder("123", pi)
|
Log.d("**", "control asked");
|
||||||
|
Control control = new Control.StatefulBuilder("e24b0d95-9982-4f9b-ad8b-2aa6b9aba8fd", pi)
|
||||||
// Required: The name of the control
|
// Required: The name of the control
|
||||||
.setTitle("TestTitle")
|
.setTitle("TestTitle")
|
||||||
// Required: Usually the room where the control is located
|
// Required: Usually the room where the control is located
|
||||||
@ -75,7 +78,7 @@ public class NymeaAppHomeControlsService extends ControlsProviderService {
|
|||||||
// Optional: Structure where the control is located, an example would be a house
|
// Optional: Structure where the control is located, an example would be a house
|
||||||
.setStructure("TestStructure")
|
.setStructure("TestStructure")
|
||||||
// Required: Type of device, i.e., thermostat, light, switch
|
// Required: Type of device, i.e., thermostat, light, switch
|
||||||
.setDeviceType(DeviceTypes.TYPE_LIGHT) // For example, DeviceTypes.TYPE_THERMOSTAT
|
.setDeviceType(DeviceTypes.TYPE_GENERIC_ON_OFF) // For example, DeviceTypes.TYPE_THERMOSTAT
|
||||||
// Required: Current status of the device
|
// Required: Current status of the device
|
||||||
.setStatus(Control.STATUS_OK) // For example, Control.STATUS_OK
|
.setStatus(Control.STATUS_OK) // For example, Control.STATUS_OK
|
||||||
.build();
|
.build();
|
||||||
@ -107,21 +110,21 @@ public class NymeaAppHomeControlsService extends ControlsProviderService {
|
|||||||
* After updating, the application should use the publisher to update SystemUI with the new
|
* After updating, the application should use the publisher to update SystemUI with the new
|
||||||
* state.
|
* state.
|
||||||
*/
|
*/
|
||||||
Control control = new Control.StatefulBuilder("123", pi)
|
// Control control = new Control.StatefulBuilder("123", pi)
|
||||||
// Required: The name of the control
|
// // Required: The name of the control
|
||||||
.setTitle("TestControl")
|
// .setTitle("TestControl")
|
||||||
// Required: Usually the room where the control is located
|
// // Required: Usually the room where the control is located
|
||||||
.setSubtitle("TestSubTitle")
|
// .setSubtitle("TestSubTitle")
|
||||||
// Optional: Structure where the control is located, an example would be a house
|
// // Optional: Structure where the control is located, an example would be a house
|
||||||
.setStructure("TestStructure")
|
// .setStructure("TestStructure")
|
||||||
// Required: Type of device, i.e., thermostat, light, switch
|
// // Required: Type of device, i.e., thermostat, light, switch
|
||||||
.setDeviceType(DeviceTypes.TYPE_LIGHT) // For example, DeviceTypes.TYPE_THERMOSTAT
|
// .setDeviceType(DeviceTypes.TYPE_GENERIC_ON_OFF) // For example, DeviceTypes.TYPE_THERMOSTAT
|
||||||
// Required: Current status of the device
|
// // Required: Current status of the device
|
||||||
.setStatus(Control.STATUS_OK) // For example, Control.STATUS_OK
|
// .setStatus(Control.STATUS_OK) // For example, Control.STATUS_OK
|
||||||
.build();
|
// .build();
|
||||||
|
|
||||||
// This is the publisher the application created during the call to createPublisherFor()
|
// // This is the publisher the application created during the call to createPublisherFor()
|
||||||
updatePublisher.onNext(control);
|
// updatePublisher.onNext(control);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user