-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from learningequality/revert-175
Notification handling and work manager tweaks
- Loading branch information
Showing
16 changed files
with
462 additions
and
187 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,5 @@ android_root/ | |
.env | ||
.version-code | ||
*.keystore | ||
.envrc | ||
.idea/ |
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
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
67 changes: 67 additions & 0 deletions
67
python-for-android/dists/kolibri/src/main/java/org/learningequality/Kolibri/App.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,67 @@ | ||
package org.learningequality.Kolibri; | ||
|
||
import android.app.Application; | ||
import android.content.Context; | ||
import android.os.Build; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.core.app.NotificationManagerCompat; | ||
import androidx.core.app.NotificationChannelCompat; | ||
import androidx.work.Configuration; | ||
|
||
import org.learningequality.NotificationRef; | ||
|
||
import java.util.concurrent.Executors; | ||
|
||
public class App extends Application implements Configuration.Provider { | ||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
NotificationRef.initialize(this); | ||
createNotificationChannels(); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public Configuration getWorkManagerConfiguration() { | ||
String processName = getApplicationContext().getPackageName(); | ||
processName += getApplicationContext().getString(R.string.task_worker_process); | ||
|
||
|
||
|
||
// Using the same quantity of worker threads as Kolibri's python side: | ||
// https://github.com/learningequality/kolibri/blob/release-v0.16.x/kolibri/utils/options.py#L683 | ||
return new Configuration.Builder() | ||
.setDefaultProcessName(processName) | ||
.setMinimumLoggingLevel(android.util.Log.DEBUG) | ||
.setExecutor(Executors.newFixedThreadPool(6)) | ||
.build(); | ||
} | ||
|
||
private void createNotificationChannels() { | ||
// Create the NotificationChannel, but only on API 26+ because | ||
// the NotificationChannel class is not in the Support Library. | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
Context context = getApplicationContext(); | ||
NotificationChannelCompat serviceChannel = new NotificationChannelCompat.Builder( | ||
context.getString(R.string.notification_service_channel_id), | ||
NotificationManagerCompat.IMPORTANCE_MIN | ||
) | ||
.setName(context.getString(R.string.notification_service_channel_title)) | ||
.setShowBadge(false) | ||
.build(); | ||
NotificationChannelCompat taskChannel = new NotificationChannelCompat.Builder( | ||
context.getString(R.string.notification_default_channel_id), | ||
NotificationManagerCompat.IMPORTANCE_DEFAULT | ||
) | ||
.setName(context.getString(R.string.notification_default_channel_title)) | ||
.build(); | ||
|
||
// Register the channel with the system. You can't change the importance | ||
// or other notification behaviors after this. | ||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); | ||
notificationManager.createNotificationChannel(serviceChannel); | ||
notificationManager.createNotificationChannel(taskChannel); | ||
} | ||
} | ||
} |
Oops, something went wrong.