-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for notification channels introduced in Oreo
- Loading branch information
1 parent
07b9b8c
commit 3328f02
Showing
5 changed files
with
53 additions
and
3 deletions.
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
46 changes: 46 additions & 0 deletions
46
app/src/main/java/name/raev/kaloyan/hellostorj/FileTransferChannel.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,46 @@ | ||
/* | ||
* Copyright (C) 2018 Kaloyan Raev | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package name.raev.kaloyan.hellostorj; | ||
|
||
import android.app.NotificationChannel; | ||
import android.app.NotificationManager; | ||
import android.content.Context; | ||
|
||
import android.os.Build; | ||
|
||
public class FileTransferChannel { | ||
|
||
public static final String ID = "file_transfer"; | ||
|
||
public static void create(Context context) { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
NotificationManager notificationManager = (NotificationManager) | ||
context.getSystemService(Context.NOTIFICATION_SERVICE); | ||
// The user-visible name of the channel. | ||
CharSequence name = context.getString(R.string.channel_name); | ||
// The user-visible description of the channel. | ||
String description = context.getString(R.string.channel_description); | ||
int importance = NotificationManager.IMPORTANCE_DEFAULT; | ||
NotificationChannel channel = new android.app.NotificationChannel(ID, name, importance); | ||
// Configure the notification channel. | ||
channel.setDescription(description); | ||
channel.enableLights(false); | ||
channel.enableVibration(false); | ||
notificationManager.createNotificationChannel(channel); | ||
} | ||
} | ||
} |
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
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