mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
Fix crashing issue on bootup
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
dd2c02e46a
commit
bedf9f1ae8
4 changed files with 28 additions and 0 deletions
|
@ -323,6 +323,10 @@ public class MainApp extends MultiDexApplication {
|
|||
createChannel(notificationManager, NotificationUtils.NOTIFICATION_CHANNEL_FILE_SYNC,
|
||||
R.string.notification_channel_file_sync_name,
|
||||
R.string.notification_channel_file_sync_description, context);
|
||||
|
||||
createChannel(notificationManager, NotificationUtils.NOTIFICATION_CHANNEL_FILE_OBSERVER,
|
||||
R.string.notification_channel_file_observer_name, R.string
|
||||
.notification_channel_file_observer_description, context);
|
||||
} else {
|
||||
Log_OC.e(TAG, "Notification manager is null");
|
||||
}
|
||||
|
|
|
@ -22,22 +22,28 @@
|
|||
package com.owncloud.android.services.observer;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.app.Notification;
|
||||
import android.app.Service;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.IBinder;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AccountUtils;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
|
||||
import com.owncloud.android.files.services.FileDownloader;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.operations.SynchronizeFileOperation;
|
||||
import com.owncloud.android.ui.notifications.NotificationUtils;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
@ -68,6 +74,8 @@ public class FileObserverService extends Service {
|
|||
private final static String ARG_FILE = "ARG_FILE";
|
||||
private final static String ARG_ACCOUNT = "ARG_ACCOUNT";
|
||||
|
||||
private static final int FOREGROUND_SERVICE_ID = 333;
|
||||
|
||||
private static final String TAG = FileObserverService.class.getSimpleName();
|
||||
|
||||
private Map<String, FolderObserver> mFolderObserversMap;
|
||||
|
@ -115,6 +123,19 @@ public class FileObserverService extends Service {
|
|||
Log_OC.d(TAG, "onCreate");
|
||||
super.onCreate();
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
Notification notification = new NotificationCompat.Builder(this,
|
||||
NotificationUtils.NOTIFICATION_CHANNEL_FILE_OBSERVER)
|
||||
.setContentTitle(getResources().getString(R.string.notification_channel_file_observer_name))
|
||||
.setContentText(getResources().getString(R.string.notification_channel_file_observer_description))
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.notification_icon))
|
||||
.setColor(ThemeUtils.primaryColor())
|
||||
.build();
|
||||
|
||||
startForeground(FOREGROUND_SERVICE_ID, notification);
|
||||
}
|
||||
|
||||
mDownloadReceiver = new DownloadCompletedReceiver();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(FileDownloader.getDownloadAddedMessage());
|
||||
|
|
|
@ -38,6 +38,7 @@ public class NotificationUtils {
|
|||
public static final String NOTIFICATION_CHANNEL_UPLOAD = "NOTIFICATION_CHANNEL_UPLOAD";
|
||||
public static final String NOTIFICATION_CHANNEL_MEDIA = "NOTIFICATION_CHANNEL_MEDIA";
|
||||
public static final String NOTIFICATION_CHANNEL_FILE_SYNC = "NOTIFICATION_CHANNEL_FILE_SYNC";
|
||||
public static final String NOTIFICATION_CHANNEL_FILE_OBSERVER = "NOTIFICATION_CHANNEL_FILE_OBSERVER";
|
||||
|
||||
/**
|
||||
* Factory method for {@link android.support.v4.app.NotificationCompat.Builder} instances.
|
||||
|
|
|
@ -736,6 +736,8 @@
|
|||
<string name="notification_channel_media_description">Music player progress</string>
|
||||
<string name="notification_channel_file_sync_name">File sync</string>
|
||||
<string name="notification_channel_file_sync_description">Shows file sync progress and results</string>
|
||||
<string name="notification_channel_file_observer_name">File observer</string>
|
||||
<string name="notification_channel_file_observer_description">Monitors files for changes</string>
|
||||
|
||||
<string name="account_not_found">Account not found!</string>
|
||||
|
||||
|
|
Loading…
Reference in a new issue