|
@@ -3,7 +3,9 @@
|
|
*
|
|
*
|
|
* @author masensio
|
|
* @author masensio
|
|
* @author David A. Velasco
|
|
* @author David A. Velasco
|
|
|
|
+ * @author Chris Narkiewicz
|
|
* Copyright (C) 2015 ownCloud Inc.
|
|
* Copyright (C) 2015 ownCloud Inc.
|
|
|
|
+ * Copyright (C) 2019 Chris Narkiewicz <hello@ezaquarii.com>
|
|
*
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2,
|
|
* it under the terms of the GNU General Public License version 2,
|
|
@@ -26,6 +28,8 @@ import android.app.Activity;
|
|
import android.app.NotificationChannel;
|
|
import android.app.NotificationChannel;
|
|
import android.app.NotificationManager;
|
|
import android.app.NotificationManager;
|
|
import android.app.Service;
|
|
import android.app.Service;
|
|
|
|
+import android.content.BroadcastReceiver;
|
|
|
|
+import android.content.ContentProvider;
|
|
import android.content.ContentResolver;
|
|
import android.content.ContentResolver;
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
@@ -40,6 +44,7 @@ import android.view.WindowManager;
|
|
|
|
|
|
import com.evernote.android.job.JobManager;
|
|
import com.evernote.android.job.JobManager;
|
|
import com.evernote.android.job.JobRequest;
|
|
import com.evernote.android.job.JobRequest;
|
|
|
|
+import com.nextcloud.client.account.UserAccountManager;
|
|
import com.nextcloud.client.di.ActivityInjector;
|
|
import com.nextcloud.client.di.ActivityInjector;
|
|
import com.nextcloud.client.di.DaggerAppComponent;
|
|
import com.nextcloud.client.di.DaggerAppComponent;
|
|
import com.nextcloud.client.preferences.AppPreferences;
|
|
import com.nextcloud.client.preferences.AppPreferences;
|
|
@@ -89,6 +94,8 @@ import androidx.multidex.MultiDexApplication;
|
|
import dagger.android.AndroidInjector;
|
|
import dagger.android.AndroidInjector;
|
|
import dagger.android.DispatchingAndroidInjector;
|
|
import dagger.android.DispatchingAndroidInjector;
|
|
import dagger.android.HasActivityInjector;
|
|
import dagger.android.HasActivityInjector;
|
|
|
|
+import dagger.android.HasBroadcastReceiverInjector;
|
|
|
|
+import dagger.android.HasContentProviderInjector;
|
|
import dagger.android.HasServiceInjector;
|
|
import dagger.android.HasServiceInjector;
|
|
import dagger.android.support.HasSupportFragmentInjector;
|
|
import dagger.android.support.HasSupportFragmentInjector;
|
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
@@ -105,7 +112,9 @@ import static com.owncloud.android.ui.activity.ContactsPreferenceActivity.PREFER
|
|
public class MainApp extends MultiDexApplication implements
|
|
public class MainApp extends MultiDexApplication implements
|
|
HasActivityInjector,
|
|
HasActivityInjector,
|
|
HasSupportFragmentInjector,
|
|
HasSupportFragmentInjector,
|
|
- HasServiceInjector {
|
|
|
|
|
|
+ HasServiceInjector,
|
|
|
|
+ HasContentProviderInjector,
|
|
|
|
+ HasBroadcastReceiverInjector {
|
|
|
|
|
|
public static final OwnCloudVersion OUTDATED_SERVER_VERSION = OwnCloudVersion.nextcloud_14;
|
|
public static final OwnCloudVersion OUTDATED_SERVER_VERSION = OwnCloudVersion.nextcloud_14;
|
|
public static final OwnCloudVersion MINIMUM_SUPPORTED_SERVER_VERSION = OwnCloudVersion.nextcloud_12;
|
|
public static final OwnCloudVersion MINIMUM_SUPPORTED_SERVER_VERSION = OwnCloudVersion.nextcloud_12;
|
|
@@ -137,24 +146,37 @@ public class MainApp extends MultiDexApplication implements
|
|
@Inject
|
|
@Inject
|
|
DispatchingAndroidInjector<Service> dispatchingServiceInjector;
|
|
DispatchingAndroidInjector<Service> dispatchingServiceInjector;
|
|
|
|
|
|
|
|
+ @Inject
|
|
|
|
+ DispatchingAndroidInjector<ContentProvider> dispatchingContentProviderInjector;
|
|
|
|
+
|
|
|
|
+ @Inject
|
|
|
|
+ DispatchingAndroidInjector<BroadcastReceiver> dispatchingBroadcastReceiverInjector;
|
|
|
|
+
|
|
|
|
+ @Inject
|
|
|
|
+ UserAccountManager accountManager;
|
|
|
|
+
|
|
private PassCodeManager passCodeManager;
|
|
private PassCodeManager passCodeManager;
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
@SuppressWarnings("unused")
|
|
private boolean mBound;
|
|
private boolean mBound;
|
|
|
|
|
|
- @SuppressFBWarnings("ST")
|
|
|
|
@Override
|
|
@Override
|
|
- public void onCreate() {
|
|
|
|
- super.onCreate();
|
|
|
|
-
|
|
|
|
|
|
+ protected void attachBaseContext(Context base) {
|
|
|
|
+ super.attachBaseContext(base);
|
|
DaggerAppComponent.builder()
|
|
DaggerAppComponent.builder()
|
|
.application(this)
|
|
.application(this)
|
|
.build()
|
|
.build()
|
|
.inject(this);
|
|
.inject(this);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @SuppressFBWarnings("ST")
|
|
|
|
+ @Override
|
|
|
|
+ public void onCreate() {
|
|
|
|
+ super.onCreate();
|
|
|
|
|
|
registerActivityLifecycleCallbacks(new ActivityInjector());
|
|
registerActivityLifecycleCallbacks(new ActivityInjector());
|
|
|
|
|
|
- JobManager.create(this).addJobCreator(new NCJobCreator());
|
|
|
|
|
|
+ JobManager.create(this).addJobCreator(new NCJobCreator(getApplicationContext(), accountManager, preferences));
|
|
MainApp.mContext = getApplicationContext();
|
|
MainApp.mContext = getApplicationContext();
|
|
|
|
|
|
new SecurityUtils();
|
|
new SecurityUtils();
|
|
@@ -195,8 +217,8 @@ public class MainApp extends MultiDexApplication implements
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- initSyncOperations();
|
|
|
|
- initContactsBackup();
|
|
|
|
|
|
+ initSyncOperations(accountManager);
|
|
|
|
+ initContactsBackup(accountManager);
|
|
notificationChannels();
|
|
notificationChannels();
|
|
|
|
|
|
|
|
|
|
@@ -256,9 +278,9 @@ public class MainApp extends MultiDexApplication implements
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- public static void initContactsBackup() {
|
|
|
|
|
|
+ public static void initContactsBackup(UserAccountManager accountManager) {
|
|
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(mContext.getContentResolver());
|
|
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(mContext.getContentResolver());
|
|
- Account[] accounts = AccountUtils.getAccounts(mContext);
|
|
|
|
|
|
+ Account[] accounts = accountManager.getAccounts();
|
|
|
|
|
|
for (Account account : accounts) {
|
|
for (Account account : accounts) {
|
|
if (arbitraryDataProvider.getBooleanValue(account, PREFERENCE_CONTACTS_AUTOMATIC_BACKUP)) {
|
|
if (arbitraryDataProvider.getBooleanValue(account, PREFERENCE_CONTACTS_AUTOMATIC_BACKUP)) {
|
|
@@ -320,7 +342,7 @@ public class MainApp extends MultiDexApplication implements
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public static void initSyncOperations() {
|
|
|
|
|
|
+ public static void initSyncOperations(UserAccountManager accountManager) {
|
|
updateToAutoUpload();
|
|
updateToAutoUpload();
|
|
cleanOldEntries();
|
|
cleanOldEntries();
|
|
updateAutoUploadEntries();
|
|
updateAutoUploadEntries();
|
|
@@ -338,17 +360,18 @@ public class MainApp extends MultiDexApplication implements
|
|
initiateExistingAutoUploadEntries();
|
|
initiateExistingAutoUploadEntries();
|
|
|
|
|
|
FilesSyncHelper.scheduleFilesSyncIfNeeded(mContext);
|
|
FilesSyncHelper.scheduleFilesSyncIfNeeded(mContext);
|
|
- FilesSyncHelper.restartJobsIfNeeded();
|
|
|
|
|
|
+ FilesSyncHelper.restartJobsIfNeeded(accountManager);
|
|
FilesSyncHelper.scheduleOfflineSyncIfNeeded();
|
|
FilesSyncHelper.scheduleOfflineSyncIfNeeded();
|
|
|
|
|
|
- ReceiversHelper.registerNetworkChangeReceiver();
|
|
|
|
|
|
+ ReceiversHelper.registerNetworkChangeReceiver(accountManager);
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
|
- ReceiversHelper.registerPowerChangeReceiver();
|
|
|
|
|
|
+ ReceiversHelper.registerPowerChangeReceiver(accountManager
|
|
|
|
+ );
|
|
}
|
|
}
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
- ReceiversHelper.registerPowerSaveReceiver();
|
|
|
|
|
|
+ ReceiversHelper.registerPowerSaveReceiver(accountManager);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -698,4 +721,14 @@ public class MainApp extends MultiDexApplication implements
|
|
public AndroidInjector<Service> serviceInjector() {
|
|
public AndroidInjector<Service> serviceInjector() {
|
|
return dispatchingServiceInjector;
|
|
return dispatchingServiceInjector;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public AndroidInjector<ContentProvider> contentProviderInjector() {
|
|
|
|
+ return dispatchingContentProviderInjector;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public AndroidInjector<BroadcastReceiver> broadcastReceiverInjector() {
|
|
|
|
+ return dispatchingBroadcastReceiverInjector;
|
|
|
|
+ }
|
|
}
|
|
}
|