forked from rhaeus/dnd-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
rhaeus
committed
Aug 29, 2021
1 parent
3cb6a18
commit ea7c051
Showing
47 changed files
with
261 additions
and
147 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions
70
mobile/src/main/java/de/rhaeus/dndsync/DNDSyncListenerService.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,70 @@ | ||
package de.rhaeus.dndsync; | ||
|
||
import android.app.NotificationManager; | ||
import android.content.Context; | ||
import android.os.Handler; | ||
import android.os.PowerManager; | ||
import android.os.VibrationEffect; | ||
import android.os.Vibrator; | ||
import android.util.Log; | ||
import android.widget.Toast; | ||
|
||
import com.google.android.gms.wearable.MessageEvent; | ||
import com.google.android.gms.wearable.WearableListenerService; | ||
|
||
public class DNDSyncListenerService extends WearableListenerService { | ||
private static final String TAG = "DNDSyncListenerService"; | ||
private static final String DND_SYNC_MESSAGE_PATH = "/wear-dnd-sync"; | ||
|
||
@Override | ||
public void onMessageReceived (MessageEvent messageEvent) { | ||
if (Log.isLoggable(TAG, Log.DEBUG)) { | ||
Log.d(TAG, "onMessageReceived: " + messageEvent); | ||
} | ||
|
||
if (messageEvent.getPath().equalsIgnoreCase(DND_SYNC_MESSAGE_PATH)) { | ||
|
||
byte[] data = messageEvent.getData(); | ||
// data[0] contains if dnd or bedtime mode | ||
// 0 = dnd | ||
// 1 = bedtime mode | ||
// data[1] contains dnd mode of phone | ||
// 0 = INTERRUPTION_FILTER_UNKNOWN | ||
// 1 = INTERRUPTION_FILTER_ALL (all notifications pass) | ||
// 2 = INTERRUPTION_FILTER_PRIORITY | ||
// 3 = INTERRUPTION_FILTER_NONE (no notification passes) | ||
// 4 = INTERRUPTION_FILTER_ALARMS | ||
byte mode = data[0]; | ||
Log.d(TAG, "mode: " + mode); | ||
byte dndStatePhone = data[1]; | ||
Log.d(TAG, "dndStatePhone: " + dndStatePhone); | ||
|
||
// get dnd state | ||
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); | ||
// if (!mNotificationManager.isNotificationPolicyAccessGranted()) { | ||
// Toast.makeText(getApplicationContext(), "DNDSync missing DND permission!", Toast.LENGTH_SHORT).show(); | ||
// Log.d(TAG, "DNDSync missing DND permission!"); | ||
// } | ||
|
||
int filterState = mNotificationManager.getCurrentInterruptionFilter(); | ||
if (filterState < 0 || filterState > 4) { | ||
Log.d(TAG, "DNDSync weird current dnd state: " + filterState); | ||
} | ||
byte currentDndState = (byte) filterState; | ||
Log.d(TAG, "currentDndState: " + currentDndState); | ||
|
||
if (mode == 0) { //dnd | ||
if (dndStatePhone != currentDndState) { | ||
mNotificationManager.setInterruptionFilter(dndStatePhone); | ||
// Toast.makeText(getApplicationContext(), "DND set to " + dndStatePhone, Toast.LENGTH_LONG).show(); | ||
Log.d(TAG, "DND set to " + dndStatePhone); | ||
} | ||
} else { | ||
Log.d(TAG, "DNDSync mode went wrong: " + mode); | ||
} | ||
} else { | ||
super.onMessageReceived(messageEvent); | ||
} | ||
} | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-391 Bytes
(81%)
mobile/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-244 Bytes
(83%)
mobile/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-412 Bytes
(85%)
mobile/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-638 Bytes
(86%)
mobile/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-985 Bytes
(84%)
mobile/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="ic_launcher_background">#3DAADC</color> | ||
<color name="ic_launcher_background">#4272F5</color> | ||
</resources> |
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,6 @@ | ||
<resources xmlns:tools="http://schemas.android.com/tools" | ||
tools:keep="@array/android_wear_capabilities"> | ||
<string-array name="android_wear_capabilities"> | ||
<item>dnd_sync</item> | ||
</string-array> | ||
</resources> |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.