Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasKaminsky committed Sep 24, 2020
2 parents ccd261f + 750e4de commit 1cadee3
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 24 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/autoApproveDependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Auto approve
on: pull_request

jobs:
auto-approve:
runs-on: ubuntu-latest
steps:
- uses: hmarr/auto-approve-action@v2.0.0
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
with:
github-token: "${{ secrets.DEPENDABOT_AUTOMERGE_TOKEN }}"
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 @@ -262,7 +262,7 @@ protected void onCreate(Bundle savedInstanceState) {
onboarding.launchFirstRunIfNeeded(this);
}

onlyAdd = getIntent().getBooleanExtra(KEY_ONLY_ADD, false);
onlyAdd = getIntent().getBooleanExtra(KEY_ONLY_ADD, false) || checkIfViaSSO(getIntent());

// delete cookies for webView
deleteCookies();
Expand Down Expand Up @@ -676,7 +676,7 @@ protected void onNewIntent(Intent intent) {
super.finish();
}

onlyAdd = intent.getBooleanExtra(KEY_ONLY_ADD, false);
onlyAdd = intent.getBooleanExtra(KEY_ONLY_ADD, false) || checkIfViaSSO(intent);

// Passcode
PassCodeManager passCodeManager = new PassCodeManager(preferences);
Expand All @@ -702,6 +702,15 @@ protected void onNewIntent(Intent intent) {
}
}

private boolean checkIfViaSSO(Intent intent) {
Bundle extras = intent.getExtras();
if (extras == null) {
return false;
} else {
return extras.getParcelable("accountAuthenticatorResponse") != null;
}
}


/**
* The redirection triggered by the OAuth authentication server as response to the GET AUTHORIZATION, and deferred
Expand Down Expand Up @@ -1124,7 +1133,9 @@ public void onAuthenticatorTaskCallback(RemoteOperationResult result) {

if (success) {
accountManager.setCurrentOwnCloudAccount(mAccount.name);
if (!onlyAdd) {
if (onlyAdd) {
finish();
} else {
Intent i = new Intent(this, FileDisplayActivity.class);
i.setAction(FileDisplayActivity.RESTART);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Expand Down Expand Up @@ -1287,11 +1298,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

0 comments on commit 1cadee3

Please sign in to comment.