Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BugFix - Check Account Type Before Sync Operation Execution and Instead Crashing The App Inform User #13440

Merged
merged 5 commits into from
Aug 23, 2024
Merged
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ private void onNavigationItemClicked(final MenuItem menuItem) {
} else if (itemId == R.id.nav_logout) {
mCheckedMenuItem = -1;
MenuItem isNewMenuItemChecked = menuItem.setChecked(false);
Log_OC.d(TAG,"onNavigationItemClicked nav_logout setChecked " + isNewMenuItemChecked);
Log_OC.d(TAG, "onNavigationItemClicked nav_logout setChecked " + isNewMenuItemChecked);
final Optional<User> optionalUser = getUser();
if (optionalUser.isPresent()) {
UserInfoActivity.openAccountRemovalDialog(optionalUser.get(), getSupportFragmentManager());
Expand Down Expand Up @@ -1164,7 +1164,7 @@ public void showFiles(boolean onDeviceOnly, boolean onlyPersonalFiles) {
public void avatarGenerated(Drawable avatarDrawable, Object callContext) {
if (callContext instanceof MenuItem menuItem) {
MenuItem newIcon = menuItem.setIcon(avatarDrawable);
Log_OC.d(TAG,"avatarGenerated new icon: " + newIcon);
Log_OC.d(TAG, "avatarGenerated new icon: " + newIcon);
} else if (callContext instanceof ImageView imageView) {
imageView.setImageDrawable(avatarDrawable);
} else if (callContext instanceof MaterialButton materialButton) {
Expand Down Expand Up @@ -1229,60 +1229,60 @@ public void onAccountRemovedEvent(AccountRemovedEvent event) {
* Retrieves external links via api from 'external' app
*/
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) {
if (!getBaseContext().getResources().getBoolean(R.bool.show_external_links)) {
return;
}

Thread t = new Thread(() -> {
User user = accountManager.getUser();
if (user.isAnonymous()) {
accountManager.startAccountCreation(this);
alperozturk96 marked this conversation as resolved.
Show resolved Hide resolved
} else {
if ((getCapabilities() == null || getCapabilities().getAccountName() != null && getCapabilities().getAccountName().isEmpty()) && getStorageManager() != null) {
GetCapabilitiesOperation getCapabilities = new GetCapabilitiesOperation(getStorageManager());
getCapabilities.execute(getBaseContext());
}

User user = accountManager.getUser();
if (getStorageManager() != null && CapabilityUtils.getCapability(user, this)
.getExternalLinks().isTrue()) {

int count = arbitraryDataProvider.getIntegerValue(FilesSyncHelper.GLOBAL,
FileActivity.APP_OPENED_COUNT);
if (getStorageManager() != null && CapabilityUtils.getCapability(user, this).getExternalLinks().isTrue()) {
int count = arbitraryDataProvider.getIntegerValue(FilesSyncHelper.GLOBAL, FileActivity.APP_OPENED_COUNT);

if (count > 10 || count == -1 || force) {
if (force) {
Log_OC.d("ExternalLinks", "force update");
}

arbitraryDataProvider.storeOrUpdateKeyValue(FilesSyncHelper.GLOBAL,
FileActivity.APP_OPENED_COUNT, "0");
arbitraryDataProvider.storeOrUpdateKeyValue(FilesSyncHelper.GLOBAL, FileActivity.APP_OPENED_COUNT, "0");

Log_OC.d("ExternalLinks", "update via api");
RemoteOperation getExternalLinksOperation = new ExternalLinksOperation();
RemoteOperationResult result = getExternalLinksOperation.execute(user, this);

if (result.isSuccess() && result.getData() != null) {
externalLinksProvider.deleteAllExternalLinks();

ArrayList<ExternalLink> externalLinks = (ArrayList<ExternalLink>) (Object) result.getData();

ArrayList<ExternalLink> externalLinks = (ArrayList<ExternalLink>) result.getData();
for (ExternalLink link : externalLinks) {
externalLinksProvider.storeExternalLink(link);
}
}
} else {
arbitraryDataProvider.storeOrUpdateKeyValue(FilesSyncHelper.GLOBAL,
FileActivity.APP_OPENED_COUNT, String.valueOf(count + 1));
arbitraryDataProvider.storeOrUpdateKeyValue(FilesSyncHelper.GLOBAL, FileActivity.APP_OPENED_COUNT, String.valueOf(count + 1));
}
} else {
externalLinksProvider.deleteAllExternalLinks();
Log_OC.d("ExternalLinks", "links disabled");
}

runOnUiThread(this::updateExternalLinksInDrawer);
});
t.start();
}
}
});
t.start();
}

protected void handleDeepLink(@NonNull Uri uri) {
String path = uri.getLastPathSegment();
if (path == null) return;
if (path == null) {
return;
}

DeepLinkConstants deepLinkType = DeepLinkConstants.Companion.fromPath(path);
if (deepLinkType == null) {
Expand Down
Loading