This repository has been archived by the owner on Dec 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 659
Tasker Plugin #1435
Open
christian-n
wants to merge
19
commits into
Freeyourgadget:master
Choose a base branch
from
christian-n:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Tasker Plugin #1435
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
e860d78
First tasker draft.
christian-n be6a3e3
Added Tasker plugin with service and events.
christian-n 26af4c4
Fist draft for tasker settings.
christian-n 88c823d
Added tasker activities and dynamic building.
christian-n 0ecff3f
Added tasker activities in draft state. Still buggy.
christian-n 9dee59f
Settings now complete.
christian-n c6b20ea
TaskerSettings now binded to TaskerActivities.
christian-n 85c3d40
Finished activities. Fixed some bugs. Added scopes for preferences. S…
christian-n 20e14ec
TaskerEventSettings are now fragment based and scoped.
christian-n a857be6
Changed Settings to Fragment based perferences and implemented the sc…
christian-n 3fb1c70
Finished scope settings. Loading is still missing.
christian-n 015898d
Added all tasker plugin classes.
christian-n b54b306
Started bug fixing.
christian-n 82cec63
Added task removal.
christian-n 554a9a9
Fixed threshold values.
christian-n 2aeb993
Merge branch 'master' of https://github.com/Freeyourgadget/Gadgetbridge
christian-n 4b9e9f0
Merged origin.
christian-n 7e736a4
Changed to GB.toast, fixed equals and added constructors to TaskerEve…
christian-n 14db704
Merged with master.
christian-n File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/xwatch/XWatchConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package nodomain.freeyourgadget.gadgetbridge.devices.xwatch; | ||
|
||
public class XWatchConstants { | ||
|
||
public static class Tasker { | ||
public static final String TASKER_ACTIVE = "tasker_active"; | ||
public static final String TASKER_TASK_SINGLE = "tasker_task_single"; | ||
public static final String TASKER_TASK_DOUBLE = "tasker_task_double"; | ||
public static final String TASKER_TASK_TRIPLE = "tasker_task_triple"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,4 +47,5 @@ public static String lookup(UUID uuid, String fallback) { | |
} | ||
return name; | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/xwatch/XWatchTaskerSpec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package nodomain.freeyourgadget.gadgetbridge.devices.xwatch; | ||
|
||
import android.bluetooth.BluetoothGatt; | ||
import android.bluetooth.BluetoothGattCharacteristic; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; | ||
import nodomain.freeyourgadget.gadgetbridge.tasker.event.TaskerEventType; | ||
import nodomain.freeyourgadget.gadgetbridge.tasker.spec.AbstractTaskerSpec; | ||
|
||
public class XWatchTaskerSpec extends AbstractTaskerSpec { | ||
|
||
public XWatchTaskerSpec(DeviceType device) { | ||
super(device); | ||
} | ||
|
||
@Override | ||
public TaskerEventType getEventType(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { | ||
if (XWatchService.UUID_NOTIFY.equals(characteristic.getUuid())) { | ||
byte[] data = characteristic.getValue(); | ||
if (data[0] == XWatchService.COMMAND_ACTIVITY_DATA) { | ||
return TaskerEventType.DATA; | ||
} | ||
if (data[0] == XWatchService.COMMAND_ACTION_BUTTON) { | ||
return TaskerEventType.BUTTON; | ||
} | ||
if (data[0] == XWatchService.COMMAND_CONNECTED) { | ||
return TaskerEventType.CONNECTION; | ||
} | ||
} | ||
return TaskerEventType.NO_OP; | ||
} | ||
|
||
@Override | ||
public List<TaskerEventType> getSupportedTypes() { | ||
return Arrays.asList(TaskerEventType.BUTTON, TaskerEventType.DATA, TaskerEventType.CONNECTION); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
app/src/main/java/nodomain/freeyourgadget/gadgetbridge/tasker/event/TaskerEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package nodomain.freeyourgadget.gadgetbridge.tasker.event; | ||
|
||
import nodomain.freeyourgadget.gadgetbridge.tasker.settings.TaskerSettings; | ||
|
||
/** | ||
* Tasker event that gets thrown if its corresponding {@link TaskerSettings#isEnabled()} is true. | ||
* <p> | ||
* Provides {@link TaskerEventType} and a count. | ||
* <p> | ||
* Count resets itself after {@link TaskerSettings#getThreshold()} is expired. | ||
*/ | ||
public class TaskerEvent { | ||
|
||
private TaskerEventType type; | ||
private int count; | ||
|
||
public TaskerEvent(TaskerEventType type, int count) { | ||
this.type = type; | ||
this.count = count; | ||
} | ||
|
||
/** | ||
* Tasker event type of this event. | ||
* | ||
* @return | ||
*/ | ||
public TaskerEventType getType() { | ||
return type; | ||
} | ||
|
||
public void setType(TaskerEventType type) { | ||
this.type = type; | ||
} | ||
|
||
/** | ||
* Count how often this event is thrown in the {@link TaskerSettings#getThreshold()} | ||
* | ||
* @return Fired times | ||
*/ | ||
public int getCount() { | ||
return count; | ||
} | ||
|
||
public void setCount(int count) { | ||
this.count = count; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that such events would rather be handled generically via GBDevice#getState() changes (see GBDevice#sendDeviceUpdateEvent()).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AbstractDeviceSupport#handleGBDeviceEvent() methods are probably also good candidates for a generic implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you give me more info on that.