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
9 changes: 2 additions & 7 deletions src/main/java/com/nextcloud/client/jobs/AccountRemovalWork.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ package com.nextcloud.client.jobs

import android.accounts.Account
import android.content.Context
import android.os.Build
import android.provider.DocumentsContract
import android.text.TextUtils
import androidx.work.Worker
import androidx.work.WorkerParameters
Expand All @@ -48,6 +46,7 @@ import com.owncloud.android.lib.common.OwnCloudClient
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
import com.owncloud.android.lib.common.utils.Log_OC
import com.owncloud.android.lib.resources.users.RemoteWipeSuccessRemoteOperation
import com.owncloud.android.providers.DocumentsStorageProvider
import com.owncloud.android.ui.activity.ContactsPreferenceActivity
import com.owncloud.android.ui.activity.ManageAccountsActivity
import com.owncloud.android.ui.events.AccountRemovedEvent
Expand Down Expand Up @@ -127,11 +126,7 @@ class AccountRemovalWork(
}
}
// notify Document Provider
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
val authority = context.resources.getString(R.string.document_provider_authority)
val rootsUri = DocumentsContract.buildRootsUri(authority)
context.contentResolver.notifyChange(rootsUri, null)
}
DocumentsStorageProvider.notifyRootsChanged(context)
return Result.success()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
import android.os.Handler;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.provider.DocumentsContract;
import android.text.TextUtils;
import android.util.AndroidRuntimeException;
import android.view.KeyEvent;
Expand Down Expand Up @@ -114,6 +113,7 @@
import com.owncloud.android.lib.resources.users.GetUserInfoRemoteOperation;
import com.owncloud.android.operations.DetectAuthenticationMethodOperation.AuthenticationMethod;
import com.owncloud.android.operations.GetServerInfoOperation;
import com.owncloud.android.providers.DocumentsStorageProvider;
import com.owncloud.android.services.OperationsService;
import com.owncloud.android.services.OperationsService.OperationsServiceBinder;
import com.owncloud.android.ui.activity.FileDisplayActivity;
Expand Down Expand Up @@ -1287,11 +1287,7 @@ protected boolean createAccount(RemoteOperationResult authResult) {
setResult(RESULT_OK, intent);

// notify Document Provider
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
String authority = getResources().getString(R.string.document_provider_authority);
Uri rootsUri = DocumentsContract.buildRootsUri(authority);
getContentResolver().notifyChange(rootsUri, null);
}
DocumentsStorageProvider.notifyRootsChanged(this);

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ public Cursor queryRoots(String[] projection) {
return result;
}

public static void notifyRootsChanged(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
String authority = context.getString(R.string.document_provider_authority);
Uri rootsUri = DocumentsContract.buildRootsUri(authority);
context.getContentResolver().notifyChange(rootsUri, null);
}
}

@Override
public Cursor queryDocument(String documentId, String[] projection) throws FileNotFoundException {
Log.d(TAG, "queryDocument(), id=" + documentId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import com.owncloud.android.lib.common.ExternalLink;
import com.owncloud.android.lib.common.ExternalLinkType;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.providers.DocumentsStorageProvider;
import com.owncloud.android.ui.asynctasks.LoadingVersionNumberTask;
import com.owncloud.android.utils.DeviceCredentialUtils;
import com.owncloud.android.utils.DisplayUtils;
Expand Down Expand Up @@ -641,12 +642,17 @@ private void enableLock(String lock) {
DisplayUtils.showSnackMessage(this, R.string.prefs_lock_device_credentials_not_setup);
} else {
DisplayUtils.showSnackMessage(this, R.string.prefs_lock_device_credentials_enabled);
this.lock.setValue(LOCK_DEVICE_CREDENTIALS);
this.lock.setSummary(this.lock.getEntry());
changeLockSetting(LOCK_DEVICE_CREDENTIALS);
}
}
}

private void changeLockSetting(String value) {
lock.setValue(value);
lock.setSummary(lock.getEntry());
DocumentsStorageProvider.notifyRootsChanged(this);
}

private void disableLock(String lock) {
if (LOCK_PASSCODE.equals(lock)) {
Intent i = new Intent(getApplicationContext(), PassCodeActivity.class);
Expand Down Expand Up @@ -819,14 +825,12 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
appPrefs.putString(PassCodeActivity.PREFERENCE_PASSCODE_D + i, passcode.substring(i - 1, i));
}
appPrefs.apply();
lock.setValue(LOCK_PASSCODE);
lock.setSummary(lock.getEntry());
changeLockSetting(LOCK_PASSCODE);
DisplayUtils.showSnackMessage(this, R.string.pass_code_stored);
}
} else if (requestCode == ACTION_CONFIRM_PASSCODE && resultCode == RESULT_OK) {
if (data.getBooleanExtra(PassCodeActivity.KEY_CHECK_RESULT, false)) {
lock.setValue(LOCK_NONE);
lock.setSummary(lock.getEntry());
changeLockSetting(LOCK_NONE);

DisplayUtils.showSnackMessage(this, R.string.pass_code_removed);
if (!LOCK_NONE.equals(pendingLock)) {
Expand All @@ -840,8 +844,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
data.getIntExtra(RequestCredentialsActivity.KEY_CHECK_RESULT,
RequestCredentialsActivity.KEY_CHECK_RESULT_FALSE) ==
RequestCredentialsActivity.KEY_CHECK_RESULT_TRUE) {
lock.setValue(LOCK_NONE);
lock.setSummary(lock.getEntry());
changeLockSetting(LOCK_NONE);
DisplayUtils.showSnackMessage(this, R.string.credentials_disabled);
if (!LOCK_NONE.equals(pendingLock)) {
enableLock(pendingLock);
Expand Down