diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 8080a21ce7..727c5da4b0 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -906,7 +906,7 @@ public class FileDisplayActivity extends HookActivity String synchFolderRemotePath = intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH); RemoteOperationResult synchResult = - (RemoteOperationResult)intent.getSerializableExtra( + (RemoteOperationResult) intent.getSerializableExtra( FileSyncAdapter.EXTRA_RESULT); boolean sameAccount = (getAccount() != null && accountName.equals(getAccount().name) && getStorageManager() != null); @@ -976,9 +976,6 @@ public class FileDisplayActivity extends HookActivity removeStickyBroadcast(intent); Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress); mProgressBar.setIndeterminate(mSyncInProgress); - //mProgressBar.setVisibility((mSyncInProgress) ? View.VISIBLE : View.INVISIBLE); - //setSupportProgressBarIndeterminateVisibility(mSyncInProgress - /*|| mRefreshSharesInProgress*/ //); setBackgroundText(); diff --git a/src/com/owncloud/android/ui/activity/Uploader.java b/src/com/owncloud/android/ui/activity/Uploader.java index c0574ebf79..6d1d28b674 100644 --- a/src/com/owncloud/android/ui/activity/Uploader.java +++ b/src/com/owncloud/android/ui/activity/Uploader.java @@ -23,7 +23,6 @@ package com.owncloud.android.ui.activity; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; @@ -34,30 +33,19 @@ import java.util.Vector; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountAuthenticator; -import com.owncloud.android.authentication.AuthenticatorActivity; -import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.files.services.FileUploader; -import com.owncloud.android.lib.common.OwnCloudAccount; -import com.owncloud.android.lib.common.OwnCloudClient; -import com.owncloud.android.lib.common.OwnCloudClientManagerFactory; -import com.owncloud.android.lib.common.OwnCloudCredentials; -import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.operations.RefreshFolderOperation; -import com.owncloud.android.operations.SynchronizeFolderOperation; import android.accounts.Account; import android.accounts.AccountManager; import android.accounts.AuthenticatorException; -import android.accounts.OperationCanceledException; import android.app.AlertDialog; import android.app.AlertDialog.Builder; -import android.accounts.Account; -import android.accounts.AccountManager; import android.app.Dialog; import android.app.ProgressDialog; import android.content.BroadcastReceiver; @@ -74,7 +62,6 @@ import android.net.Uri; import android.os.Bundle; import android.os.Parcelable; import android.preference.PreferenceManager; -import android.provider.MediaStore; import android.provider.MediaStore.Audio; import android.provider.MediaStore.Images; import android.provider.MediaStore.Video; @@ -92,20 +79,11 @@ import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import android.widget.ProgressBar; -import android.widget.SimpleAdapter; import android.widget.Toast; -import com.owncloud.android.MainApp; -import com.owncloud.android.R; -import com.owncloud.android.authentication.AccountAuthenticator; -import com.owncloud.android.datamodel.OCFile; -import com.owncloud.android.files.services.FileUploader; -import com.owncloud.android.lib.common.utils.Log_OC; -import com.owncloud.android.lib.common.operations.RemoteOperation; -import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.operations.CreateFolderOperation; import com.owncloud.android.syncadapter.FileSyncAdapter; -import com.owncloud.android.ui.adapter.ImageSimpleAdapter; +import com.owncloud.android.ui.adapter.UploaderAdapter; import com.owncloud.android.ui.dialog.CreateFolderDialogFragment; import com.owncloud.android.ui.dialog.LoadingDialog; import com.owncloud.android.utils.CopyTmpFileAsyncTask; @@ -476,7 +454,7 @@ public class Uploader extends FileActivity data.add(h); } - ImageSimpleAdapter sa = new ImageSimpleAdapter(this, + UploaderAdapter sa = new UploaderAdapter(this, data, R.layout.uploader_list_item_layout, new String[] {"dirname"}, @@ -766,15 +744,6 @@ public class Uploader extends FileActivity startSyncFolderOperation(root); } - protected void requestCredentialsUpdate() { - Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class); - updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, getAccount()) - .putExtra(AuthenticatorActivity.EXTRA_ACTION, - AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN) - .addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); - startActivity(updateAccountCredentials); - } - private class SyncBroadcastReceiver extends BroadcastReceiver { /** @@ -786,15 +755,19 @@ public class Uploader extends FileActivity String event = intent.getAction(); Log_OC.d(TAG, "Received broadcast " + event); String accountName = intent.getStringExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME); - String synchFolderRemotePath = intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH); - RemoteOperationResult synchResult = (RemoteOperationResult) intent.getSerializableExtra( - FileSyncAdapter.EXTRA_RESULT); - boolean sameAccount = (getAccount() != null && accountName.equals(getAccount().name) - && getStorageManager() != null); + String synchFolderRemotePath = + intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH); + RemoteOperationResult synchResult = + (RemoteOperationResult) intent.getSerializableExtra( + FileSyncAdapter.EXTRA_RESULT); + boolean sameAccount = (getAccount() != null && + accountName.equals(getAccount().name) && getStorageManager() != null); if (sameAccount) { + if (FileSyncAdapter.EVENT_FULL_SYNC_START.equals(event)) { mSyncInProgress = true; + } else { OCFile currentFile = (mFile == null) ? null : getStorageManager().getFileByPath(mFile.getRemotePath()); @@ -836,36 +809,12 @@ public class Uploader extends FileActivity (synchResult.isException() && synchResult.getException() instanceof AuthenticatorException))) { - OwnCloudClient client = null; - try { - OwnCloudAccount ocAccount = - new OwnCloudAccount(getAccount(), context); - client = (OwnCloudClientManagerFactory.getDefaultSingleton(). - removeClientFor(ocAccount)); - // TODO get rid of these exceptions - } catch (AccountNotFoundException e) { - e.printStackTrace(); - } - - if (client != null) { - OwnCloudCredentials cred = client.getCredentials(); - if (cred != null) { - AccountManager am = AccountManager.get(context); - if (cred.authTokenExpires()) { - am.invalidateAuthToken( - getAccount().type, - cred.getAuthToken() - ); - } else { - am.clearPassword(getAccount()); - } - } - } - requestCredentialsUpdate(); + requestCredentialsUpdate(context); } } removeStickyBroadcast(intent); Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress); + } } catch (RuntimeException e) { // avoid app crashes after changing the serial id of RemoteOperationResult diff --git a/src/com/owncloud/android/ui/adapter/ImageSimpleAdapter.java b/src/com/owncloud/android/ui/adapter/UploaderAdapter.java similarity index 93% rename from src/com/owncloud/android/ui/adapter/ImageSimpleAdapter.java rename to src/com/owncloud/android/ui/adapter/UploaderAdapter.java index 3a21deceaa..796959eda4 100644 --- a/src/com/owncloud/android/ui/adapter/ImageSimpleAdapter.java +++ b/src/com/owncloud/android/ui/adapter/UploaderAdapter.java @@ -41,16 +41,16 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -public class ImageSimpleAdapter extends SimpleAdapter { +public class UploaderAdapter extends SimpleAdapter { private Context mContext; private Account mAccount; private FileDataStorageManager mStorageManager; private LayoutInflater inflater; - public ImageSimpleAdapter(Context context, - List> data, int resource, String[] from, - int[] to, FileDataStorageManager storageManager, Account account) { + public UploaderAdapter(Context context, + List> data, int resource, String[] from, + int[] to, FileDataStorageManager storageManager, Account account) { super(context, data, resource, from, to); mAccount = account; mStorageManager = storageManager;