Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions app/src/main/java/fr/free/nrw/commons/CommonsApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;

import com.facebook.drawee.backends.pipeline.Fresco;
Expand Down Expand Up @@ -122,22 +123,22 @@ public void onCreate() {
Stetho.initializeWithDefaults(this);
}


if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
createNotificationChannel();
}
createNotificationChannel(this);

// Fire progress callbacks for every 3% of uploaded content
System.setProperty("in.yuvi.http.fluent.PROGRESS_TRIGGER_THRESHOLD", "3.0");
}

@RequiresApi(26)
private void createNotificationChannel() {
NotificationChannel channel = new NotificationChannel(
NOTIFICATION_CHANNEL_ID_ALL,
getString(R.string.notifications_channel_name_all), NotificationManager.IMPORTANCE_NONE);
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.createNotificationChannel(channel);
public static void createNotificationChannel(@NonNull Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel channel = manager.getNotificationChannel(NOTIFICATION_CHANNEL_ID_ALL);
if (channel == null) {
channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID_ALL,
context.getString(R.string.notifications_channel_name_all), NotificationManager.IMPORTANCE_DEFAULT);
manager.createNotificationChannel(channel);
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void onDestroy() {
@Override
public void onCreate() {
super.onCreate();

CommonsApplication.createNotificationChannel(getApplicationContext());
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
}

Expand Down