|
@@ -1229,55 +1229,62 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|
* Retrieves external links via api from 'external' app
|
|
* Retrieves external links via api from 'external' app
|
|
*/
|
|
*/
|
|
public void fetchExternalLinks(final boolean force) {
|
|
public void fetchExternalLinks(final boolean force) {
|
|
- if (getBaseContext().getResources().getBoolean(R.bool.show_external_links)) {
|
|
|
|
- Thread t = new Thread(() -> {
|
|
|
|
- // fetch capabilities as early as possible
|
|
|
|
- if ((getCapabilities() == null || getCapabilities().getAccountName().isEmpty())
|
|
|
|
- && getStorageManager() != null) {
|
|
|
|
- GetCapabilitiesOperation getCapabilities = new GetCapabilitiesOperation(getStorageManager());
|
|
|
|
- getCapabilities.execute(getBaseContext());
|
|
|
|
- }
|
|
|
|
|
|
+ if (!getBaseContext().getResources().getBoolean(R.bool.show_external_links)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
- User user = accountManager.getUser();
|
|
|
|
- if (getStorageManager() != null && CapabilityUtils.getCapability(user, this)
|
|
|
|
- .getExternalLinks().isTrue()) {
|
|
|
|
|
|
+ User user = accountManager.getUser();
|
|
|
|
+ if (user.isAnonymous()) {
|
|
|
|
+ Log_OC.d(TAG, "Trying to execute a sync operation with a storage manager for an anonymous account");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
- int count = arbitraryDataProvider.getIntegerValue(FilesSyncHelper.GLOBAL,
|
|
|
|
- FileActivity.APP_OPENED_COUNT);
|
|
|
|
|
|
+ Thread t = new Thread(() -> {
|
|
|
|
+ // fetch capabilities as early as possible
|
|
|
|
+ if ((getCapabilities() == null || getCapabilities().getAccountName() != null && getCapabilities().getAccountName().isEmpty())
|
|
|
|
+ && getStorageManager() != null) {
|
|
|
|
+ GetCapabilitiesOperation getCapabilities = new GetCapabilitiesOperation(getStorageManager());
|
|
|
|
+ getCapabilities.execute(getBaseContext());
|
|
|
|
+ }
|
|
|
|
|
|
- if (count > 10 || count == -1 || force) {
|
|
|
|
- if (force) {
|
|
|
|
- Log_OC.d("ExternalLinks", "force update");
|
|
|
|
- }
|
|
|
|
|
|
+ if (getStorageManager() != null && CapabilityUtils.getCapability(user, this)
|
|
|
|
+ .getExternalLinks().isTrue()) {
|
|
|
|
|
|
- arbitraryDataProvider.storeOrUpdateKeyValue(FilesSyncHelper.GLOBAL,
|
|
|
|
- FileActivity.APP_OPENED_COUNT, "0");
|
|
|
|
|
|
+ int count = arbitraryDataProvider.getIntegerValue(FilesSyncHelper.GLOBAL,
|
|
|
|
+ FileActivity.APP_OPENED_COUNT);
|
|
|
|
|
|
- Log_OC.d("ExternalLinks", "update via api");
|
|
|
|
- RemoteOperation getExternalLinksOperation = new ExternalLinksOperation();
|
|
|
|
- RemoteOperationResult result = getExternalLinksOperation.execute(user, this);
|
|
|
|
|
|
+ if (count > 10 || count == -1 || force) {
|
|
|
|
+ if (force) {
|
|
|
|
+ Log_OC.d("ExternalLinks", "force update");
|
|
|
|
+ }
|
|
|
|
|
|
- if (result.isSuccess() && result.getData() != null) {
|
|
|
|
- externalLinksProvider.deleteAllExternalLinks();
|
|
|
|
|
|
+ arbitraryDataProvider.storeOrUpdateKeyValue(FilesSyncHelper.GLOBAL,
|
|
|
|
+ FileActivity.APP_OPENED_COUNT, "0");
|
|
|
|
|
|
- ArrayList<ExternalLink> externalLinks = (ArrayList<ExternalLink>) (Object) result.getData();
|
|
|
|
|
|
+ Log_OC.d("ExternalLinks", "update via api");
|
|
|
|
+ RemoteOperation getExternalLinksOperation = new ExternalLinksOperation();
|
|
|
|
+ RemoteOperationResult result = getExternalLinksOperation.execute(user, this);
|
|
|
|
|
|
- for (ExternalLink link : externalLinks) {
|
|
|
|
- externalLinksProvider.storeExternalLink(link);
|
|
|
|
- }
|
|
|
|
|
|
+ if (result.isSuccess() && result.getData() != null) {
|
|
|
|
+ externalLinksProvider.deleteAllExternalLinks();
|
|
|
|
+
|
|
|
|
+ ArrayList<ExternalLink> externalLinks = (ArrayList<ExternalLink>) (Object) result.getData();
|
|
|
|
+
|
|
|
|
+ for (ExternalLink link : externalLinks) {
|
|
|
|
+ externalLinksProvider.storeExternalLink(link);
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- arbitraryDataProvider.storeOrUpdateKeyValue(FilesSyncHelper.GLOBAL,
|
|
|
|
- FileActivity.APP_OPENED_COUNT, String.valueOf(count + 1));
|
|
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- externalLinksProvider.deleteAllExternalLinks();
|
|
|
|
- Log_OC.d("ExternalLinks", "links disabled");
|
|
|
|
|
|
+ arbitraryDataProvider.storeOrUpdateKeyValue(FilesSyncHelper.GLOBAL,
|
|
|
|
+ FileActivity.APP_OPENED_COUNT, String.valueOf(count + 1));
|
|
}
|
|
}
|
|
- runOnUiThread(this::updateExternalLinksInDrawer);
|
|
|
|
- });
|
|
|
|
- t.start();
|
|
|
|
- }
|
|
|
|
|
|
+ } else {
|
|
|
|
+ externalLinksProvider.deleteAllExternalLinks();
|
|
|
|
+ Log_OC.d("ExternalLinks", "links disabled");
|
|
|
|
+ }
|
|
|
|
+ runOnUiThread(this::updateExternalLinksInDrawer);
|
|
|
|
+ });
|
|
|
|
+ t.start();
|
|
}
|
|
}
|
|
|
|
|
|
protected void handleDeepLink(@NonNull Uri uri) {
|
|
protected void handleDeepLink(@NonNull Uri uri) {
|