mirror of
https://github.com/nextcloud/android.git
synced 2024-11-21 20:55:31 +03:00
PMD appeased
Some warnings have been supressed.
This commit is contained in:
parent
97da0cbc94
commit
0a13a5b818
84 changed files with 845 additions and 811 deletions
|
@ -9,6 +9,7 @@
|
||||||
</description>
|
</description>
|
||||||
<exclude-pattern>.*/R.java</exclude-pattern>
|
<exclude-pattern>.*/R.java</exclude-pattern>
|
||||||
<exclude-pattern>.*/gen/.*</exclude-pattern>
|
<exclude-pattern>.*/gen/.*</exclude-pattern>
|
||||||
|
<exclude-pattern>.*/third_parties/.*</exclude-pattern>
|
||||||
|
|
||||||
<rule ref="rulesets/java/logging-java.xml" />
|
<rule ref="rulesets/java/logging-java.xml" />
|
||||||
<rule ref="rulesets/java/braces.xml" />
|
<rule ref="rulesets/java/braces.xml" />
|
||||||
|
|
|
@ -198,7 +198,7 @@ public class MainApp extends Application {
|
||||||
mOnlyOnDevice = state;
|
mOnlyOnDevice = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getOnlyOnDevice(){
|
public static boolean isOnlyOnDevice(){
|
||||||
return mOnlyOnDevice;
|
return mOnlyOnDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,8 +87,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
|
||||||
validateAccountType(accountType);
|
validateAccountType(accountType);
|
||||||
} catch (AuthenticatorException e) {
|
} catch (AuthenticatorException e) {
|
||||||
Log_OC.e(TAG, "Failed to validate account type " + accountType + ": "
|
Log_OC.e(TAG, "Failed to validate account type " + accountType + ": "
|
||||||
+ e.getMessage());
|
+ e.getMessage(), e);
|
||||||
e.printStackTrace();
|
|
||||||
return e.getFailureBundle();
|
return e.getFailureBundle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,8 +132,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
|
||||||
validateAccountType(account.type);
|
validateAccountType(account.type);
|
||||||
} catch (AuthenticatorException e) {
|
} catch (AuthenticatorException e) {
|
||||||
Log_OC.e(TAG, "Failed to validate account type " + account.type + ": "
|
Log_OC.e(TAG, "Failed to validate account type " + account.type + ": "
|
||||||
+ e.getMessage());
|
+ e.getMessage(), e);
|
||||||
e.printStackTrace();
|
|
||||||
return e.getFailureBundle();
|
return e.getFailureBundle();
|
||||||
}
|
}
|
||||||
Intent intent = new Intent(mContext, AuthenticatorActivity.class);
|
Intent intent = new Intent(mContext, AuthenticatorActivity.class);
|
||||||
|
@ -169,8 +167,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
|
||||||
validateAuthTokenType(authTokenType);
|
validateAuthTokenType(authTokenType);
|
||||||
} catch (AuthenticatorException e) {
|
} catch (AuthenticatorException e) {
|
||||||
Log_OC.e(TAG, "Failed to validate account type " + account.type + ": "
|
Log_OC.e(TAG, "Failed to validate account type " + account.type + ": "
|
||||||
+ e.getMessage());
|
+ e.getMessage(), e);
|
||||||
e.printStackTrace();
|
|
||||||
return e.getFailureBundle();
|
return e.getFailureBundle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ public class AccountUtils {
|
||||||
*/
|
*/
|
||||||
public static String getAccountUsername(String accountName) {
|
public static String getAccountUsername(String accountName) {
|
||||||
if (accountName != null) {
|
if (accountName != null) {
|
||||||
return accountName.substring(0, accountName.lastIndexOf("@"));
|
return accountName.substring(0, accountName.lastIndexOf('@'));
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -135,8 +135,9 @@ public class AccountUtils {
|
||||||
Account[] ocAccounts = AccountManager.get(context).getAccountsByType(
|
Account[] ocAccounts = AccountManager.get(context).getAccountsByType(
|
||||||
MainApp.getAccountType());
|
MainApp.getAccountType());
|
||||||
for (Account account : ocAccounts) {
|
for (Account account : ocAccounts) {
|
||||||
if(account.name.equals(accountName))
|
if(account.name.equals(accountName)) {
|
||||||
return account;
|
return account;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -241,15 +242,13 @@ public class AccountUtils {
|
||||||
);
|
);
|
||||||
|
|
||||||
// copy type of authentication
|
// copy type of authentication
|
||||||
String isSamlStr = accountMgr.getUserData(account, Constants.KEY_SUPPORTS_SAML_WEB_SSO);
|
final String isSamlStr = accountMgr.getUserData(account, Constants.KEY_SUPPORTS_SAML_WEB_SSO);
|
||||||
boolean isSaml = "TRUE".equals(isSamlStr);
|
if (Boolean.parseBoolean(isSamlStr)) {
|
||||||
if (isSaml) {
|
|
||||||
accountMgr.setUserData(newAccount, Constants.KEY_SUPPORTS_SAML_WEB_SSO, "TRUE");
|
accountMgr.setUserData(newAccount, Constants.KEY_SUPPORTS_SAML_WEB_SSO, "TRUE");
|
||||||
}
|
}
|
||||||
|
|
||||||
String isOauthStr = accountMgr.getUserData(account, Constants.KEY_SUPPORTS_OAUTH2);
|
final String isOauthStr = accountMgr.getUserData(account, Constants.KEY_SUPPORTS_OAUTH2);
|
||||||
boolean isOAuth = "TRUE".equals(isOauthStr);
|
if (Boolean.parseBoolean(isOauthStr)) {
|
||||||
if (isOAuth) {
|
|
||||||
accountMgr.setUserData(newAccount, Constants.KEY_SUPPORTS_OAUTH2, "TRUE");
|
accountMgr.setUserData(newAccount, Constants.KEY_SUPPORTS_OAUTH2, "TRUE");
|
||||||
}
|
}
|
||||||
/* TODO - study if it's possible to run this method in a background thread to copy the authToken
|
/* TODO - study if it's possible to run this method in a background thread to copy the authToken
|
||||||
|
|
|
@ -142,6 +142,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||||
private static final String KEY_ASYNC_TASK_IN_PROGRESS = "AUTH_IN_PROGRESS";
|
private static final String KEY_ASYNC_TASK_IN_PROGRESS = "AUTH_IN_PROGRESS";
|
||||||
public static final String PROTOCOL_SUFFIX = "://";
|
public static final String PROTOCOL_SUFFIX = "://";
|
||||||
public static final String LOGIN_URL_DATA_KEY_VALUE_SEPARATOR = ":";
|
public static final String LOGIN_URL_DATA_KEY_VALUE_SEPARATOR = ":";
|
||||||
|
private static final String HTTPS_PROTOCOL = "https://";
|
||||||
|
private static final String HTTP_PROTOCOL = "http://";
|
||||||
|
|
||||||
/// parameters from EXTRAs in starter Intent
|
/// parameters from EXTRAs in starter Intent
|
||||||
private byte mAction;
|
private byte mAction;
|
||||||
|
@ -167,7 +169,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||||
|
|
||||||
private boolean mServerIsChecked = false;
|
private boolean mServerIsChecked = false;
|
||||||
private boolean mServerIsValid = false;
|
private boolean mServerIsValid = false;
|
||||||
private boolean mPendingAutoCheck = false;
|
|
||||||
|
|
||||||
private GetServerInfoOperation.ServerInfo mServerInfo = new GetServerInfoOperation.ServerInfo();
|
private GetServerInfoOperation.ServerInfo mServerInfo = new GetServerInfoOperation.ServerInfo();
|
||||||
|
|
||||||
|
@ -408,11 +409,11 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||||
if (mAccount != null) {
|
if (mAccount != null) {
|
||||||
mServerInfo.mBaseUrl = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_BASE_URL);
|
mServerInfo.mBaseUrl = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_BASE_URL);
|
||||||
// TODO do next in a setter for mBaseUrl
|
// TODO do next in a setter for mBaseUrl
|
||||||
mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://");
|
mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith(HTTPS_PROTOCOL);
|
||||||
mServerInfo.mVersion = AccountUtils.getServerVersion(mAccount);
|
mServerInfo.mVersion = AccountUtils.getServerVersion(mAccount);
|
||||||
} else {
|
} else {
|
||||||
mServerInfo.mBaseUrl = getString(R.string.server_url).trim();
|
mServerInfo.mBaseUrl = getString(R.string.server_url).trim();
|
||||||
mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://");
|
mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith(HTTPS_PROTOCOL);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mServerStatusText = savedInstanceState.getInt(KEY_SERVER_STATUS_TEXT);
|
mServerStatusText = savedInstanceState.getInt(KEY_SERVER_STATUS_TEXT);
|
||||||
|
@ -492,24 +493,16 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||||
findViewById(R.id.scroll).setOnTouchListener(new OnTouchListener() {
|
findViewById(R.id.scroll).setOnTouchListener(new OnTouchListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View view, MotionEvent event) {
|
public boolean onTouch(View view, MotionEvent event) {
|
||||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
if (event.getAction() == MotionEvent.ACTION_DOWN &&
|
||||||
if (
|
AccountTypeUtils
|
||||||
AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(
|
.getAuthTokenTypeSamlSessionCookie(MainApp
|
||||||
MainApp.getAccountType()
|
.getAccountType()).equals(mAuthTokenType) &&
|
||||||
).equals(mAuthTokenType) &&
|
mHostUrlInput.hasFocus()) {
|
||||||
mHostUrlInput.hasFocus()
|
checkOcServer();
|
||||||
) {
|
|
||||||
checkOcServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/// step 4 - mark automatic check to be started when OperationsService is ready
|
|
||||||
mPendingAutoCheck = (savedInstanceState == null &&
|
|
||||||
(mAction != ACTION_CREATE || checkHostUrl));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1127,8 +1120,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success)
|
if (success) {
|
||||||
finish();
|
finish();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
updateStatusIconFailUserName();
|
updateStatusIconFailUserName();
|
||||||
showAuthStatus();
|
showAuthStatus();
|
||||||
|
@ -1197,14 +1191,15 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||||
|
|
||||||
// TODO remove, if possible
|
// TODO remove, if possible
|
||||||
private String normalizeUrl(String url, boolean sslWhenUnprefixed) {
|
private String normalizeUrl(String url, boolean sslWhenUnprefixed) {
|
||||||
|
|
||||||
if (url != null && url.length() > 0) {
|
if (url != null && url.length() > 0) {
|
||||||
url = url.trim();
|
url = url.trim();
|
||||||
if (!url.toLowerCase().startsWith("http://") &&
|
if (!url.toLowerCase().startsWith(HTTP_PROTOCOL) &&
|
||||||
!url.toLowerCase().startsWith("https://")) {
|
!url.toLowerCase().startsWith(HTTP_PROTOCOL)) {
|
||||||
if (sslWhenUnprefixed) {
|
if (sslWhenUnprefixed) {
|
||||||
url = "https://" + url;
|
url = HTTPS_PROTOCOL + url;
|
||||||
} else {
|
} else {
|
||||||
url = "http://" + url;
|
url = HTTP_PROTOCOL + url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1259,7 +1254,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||||
|
|
||||||
case OK_NO_SSL:
|
case OK_NO_SSL:
|
||||||
case OK:
|
case OK:
|
||||||
if (mHostUrlInput.getText().toString().trim().toLowerCase().startsWith("http://")) {
|
if (mHostUrlInput.getText().toString().trim().toLowerCase().startsWith(HTTP_PROTOCOL)) {
|
||||||
mServerStatusText = R.string.auth_connection_established;
|
mServerStatusText = R.string.auth_connection_established;
|
||||||
mServerStatusIcon = R.drawable.ic_ok;
|
mServerStatusIcon = R.drawable.ic_ok;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1340,7 +1335,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||||
|
|
||||||
case OK_NO_SSL:
|
case OK_NO_SSL:
|
||||||
case OK:
|
case OK:
|
||||||
if (mHostUrlInput.getText().toString().trim().toLowerCase().startsWith("http://")) {
|
if (mHostUrlInput.getText().toString().trim().toLowerCase().startsWith(HTTP_PROTOCOL)) {
|
||||||
mAuthStatusText = R.string.auth_connection_established;
|
mAuthStatusText = R.string.auth_connection_established;
|
||||||
mAuthStatusIcon = R.drawable.ic_ok;
|
mAuthStatusIcon = R.drawable.ic_ok;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1783,11 +1778,10 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (actionId == EditorInfo.IME_ACTION_NEXT && inputField != null &&
|
} else if (actionId == EditorInfo.IME_ACTION_NEXT && inputField != null &&
|
||||||
inputField.equals(mHostUrlInput)) {
|
inputField.equals(mHostUrlInput) &&
|
||||||
if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).
|
AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).
|
||||||
equals(mAuthTokenType)) {
|
equals(mAuthTokenType)) {
|
||||||
checkOcServer();
|
checkOcServer();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false; // always return false to grant that the software keyboard is hidden anyway
|
return false; // always return false to grant that the software keyboard is hidden anyway
|
||||||
}
|
}
|
||||||
|
@ -1848,7 +1842,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||||
mAuthToken = sessionCookie;
|
mAuthToken = sessionCookie;
|
||||||
getRemoteUserNameOperation(sessionCookie);
|
getRemoteUserNameOperation(sessionCookie);
|
||||||
Fragment fd = getSupportFragmentManager().findFragmentByTag(SAML_DIALOG_TAG);
|
Fragment fd = getSupportFragmentManager().findFragmentByTag(SAML_DIALOG_TAG);
|
||||||
if (fd != null && fd instanceof DialogFragment) {
|
if (fd instanceof DialogFragment) {
|
||||||
Dialog d = ((DialogFragment) fd).getDialog();
|
Dialog d = ((DialogFragment) fd).getDialog();
|
||||||
if (d != null && d.isShowing()) {
|
if (d != null && d.isShowing()) {
|
||||||
d.dismiss();
|
d.dismiss();
|
||||||
|
@ -1951,7 +1945,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||||
|
|
||||||
private void dismissDialog(String dialogTag) {
|
private void dismissDialog(String dialogTag) {
|
||||||
Fragment frag = getSupportFragmentManager().findFragmentByTag(dialogTag);
|
Fragment frag = getSupportFragmentManager().findFragmentByTag(dialogTag);
|
||||||
if (frag != null && frag instanceof DialogFragment) {
|
if (frag instanceof DialogFragment) {
|
||||||
DialogFragment dialog = (DialogFragment) frag;
|
DialogFragment dialog = (DialogFragment) frag;
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,8 @@ import java.lang.ref.WeakReference;
|
||||||
*/
|
*/
|
||||||
public class AuthenticatorAsyncTask extends AsyncTask<Object, Void, RemoteOperationResult> {
|
public class AuthenticatorAsyncTask extends AsyncTask<Object, Void, RemoteOperationResult> {
|
||||||
|
|
||||||
private static String REMOTE_PATH = "/";
|
private static final String REMOTE_PATH = "/";
|
||||||
private static boolean SUCCESS_IF_ABSENT = false;
|
private static final boolean SUCCESS_IF_ABSENT = false;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private final WeakReference<OnAuthenticatorTaskListener> mListener;
|
private final WeakReference<OnAuthenticatorTaskListener> mListener;
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class PassCodeManager {
|
||||||
// other activities may be exempted, if needed
|
// other activities may be exempted, if needed
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int PASS_CODE_TIMEOUT = 1000;
|
private static final int PASS_CODE_TIMEOUT = 1000;
|
||||||
// keeping a "low" positive value is the easiest way to prevent the pass code is requested on rotations
|
// keeping a "low" positive value is the easiest way to prevent the pass code is requested on rotations
|
||||||
|
|
||||||
public static PassCodeManager mPassCodeManagerInstance = null;
|
public static PassCodeManager mPassCodeManagerInstance = null;
|
||||||
|
|
|
@ -52,6 +52,7 @@ import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
@ -62,8 +63,12 @@ public class FileDataStorageManager {
|
||||||
private ContentResolver mContentResolver;
|
private ContentResolver mContentResolver;
|
||||||
private ContentProviderClient mContentProviderClient;
|
private ContentProviderClient mContentProviderClient;
|
||||||
private Account mAccount;
|
private Account mAccount;
|
||||||
|
private static final String AND = "=? AND ";
|
||||||
|
private static final String FAILED_TO_INSERT_MSG = "Fail to insert insert file to database ";
|
||||||
|
private static final String SENDING_TO_FILECONTENTPROVIDER_MSG = "Sending %d operations to FileContentProvider";
|
||||||
|
private static final String EXCEPTION_MSG = "Exception in batch of operations ";
|
||||||
|
|
||||||
private static String TAG = FileDataStorageManager.class.getSimpleName();
|
private static final String TAG = FileDataStorageManager.class.getSimpleName();
|
||||||
|
|
||||||
|
|
||||||
public FileDataStorageManager(Account account, ContentResolver cr) {
|
public FileDataStorageManager(Account account, ContentResolver cr) {
|
||||||
|
@ -179,8 +184,9 @@ public class FileDataStorageManager {
|
||||||
cv.put(ProviderTableMeta.FILE_NAME, file.getFileName());
|
cv.put(ProviderTableMeta.FILE_NAME, file.getFileName());
|
||||||
cv.put(ProviderTableMeta.FILE_PARENT, file.getParentId());
|
cv.put(ProviderTableMeta.FILE_PARENT, file.getParentId());
|
||||||
cv.put(ProviderTableMeta.FILE_PATH, file.getRemotePath());
|
cv.put(ProviderTableMeta.FILE_PATH, file.getRemotePath());
|
||||||
if (!file.isFolder())
|
if (!file.isFolder()) {
|
||||||
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
|
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
|
||||||
|
}
|
||||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name);
|
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name);
|
||||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
|
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
|
||||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData());
|
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData());
|
||||||
|
@ -219,8 +225,7 @@ public class FileDataStorageManager {
|
||||||
new String[]{String.valueOf(file.getFileId())});
|
new String[]{String.valueOf(file.getFileId())});
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log_OC.e(TAG,
|
Log_OC.e(TAG,
|
||||||
"Fail to insert insert file to database "
|
FAILED_TO_INSERT_MSG + e.getMessage());
|
||||||
+ e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -234,8 +239,7 @@ public class FileDataStorageManager {
|
||||||
ProviderTableMeta.CONTENT_URI_FILE, cv);
|
ProviderTableMeta.CONTENT_URI_FILE, cv);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log_OC.e(TAG,
|
Log_OC.e(TAG,
|
||||||
"Fail to insert insert file to database "
|
FAILED_TO_INSERT_MSG + e.getMessage());
|
||||||
+ e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (result_uri != null) {
|
if (result_uri != null) {
|
||||||
|
@ -332,7 +336,7 @@ public class FileDataStorageManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare operations to remove files in the given folder
|
// prepare operations to remove files in the given folder
|
||||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?" + " AND " +
|
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND +
|
||||||
ProviderTableMeta.FILE_PATH + "=?";
|
ProviderTableMeta.FILE_PATH + "=?";
|
||||||
String [] whereArgs = null;
|
String [] whereArgs = null;
|
||||||
for (OCFile file : filesToRemove) {
|
for (OCFile file : filesToRemove) {
|
||||||
|
@ -398,7 +402,7 @@ public class FileDataStorageManager {
|
||||||
|
|
||||||
// apply operations in batch
|
// apply operations in batch
|
||||||
ContentProviderResult[] results = null;
|
ContentProviderResult[] results = null;
|
||||||
Log_OC.d(TAG, "Sending " + operations.size() + " operations to FileContentProvider");
|
Log_OC.d(TAG, String.format(Locale.ENGLISH, SENDING_TO_FILECONTENTPROVIDER_MSG, operations.size()));
|
||||||
try {
|
try {
|
||||||
if (getContentResolver() != null) {
|
if (getContentResolver() != null) {
|
||||||
results = getContentResolver().applyBatch(MainApp.getAuthority(), operations);
|
results = getContentResolver().applyBatch(MainApp.getAuthority(), operations);
|
||||||
|
@ -407,11 +411,9 @@ public class FileDataStorageManager {
|
||||||
results = getContentProviderClient().applyBatch(operations);
|
results = getContentProviderClient().applyBatch(operations);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (OperationApplicationException e) {
|
} catch (OperationApplicationException | RemoteException e) {
|
||||||
Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage());
|
Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage());
|
||||||
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update new id in file objects for insertions
|
// update new id in file objects for insertions
|
||||||
|
@ -419,14 +421,14 @@ public class FileDataStorageManager {
|
||||||
long newId;
|
long newId;
|
||||||
Iterator<OCFile> filesIt = updatedFiles.iterator();
|
Iterator<OCFile> filesIt = updatedFiles.iterator();
|
||||||
OCFile file = null;
|
OCFile file = null;
|
||||||
for (int i = 0; i < results.length; i++) {
|
for (ContentProviderResult result : results) {
|
||||||
if (filesIt.hasNext()) {
|
if (filesIt.hasNext()) {
|
||||||
file = filesIt.next();
|
file = filesIt.next();
|
||||||
} else {
|
} else {
|
||||||
file = null;
|
file = null;
|
||||||
}
|
}
|
||||||
if (results[i].uri != null) {
|
if (result.uri != null) {
|
||||||
newId = Long.parseLong(results[i].uri.getPathSegments().get(1));
|
newId = Long.parseLong(result.uri.getPathSegments().get(1));
|
||||||
//updatedFiles.get(i).setFileId(newId);
|
//updatedFiles.get(i).setFileId(newId);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
file.setFileId(newId);
|
file.setFileId(newId);
|
||||||
|
@ -450,7 +452,7 @@ public class FileDataStorageManager {
|
||||||
// ""+file.getFileId());
|
// ""+file.getFileId());
|
||||||
Uri file_uri = ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILE,
|
Uri file_uri = ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILE,
|
||||||
file.getFileId());
|
file.getFileId());
|
||||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?" + " AND " +
|
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND +
|
||||||
ProviderTableMeta.FILE_PATH + "=?";
|
ProviderTableMeta.FILE_PATH + "=?";
|
||||||
String[] whereArgs = new String[]{mAccount.name, file.getRemotePath()};
|
String[] whereArgs = new String[]{mAccount.name, file.getRemotePath()};
|
||||||
int deleted = 0;
|
int deleted = 0;
|
||||||
|
@ -458,7 +460,7 @@ public class FileDataStorageManager {
|
||||||
try {
|
try {
|
||||||
deleted = getContentProviderClient().delete(file_uri, where, whereArgs);
|
deleted = getContentProviderClient().delete(file_uri, where, whereArgs);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
e.printStackTrace();
|
Log_OC.d(TAG, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
deleted = getContentResolver().delete(file_uri, where, whereArgs);
|
deleted = getContentResolver().delete(file_uri, where, whereArgs);
|
||||||
|
@ -502,7 +504,7 @@ public class FileDataStorageManager {
|
||||||
private boolean removeFolderInDb(OCFile folder) {
|
private boolean removeFolderInDb(OCFile folder) {
|
||||||
Uri folder_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, "" +
|
Uri folder_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, "" +
|
||||||
folder.getFileId()); // URI for recursive deletion
|
folder.getFileId()); // URI for recursive deletion
|
||||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?" + " AND " +
|
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND +
|
||||||
ProviderTableMeta.FILE_PATH + "=?";
|
ProviderTableMeta.FILE_PATH + "=?";
|
||||||
String [] whereArgs = new String[]{mAccount.name, folder.getRemotePath()};
|
String [] whereArgs = new String[]{mAccount.name, folder.getRemotePath()};
|
||||||
int deleted = 0;
|
int deleted = 0;
|
||||||
|
@ -510,7 +512,7 @@ public class FileDataStorageManager {
|
||||||
try {
|
try {
|
||||||
deleted = getContentProviderClient().delete(folder_uri, where, whereArgs);
|
deleted = getContentProviderClient().delete(folder_uri, where, whereArgs);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
e.printStackTrace();
|
Log_OC.d(TAG, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
deleted = getContentResolver().delete(folder_uri, where, whereArgs);
|
deleted = getContentResolver().delete(folder_uri, where, whereArgs);
|
||||||
|
@ -592,7 +594,7 @@ public class FileDataStorageManager {
|
||||||
c = getContentProviderClient().query(
|
c = getContentProviderClient().query(
|
||||||
ProviderTableMeta.CONTENT_URI,
|
ProviderTableMeta.CONTENT_URI,
|
||||||
null,
|
null,
|
||||||
ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " +
|
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND +
|
||||||
ProviderTableMeta.FILE_PATH + " LIKE ? ",
|
ProviderTableMeta.FILE_PATH + " LIKE ? ",
|
||||||
new String[]{
|
new String[]{
|
||||||
mAccount.name,
|
mAccount.name,
|
||||||
|
@ -608,7 +610,7 @@ public class FileDataStorageManager {
|
||||||
c = getContentResolver().query(
|
c = getContentResolver().query(
|
||||||
ProviderTableMeta.CONTENT_URI,
|
ProviderTableMeta.CONTENT_URI,
|
||||||
null,
|
null,
|
||||||
ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " +
|
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND +
|
||||||
ProviderTableMeta.FILE_PATH + " LIKE ? ",
|
ProviderTableMeta.FILE_PATH + " LIKE ? ",
|
||||||
new String[]{
|
new String[]{
|
||||||
mAccount.name,
|
mAccount.name,
|
||||||
|
@ -748,6 +750,23 @@ public class FileDataStorageManager {
|
||||||
Log_OC.e(TAG, e.getMessage());
|
Log_OC.e(TAG, e.getMessage());
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
} catch (IOException ex) {
|
||||||
|
ret = false;
|
||||||
|
} finally {
|
||||||
|
if (in != null) {
|
||||||
|
try {
|
||||||
|
in.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log_OC.d(TAG, e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (out != null) {
|
||||||
|
try {
|
||||||
|
out.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log_OC.d(TAG, e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<ContentProviderOperation> operations =
|
ArrayList<ContentProviderOperation> operations =
|
||||||
|
@ -810,17 +829,16 @@ public class FileDataStorageManager {
|
||||||
new String[]{String.valueOf(parentId)}, null);
|
new String[]{String.valueOf(parentId)}, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c.moveToFirst()) {
|
if (c != null && c.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
OCFile child = createFileInstance(c);
|
OCFile child = createFileInstance(c);
|
||||||
if (child.isFolder() || !onlyOnDevice || onlyOnDevice && child.isDown()){
|
if (child.isFolder() || !onlyOnDevice || child.isDown()){
|
||||||
ret.add(child);
|
ret.add(child);
|
||||||
}
|
}
|
||||||
} while (c.moveToNext());
|
} while (c.moveToNext());
|
||||||
|
c.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
c.close();
|
|
||||||
|
|
||||||
Collections.sort(ret);
|
Collections.sort(ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -841,7 +859,7 @@ public class FileDataStorageManager {
|
||||||
c = getContentResolver()
|
c = getContentResolver()
|
||||||
.query(ProviderTableMeta.CONTENT_URI,
|
.query(ProviderTableMeta.CONTENT_URI,
|
||||||
null,
|
null,
|
||||||
cmp_key + "=? AND "
|
cmp_key + AND
|
||||||
+ ProviderTableMeta.FILE_ACCOUNT_OWNER
|
+ ProviderTableMeta.FILE_ACCOUNT_OWNER
|
||||||
+ "=?",
|
+ "=?",
|
||||||
new String[]{value, mAccount.name}, null);
|
new String[]{value, mAccount.name}, null);
|
||||||
|
@ -850,7 +868,7 @@ public class FileDataStorageManager {
|
||||||
c = getContentProviderClient().query(
|
c = getContentProviderClient().query(
|
||||||
ProviderTableMeta.CONTENT_URI,
|
ProviderTableMeta.CONTENT_URI,
|
||||||
null,
|
null,
|
||||||
cmp_key + "=? AND "
|
cmp_key + AND
|
||||||
+ ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?",
|
+ ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?",
|
||||||
new String[]{value, mAccount.name}, null);
|
new String[]{value, mAccount.name}, null);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
@ -871,7 +889,7 @@ public class FileDataStorageManager {
|
||||||
c = getContentResolver()
|
c = getContentResolver()
|
||||||
.query(ProviderTableMeta.CONTENT_URI,
|
.query(ProviderTableMeta.CONTENT_URI,
|
||||||
null,
|
null,
|
||||||
key + "=? AND "
|
key + AND
|
||||||
+ ProviderTableMeta.FILE_ACCOUNT_OWNER
|
+ ProviderTableMeta.FILE_ACCOUNT_OWNER
|
||||||
+ "=?",
|
+ "=?",
|
||||||
new String[]{value, mAccount.name}, null);
|
new String[]{value, mAccount.name}, null);
|
||||||
|
@ -880,7 +898,7 @@ public class FileDataStorageManager {
|
||||||
c = getContentProviderClient().query(
|
c = getContentProviderClient().query(
|
||||||
ProviderTableMeta.CONTENT_URI,
|
ProviderTableMeta.CONTENT_URI,
|
||||||
null,
|
null,
|
||||||
key + "=? AND " + ProviderTableMeta.FILE_ACCOUNT_OWNER
|
key + AND + ProviderTableMeta.FILE_ACCOUNT_OWNER
|
||||||
+ "=?", new String[]{value, mAccount.name},
|
+ "=?", new String[]{value, mAccount.name},
|
||||||
null);
|
null);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
@ -983,8 +1001,7 @@ public class FileDataStorageManager {
|
||||||
new String[]{String.valueOf(share.getRemoteId())});
|
new String[]{String.valueOf(share.getRemoteId())});
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log_OC.e(TAG,
|
Log_OC.e(TAG,
|
||||||
"Fail to insert insert file to database "
|
FAILED_TO_INSERT_MSG + e.getMessage());
|
||||||
+ e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -998,8 +1015,7 @@ public class FileDataStorageManager {
|
||||||
ProviderTableMeta.CONTENT_URI_SHARE, cv);
|
ProviderTableMeta.CONTENT_URI_SHARE, cv);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log_OC.e(TAG,
|
Log_OC.e(TAG,
|
||||||
"Fail to insert insert file to database "
|
FAILED_TO_INSERT_MSG + e.getMessage());
|
||||||
+ e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (result_uri != null) {
|
if (result_uri != null) {
|
||||||
|
@ -1076,7 +1092,7 @@ public class FileDataStorageManager {
|
||||||
c = getContentResolver()
|
c = getContentResolver()
|
||||||
.query(ProviderTableMeta.CONTENT_URI_SHARE,
|
.query(ProviderTableMeta.CONTENT_URI_SHARE,
|
||||||
null,
|
null,
|
||||||
key + "=? AND "
|
key + AND
|
||||||
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?",
|
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?",
|
||||||
new String[]{value, mAccount.name},
|
new String[]{value, mAccount.name},
|
||||||
null
|
null
|
||||||
|
@ -1086,7 +1102,7 @@ public class FileDataStorageManager {
|
||||||
c = getContentProviderClient().query(
|
c = getContentProviderClient().query(
|
||||||
ProviderTableMeta.CONTENT_URI_SHARE,
|
ProviderTableMeta.CONTENT_URI_SHARE,
|
||||||
null,
|
null,
|
||||||
key + "=? AND "
|
key + AND
|
||||||
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?",
|
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?",
|
||||||
new String[]{value, mAccount.name},
|
new String[]{value, mAccount.name},
|
||||||
null
|
null
|
||||||
|
@ -1116,8 +1132,8 @@ public class FileDataStorageManager {
|
||||||
shareWith = "";
|
shareWith = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
String selection = ProviderTableMeta.OCSHARES_PATH + "=? AND "
|
String selection = ProviderTableMeta.OCSHARES_PATH + AND
|
||||||
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? AND "
|
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + AND
|
||||||
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?" ;
|
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?" ;
|
||||||
if (!ShareType.PUBLIC_LINK.equals(type)) {
|
if (!ShareType.PUBLIC_LINK.equals(type)) {
|
||||||
selection += " AND " + ProviderTableMeta.OCSHARES_SHARE_WITH + "=?";
|
selection += " AND " + ProviderTableMeta.OCSHARES_SHARE_WITH + "=?";
|
||||||
|
@ -1223,7 +1239,7 @@ public class FileDataStorageManager {
|
||||||
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, false);
|
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, false);
|
||||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
|
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
|
||||||
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
|
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
|
||||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " +
|
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND +
|
||||||
ProviderTableMeta.FILE_PARENT + "=?";
|
ProviderTableMeta.FILE_PARENT + "=?";
|
||||||
String [] whereArgs = new String[] { mAccount.name , String.valueOf(folder.getFileId()) };
|
String [] whereArgs = new String[] { mAccount.name , String.valueOf(folder.getFileId()) };
|
||||||
|
|
||||||
|
@ -1245,7 +1261,7 @@ public class FileDataStorageManager {
|
||||||
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, false);
|
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, false);
|
||||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
|
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
|
||||||
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
|
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
|
||||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " +
|
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND +
|
||||||
ProviderTableMeta.FILE_PATH+ "=?";
|
ProviderTableMeta.FILE_PATH+ "=?";
|
||||||
String [] whereArgs = new String[] { mAccount.name , filePath };
|
String [] whereArgs = new String[] { mAccount.name , filePath };
|
||||||
|
|
||||||
|
@ -1328,8 +1344,7 @@ public class FileDataStorageManager {
|
||||||
if (operations.size() > 0) {
|
if (operations.size() > 0) {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
ContentProviderResult[] results = null;
|
ContentProviderResult[] results = null;
|
||||||
Log_OC.d(TAG, "Sending " + operations.size() +
|
Log_OC.d(TAG, String.format(Locale.ENGLISH, SENDING_TO_FILECONTENTPROVIDER_MSG, operations.size()));
|
||||||
" operations to FileContentProvider");
|
|
||||||
try {
|
try {
|
||||||
if (getContentResolver() != null) {
|
if (getContentResolver() != null) {
|
||||||
results = getContentResolver().applyBatch(MainApp.getAuthority(),
|
results = getContentResolver().applyBatch(MainApp.getAuthority(),
|
||||||
|
@ -1339,10 +1354,10 @@ public class FileDataStorageManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (OperationApplicationException e) {
|
} catch (OperationApplicationException e) {
|
||||||
Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage());
|
Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage());
|
||||||
|
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage());
|
Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1420,8 +1435,7 @@ public class FileDataStorageManager {
|
||||||
if (operations.size() > 0) {
|
if (operations.size() > 0) {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
ContentProviderResult[] results = null;
|
ContentProviderResult[] results = null;
|
||||||
Log_OC.d(TAG, "Sending " + operations.size() +
|
Log_OC.d(TAG, String.format(Locale.ENGLISH, SENDING_TO_FILECONTENTPROVIDER_MSG, operations.size()));
|
||||||
" operations to FileContentProvider");
|
|
||||||
try {
|
try {
|
||||||
if (getContentResolver() != null) {
|
if (getContentResolver() != null) {
|
||||||
results = getContentResolver().applyBatch(MainApp.getAuthority(), operations);
|
results = getContentResolver().applyBatch(MainApp.getAuthority(), operations);
|
||||||
|
@ -1429,11 +1443,9 @@ public class FileDataStorageManager {
|
||||||
results = getContentProviderClient().applyBatch(operations);
|
results = getContentProviderClient().applyBatch(operations);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (OperationApplicationException e) {
|
} catch (OperationApplicationException | RemoteException e) {
|
||||||
Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage());
|
Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage());
|
||||||
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1442,14 +1454,14 @@ public class FileDataStorageManager {
|
||||||
|
|
||||||
public void removeShare(OCShare share) {
|
public void removeShare(OCShare share) {
|
||||||
Uri share_uri = ProviderTableMeta.CONTENT_URI_SHARE;
|
Uri share_uri = ProviderTableMeta.CONTENT_URI_SHARE;
|
||||||
String where = ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?" + " AND " +
|
String where = ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + AND +
|
||||||
ProviderTableMeta._ID + "=?";
|
ProviderTableMeta._ID + "=?";
|
||||||
String [] whereArgs = new String[]{mAccount.name, Long.toString(share.getId())};
|
String [] whereArgs = new String[]{mAccount.name, Long.toString(share.getId())};
|
||||||
if (getContentProviderClient() != null) {
|
if (getContentProviderClient() != null) {
|
||||||
try {
|
try {
|
||||||
getContentProviderClient().delete(share_uri, where, whereArgs);
|
getContentProviderClient().delete(share_uri, where, whereArgs);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
e.printStackTrace();
|
Log_OC.d(TAG, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
getContentResolver().delete(share_uri, where, whereArgs);
|
getContentResolver().delete(share_uri, where, whereArgs);
|
||||||
|
@ -1474,7 +1486,7 @@ public class FileDataStorageManager {
|
||||||
|
|
||||||
// apply operations in batch
|
// apply operations in batch
|
||||||
if (operations.size() > 0) {
|
if (operations.size() > 0) {
|
||||||
Log_OC.d(TAG, "Sending " + operations.size() + " operations to FileContentProvider");
|
Log_OC.d(TAG, String.format(Locale.ENGLISH, SENDING_TO_FILECONTENTPROVIDER_MSG, operations.size()));
|
||||||
try {
|
try {
|
||||||
if (getContentResolver() != null) {
|
if (getContentResolver() != null) {
|
||||||
getContentResolver().applyBatch(MainApp.getAuthority(), operations);
|
getContentResolver().applyBatch(MainApp.getAuthority(), operations);
|
||||||
|
@ -1483,11 +1495,9 @@ public class FileDataStorageManager {
|
||||||
getContentProviderClient().applyBatch(operations);
|
getContentProviderClient().applyBatch(operations);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (OperationApplicationException e) {
|
} catch (OperationApplicationException | RemoteException e) {
|
||||||
Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage());
|
Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage());
|
||||||
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1522,7 +1532,7 @@ public class FileDataStorageManager {
|
||||||
operations = prepareRemoveSharesInFile(remotePath, operations);
|
operations = prepareRemoveSharesInFile(remotePath, operations);
|
||||||
// apply operations in batch
|
// apply operations in batch
|
||||||
if (operations.size() > 0) {
|
if (operations.size() > 0) {
|
||||||
Log_OC.d(TAG, "Sending " + operations.size() + " operations to FileContentProvider");
|
Log_OC.d(TAG, String.format(Locale.ENGLISH, SENDING_TO_FILECONTENTPROVIDER_MSG, operations.size()));
|
||||||
try {
|
try {
|
||||||
if (getContentResolver() != null) {
|
if (getContentResolver() != null) {
|
||||||
getContentResolver().applyBatch(MainApp.getAuthority(), operations);
|
getContentResolver().applyBatch(MainApp.getAuthority(), operations);
|
||||||
|
@ -1531,11 +1541,9 @@ public class FileDataStorageManager {
|
||||||
getContentProviderClient().applyBatch(operations);
|
getContentProviderClient().applyBatch(operations);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (OperationApplicationException e) {
|
} catch (OperationApplicationException | RemoteException e) {
|
||||||
Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage());
|
Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage());
|
||||||
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1553,7 +1561,7 @@ public class FileDataStorageManager {
|
||||||
|
|
||||||
// apply operations in batch
|
// apply operations in batch
|
||||||
if (operations.size() > 0) {
|
if (operations.size() > 0) {
|
||||||
Log_OC.d(TAG, "Sending " + operations.size() + " operations to FileContentProvider");
|
Log_OC.d(TAG, String.format(Locale.ENGLISH, SENDING_TO_FILECONTENTPROVIDER_MSG, operations.size()));
|
||||||
try {
|
try {
|
||||||
if (getContentResolver() != null) {
|
if (getContentResolver() != null) {
|
||||||
getContentResolver().applyBatch(MainApp.getAuthority(), operations);
|
getContentResolver().applyBatch(MainApp.getAuthority(), operations);
|
||||||
|
@ -1563,10 +1571,8 @@ public class FileDataStorageManager {
|
||||||
getContentProviderClient().applyBatch(operations);
|
getContentProviderClient().applyBatch(operations);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (OperationApplicationException e) {
|
} catch (OperationApplicationException | RemoteException e) {
|
||||||
Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage());
|
Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage());
|
||||||
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1618,7 +1624,7 @@ public class FileDataStorageManager {
|
||||||
private ArrayList<ContentProviderOperation> prepareRemoveSharesInFolder(
|
private ArrayList<ContentProviderOperation> prepareRemoveSharesInFolder(
|
||||||
OCFile folder, ArrayList<ContentProviderOperation> preparedOperations) {
|
OCFile folder, ArrayList<ContentProviderOperation> preparedOperations) {
|
||||||
if (folder != null) {
|
if (folder != null) {
|
||||||
String where = ProviderTableMeta.OCSHARES_PATH + "=?" + " AND "
|
String where = ProviderTableMeta.OCSHARES_PATH + AND
|
||||||
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
|
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
|
||||||
String [] whereArgs = new String[]{ "", mAccount.name };
|
String [] whereArgs = new String[]{ "", mAccount.name };
|
||||||
|
|
||||||
|
@ -1640,7 +1646,7 @@ public class FileDataStorageManager {
|
||||||
private ArrayList<ContentProviderOperation> prepareRemoveSharesInFile(
|
private ArrayList<ContentProviderOperation> prepareRemoveSharesInFile(
|
||||||
String filePath, ArrayList<ContentProviderOperation> preparedOperations) {
|
String filePath, ArrayList<ContentProviderOperation> preparedOperations) {
|
||||||
|
|
||||||
String where = ProviderTableMeta.OCSHARES_PATH + "=?" + " AND "
|
String where = ProviderTableMeta.OCSHARES_PATH + AND
|
||||||
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
|
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
|
||||||
String[] whereArgs = new String[]{filePath, mAccount.name};
|
String[] whereArgs = new String[]{filePath, mAccount.name};
|
||||||
|
|
||||||
|
@ -1656,8 +1662,8 @@ public class FileDataStorageManager {
|
||||||
|
|
||||||
public ArrayList<OCShare> getSharesWithForAFile(String filePath, String accountName){
|
public ArrayList<OCShare> getSharesWithForAFile(String filePath, String accountName){
|
||||||
// Condition
|
// Condition
|
||||||
String where = ProviderTableMeta.OCSHARES_PATH + "=?" + " AND "
|
String where = ProviderTableMeta.OCSHARES_PATH + AND
|
||||||
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?"+ "AND"
|
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + AND
|
||||||
+ " (" + ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? OR "
|
+ " (" + ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? OR "
|
||||||
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? OR "
|
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? OR "
|
||||||
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? ) ";
|
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? ) ";
|
||||||
|
@ -1785,13 +1791,12 @@ public class FileDataStorageManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ancestorIds.size() > 0) {
|
if (ancestorIds.size() > 0) {
|
||||||
StringBuffer whereBuffer = new StringBuffer();
|
final StringBuffer whereBuffer = new StringBuffer();
|
||||||
whereBuffer.append(ProviderTableMeta._ID).append(" IN (");
|
whereBuffer.append(ProviderTableMeta._ID).append(" IN (");
|
||||||
for (int i = 0; i < ancestorIds.size() - 1; i++) {
|
for (int i = 0; i < ancestorIds.size() - 1; i++) {
|
||||||
whereBuffer.append("?,");
|
whereBuffer.append("?,");
|
||||||
}
|
}
|
||||||
whereBuffer.append("?");
|
whereBuffer.append("?)");
|
||||||
whereBuffer.append(")");
|
|
||||||
|
|
||||||
if (getContentResolver() != null) {
|
if (getContentResolver() != null) {
|
||||||
updated = getContentResolver().update(
|
updated = getContentResolver().update(
|
||||||
|
@ -1829,7 +1834,7 @@ public class FileDataStorageManager {
|
||||||
String whereForDescencentsInConflict =
|
String whereForDescencentsInConflict =
|
||||||
ProviderTableMeta.FILE_ETAG_IN_CONFLICT + " IS NOT NULL AND " +
|
ProviderTableMeta.FILE_ETAG_IN_CONFLICT + " IS NOT NULL AND " +
|
||||||
ProviderTableMeta.FILE_CONTENT_TYPE + " != 'DIR' AND " +
|
ProviderTableMeta.FILE_CONTENT_TYPE + " != 'DIR' AND " +
|
||||||
ProviderTableMeta.FILE_ACCOUNT_OWNER + " = ? AND " +
|
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND +
|
||||||
ProviderTableMeta.FILE_PATH + " LIKE ?";
|
ProviderTableMeta.FILE_PATH + " LIKE ?";
|
||||||
Cursor descendentsInConflict = null;
|
Cursor descendentsInConflict = null;
|
||||||
if (getContentResolver() != null) {
|
if (getContentResolver() != null) {
|
||||||
|
@ -1859,7 +1864,7 @@ public class FileDataStorageManager {
|
||||||
updated = getContentResolver().update(
|
updated = getContentResolver().update(
|
||||||
ProviderTableMeta.CONTENT_URI_FILE,
|
ProviderTableMeta.CONTENT_URI_FILE,
|
||||||
cv,
|
cv,
|
||||||
ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " +
|
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND +
|
||||||
ProviderTableMeta.FILE_PATH + "=?",
|
ProviderTableMeta.FILE_PATH + "=?",
|
||||||
new String[]{mAccount.name, parentPath}
|
new String[]{mAccount.name, parentPath}
|
||||||
);
|
);
|
||||||
|
@ -1868,7 +1873,7 @@ public class FileDataStorageManager {
|
||||||
updated = getContentProviderClient().update(
|
updated = getContentProviderClient().update(
|
||||||
ProviderTableMeta.CONTENT_URI_FILE,
|
ProviderTableMeta.CONTENT_URI_FILE,
|
||||||
cv,
|
cv,
|
||||||
ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " +
|
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND +
|
||||||
ProviderTableMeta.FILE_PATH + "=?"
|
ProviderTableMeta.FILE_PATH + "=?"
|
||||||
, new String[]{mAccount.name, parentPath}
|
, new String[]{mAccount.name, parentPath}
|
||||||
);
|
);
|
||||||
|
@ -1944,8 +1949,7 @@ public class FileDataStorageManager {
|
||||||
new String[]{mAccount.name});
|
new String[]{mAccount.name});
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log_OC.e(TAG,
|
Log_OC.e(TAG,
|
||||||
"Fail to insert insert file to database "
|
FAILED_TO_INSERT_MSG + e.getMessage());
|
||||||
+ e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1959,8 +1963,7 @@ public class FileDataStorageManager {
|
||||||
ProviderTableMeta.CONTENT_URI_CAPABILITIES, cv);
|
ProviderTableMeta.CONTENT_URI_CAPABILITIES, cv);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log_OC.e(TAG,
|
Log_OC.e(TAG,
|
||||||
"Fail to insert insert capability to database "
|
FAILED_TO_INSERT_MSG + e.getMessage());
|
||||||
+ e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (result_uri != null) {
|
if (result_uri != null) {
|
||||||
|
|
|
@ -549,8 +549,12 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) {
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
OCFile ocFile = (OCFile) o;
|
OCFile ocFile = (OCFile) o;
|
||||||
|
|
||||||
|
@ -643,7 +647,7 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInConflict() {
|
public boolean isInConflict() {
|
||||||
return mEtagInConflict != null && mEtagInConflict != "";
|
return mEtagInConflict != null && !mEtagInConflict.equals("");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEtagInConflict(String etagInConflict) {
|
public void setEtagInConflict(String etagInConflict) {
|
||||||
|
|
|
@ -163,15 +163,17 @@ public class ThumbnailsCacheManager {
|
||||||
Account account) {
|
Account account) {
|
||||||
// Use a WeakReference to ensure the ImageView can be garbage collected
|
// Use a WeakReference to ensure the ImageView can be garbage collected
|
||||||
mImageViewReference = new WeakReference<ImageView>(imageView);
|
mImageViewReference = new WeakReference<ImageView>(imageView);
|
||||||
if (storageManager == null)
|
if (storageManager == null) {
|
||||||
throw new IllegalArgumentException("storageManager must not be NULL");
|
throw new IllegalArgumentException("storageManager must not be NULL");
|
||||||
|
}
|
||||||
mStorageManager = storageManager;
|
mStorageManager = storageManager;
|
||||||
mAccount = account;
|
mAccount = account;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ThumbnailGenerationTask(FileDataStorageManager storageManager, Account account){
|
public ThumbnailGenerationTask(FileDataStorageManager storageManager, Account account){
|
||||||
if (storageManager == null)
|
if (storageManager == null) {
|
||||||
throw new IllegalArgumentException("storageManager must not be NULL");
|
throw new IllegalArgumentException("storageManager must not be NULL");
|
||||||
|
}
|
||||||
mStorageManager = storageManager;
|
mStorageManager = storageManager;
|
||||||
mAccount = account;
|
mAccount = account;
|
||||||
mImageViewReference = null;
|
mImageViewReference = null;
|
||||||
|
@ -198,17 +200,17 @@ public class ThumbnailsCacheManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
mFile = params[0];
|
mFile = params[0];
|
||||||
if (params.length == 2){
|
if (params.length == 2) {
|
||||||
mImageKey = (String) params[1];
|
mImageKey = (String) params[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mFile instanceof OCFile) {
|
if (mFile instanceof OCFile) {
|
||||||
thumbnail = doOCFileInBackground();
|
thumbnail = doOCFileInBackground();
|
||||||
|
|
||||||
if (MimeTypeUtil.isVideo((OCFile) mFile) && thumbnail != null) {
|
if (MimeTypeUtil.isVideo((OCFile) mFile) && thumbnail != null) {
|
||||||
thumbnail = addVideoOverlay(thumbnail);
|
thumbnail = addVideoOverlay(thumbnail);
|
||||||
}
|
}
|
||||||
} else if (mFile instanceof File) {
|
} else if (mFile instanceof File) {
|
||||||
thumbnail = doFileInBackground();
|
thumbnail = doFileInBackground();
|
||||||
|
|
||||||
String url = ((File) mFile).getAbsolutePath();
|
String url = ((File) mFile).getAbsolutePath();
|
||||||
|
@ -217,16 +219,15 @@ public class ThumbnailsCacheManager {
|
||||||
if (MimeTypeUtil.isVideo(mMimeType) && thumbnail != null) {
|
if (MimeTypeUtil.isVideo(mMimeType) && thumbnail != null) {
|
||||||
thumbnail = addVideoOverlay(thumbnail);
|
thumbnail = addVideoOverlay(thumbnail);
|
||||||
}
|
}
|
||||||
//} else { do nothing
|
//} else { do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
}catch(Throwable t){
|
} catch(OutOfMemoryError oome) {
|
||||||
// the app should never break due to a problem with thumbnails
|
System.gc();
|
||||||
Log_OC.e(TAG, "Generation of thumbnail for " + mFile + " failed", t);
|
} catch (Throwable t) {
|
||||||
if (t instanceof OutOfMemoryError) {
|
// the app should never break due to a problem with thumbnails
|
||||||
System.gc();
|
Log_OC.e(TAG, "Generation of thumbnail for " + mFile + " failed", t);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return thumbnail;
|
return thumbnail;
|
||||||
}
|
}
|
||||||
|
@ -343,7 +344,7 @@ public class ThumbnailsCacheManager {
|
||||||
mClient.exhaustResponse(get.getResponseBodyAsStream());
|
mClient.exhaustResponse(get.getResponseBodyAsStream());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
Log_OC.d(TAG, e.getMessage(), e);
|
||||||
} finally {
|
} finally {
|
||||||
if (get != null) {
|
if (get != null) {
|
||||||
get.releaseConnection();
|
get.releaseConnection();
|
||||||
|
@ -401,8 +402,9 @@ public class ThumbnailsCacheManager {
|
||||||
FileDataStorageManager storageManager, Account account) {
|
FileDataStorageManager storageManager, Account account) {
|
||||||
mAvatarGenerationListener = new WeakReference<>(avatarGenerationListener);
|
mAvatarGenerationListener = new WeakReference<>(avatarGenerationListener);
|
||||||
mCallContext = callContext;
|
mCallContext = callContext;
|
||||||
if (storageManager == null)
|
if (storageManager == null) {
|
||||||
throw new IllegalArgumentException("storageManager must not be NULL");
|
throw new IllegalArgumentException("storageManager must not be NULL");
|
||||||
|
}
|
||||||
mAccount = account;
|
mAccount = account;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,12 +424,11 @@ public class ThumbnailsCacheManager {
|
||||||
mUsername = params[0];
|
mUsername = params[0];
|
||||||
thumbnail = doAvatarInBackground();
|
thumbnail = doAvatarInBackground();
|
||||||
|
|
||||||
|
} catch(OutOfMemoryError oome) {
|
||||||
|
System.gc(); // todo, does this really make sense?
|
||||||
} catch(Throwable t){
|
} catch(Throwable t){
|
||||||
// the app should never break due to a problem with avatars
|
// the app should never break due to a problem with avatars
|
||||||
Log_OC.e(TAG, "Generation of avatar for " + mUsername + " failed", t);
|
Log_OC.e(TAG, "Generation of avatar for " + mUsername + " failed", t);
|
||||||
if (t instanceof OutOfMemoryError) {
|
|
||||||
System.gc();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return thumbnail;
|
return thumbnail;
|
||||||
|
@ -435,15 +436,12 @@ public class ThumbnailsCacheManager {
|
||||||
|
|
||||||
protected void onPostExecute(Bitmap bitmap) {
|
protected void onPostExecute(Bitmap bitmap) {
|
||||||
if (bitmap != null) {
|
if (bitmap != null) {
|
||||||
if (mAvatarGenerationListener != null) {
|
AvatarGenerationListener listener = mAvatarGenerationListener.get();
|
||||||
AvatarGenerationListener listener = mAvatarGenerationListener.get();
|
AvatarGenerationTask avatarWorkerTask = getAvatarWorkerTask(mCallContext);
|
||||||
AvatarGenerationTask avatarWorkerTask = getAvatarWorkerTask(mCallContext);
|
if (this == avatarWorkerTask
|
||||||
if (this == avatarWorkerTask) {
|
&& listener.shouldCallGeneratedCallback(mUsername, mCallContext)) {
|
||||||
if (listener.shouldCallGeneratedCallback(mUsername, mCallContext)) {
|
listener.avatarGenerated(new BitmapDrawable(bitmap), mCallContext);
|
||||||
listener.avatarGenerated(new BitmapDrawable(bitmap), mCallContext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,7 +535,7 @@ public class ThumbnailsCacheManager {
|
||||||
if (bitmapWorkerTask != null) {
|
if (bitmapWorkerTask != null) {
|
||||||
final Object bitmapData = bitmapWorkerTask.mFile;
|
final Object bitmapData = bitmapWorkerTask.mFile;
|
||||||
// If bitmapData is not yet set or it differs from the new data
|
// If bitmapData is not yet set or it differs from the new data
|
||||||
if (bitmapData == null || bitmapData != file) {
|
if (bitmapData == null || !bitmapData.equals(file)) {
|
||||||
// Cancel previous task
|
// Cancel previous task
|
||||||
bitmapWorkerTask.cancel(true);
|
bitmapWorkerTask.cancel(true);
|
||||||
Log_OC.v(TAG, "Cancelled generation of thumbnail for a reused imageView");
|
Log_OC.v(TAG, "Cancelled generation of thumbnail for a reused imageView");
|
||||||
|
@ -551,10 +549,11 @@ public class ThumbnailsCacheManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean cancelPotentialAvatarWork(Object file, Object callContext) {
|
public static boolean cancelPotentialAvatarWork(Object file, Object callContext) {
|
||||||
if (callContext instanceof ImageView)
|
if (callContext instanceof ImageView) {
|
||||||
return cancelPotentialAvatarWork(file, (ImageView)callContext);
|
return cancelPotentialAvatarWork(file, (ImageView) callContext);
|
||||||
else if (callContext instanceof MenuItem)
|
} else if (callContext instanceof MenuItem) {
|
||||||
return cancelPotentialAvatarWork(file, (MenuItem)callContext);
|
return cancelPotentialAvatarWork(file, (MenuItem)callContext);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -565,7 +564,7 @@ public class ThumbnailsCacheManager {
|
||||||
if (avatarWorkerTask != null) {
|
if (avatarWorkerTask != null) {
|
||||||
final Object usernameData = avatarWorkerTask.mUsername;
|
final Object usernameData = avatarWorkerTask.mUsername;
|
||||||
// If usernameData is not yet set or it differs from the new data
|
// If usernameData is not yet set or it differs from the new data
|
||||||
if (usernameData == null || usernameData != file) {
|
if (usernameData == null || !usernameData.equals(file)) {
|
||||||
// Cancel previous task
|
// Cancel previous task
|
||||||
avatarWorkerTask.cancel(true);
|
avatarWorkerTask.cancel(true);
|
||||||
Log_OC.v(TAG, "Cancelled generation of avatar for a reused imageView");
|
Log_OC.v(TAG, "Cancelled generation of avatar for a reused imageView");
|
||||||
|
@ -584,7 +583,7 @@ public class ThumbnailsCacheManager {
|
||||||
if (avatarWorkerTask != null) {
|
if (avatarWorkerTask != null) {
|
||||||
final Object usernameData = avatarWorkerTask.mUsername;
|
final Object usernameData = avatarWorkerTask.mUsername;
|
||||||
// If usernameData is not yet set or it differs from the new data
|
// If usernameData is not yet set or it differs from the new data
|
||||||
if (usernameData == null || usernameData != file) {
|
if (usernameData == null || !usernameData.equals(file)) {
|
||||||
// Cancel previous task
|
// Cancel previous task
|
||||||
avatarWorkerTask.cancel(true);
|
avatarWorkerTask.cancel(true);
|
||||||
Log_OC.v(TAG, "Cancelled generation of avatar for a reused imageView");
|
Log_OC.v(TAG, "Cancelled generation of avatar for a reused imageView");
|
||||||
|
@ -639,7 +638,6 @@ public class ThumbnailsCacheManager {
|
||||||
|
|
||||||
// offset to top left
|
// offset to top left
|
||||||
double ox = - xm;
|
double ox = - xm;
|
||||||
double oy = thumbnail.getHeight() - ym;
|
|
||||||
|
|
||||||
|
|
||||||
c.drawBitmap(thumbnail, 0, 0, null);
|
c.drawBitmap(thumbnail, 0, 0, null);
|
||||||
|
@ -654,10 +652,11 @@ public class ThumbnailsCacheManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AvatarGenerationTask getAvatarWorkerTask(Object callContext) {
|
public static AvatarGenerationTask getAvatarWorkerTask(Object callContext) {
|
||||||
if (callContext instanceof ImageView)
|
if (callContext instanceof ImageView) {
|
||||||
return getAvatarWorkerTask(((ImageView)callContext).getDrawable());
|
return getAvatarWorkerTask(((ImageView)callContext).getDrawable());
|
||||||
else if (callContext instanceof MenuItem)
|
} else if (callContext instanceof MenuItem) {
|
||||||
return getAvatarWorkerTask(((MenuItem)callContext).getIcon());
|
return getAvatarWorkerTask(((MenuItem)callContext).getIcon());
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ import java.util.Observable;
|
||||||
public class UploadsStorageManager extends Observable {
|
public class UploadsStorageManager extends Observable {
|
||||||
|
|
||||||
private ContentResolver mContentResolver;
|
private ContentResolver mContentResolver;
|
||||||
|
private static final String AND = " AND ";
|
||||||
|
|
||||||
static private final String TAG = UploadsStorageManager.class.getSimpleName();
|
static private final String TAG = UploadsStorageManager.class.getSimpleName();
|
||||||
|
|
||||||
|
@ -391,8 +392,8 @@ public class UploadsStorageManager extends Observable {
|
||||||
*/
|
*/
|
||||||
public OCUpload[] getFailedButNotDelayedUploads() {
|
public OCUpload[] getFailedButNotDelayedUploads() {
|
||||||
return getUploads(
|
return getUploads(
|
||||||
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value + " AND " +
|
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value + AND +
|
||||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + " AND " +
|
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + AND +
|
||||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_CHARGING.getValue(),
|
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_CHARGING.getValue(),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
@ -405,8 +406,8 @@ public class UploadsStorageManager extends Observable {
|
||||||
public long clearFailedButNotDelayedUploads() {
|
public long clearFailedButNotDelayedUploads() {
|
||||||
long result = getDB().delete(
|
long result = getDB().delete(
|
||||||
ProviderTableMeta.CONTENT_URI_UPLOADS,
|
ProviderTableMeta.CONTENT_URI_UPLOADS,
|
||||||
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value + " AND " +
|
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value + AND +
|
||||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + " AND " +
|
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + AND +
|
||||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_CHARGING.getValue(),
|
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_CHARGING.getValue(),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
@ -436,7 +437,7 @@ public class UploadsStorageManager extends Observable {
|
||||||
long result = getDB().delete(
|
long result = getDB().delete(
|
||||||
ProviderTableMeta.CONTENT_URI_UPLOADS,
|
ProviderTableMeta.CONTENT_URI_UPLOADS,
|
||||||
ProviderTableMeta.UPLOADS_STATUS + "=? OR " + ProviderTableMeta.UPLOADS_STATUS + "=? AND " +
|
ProviderTableMeta.UPLOADS_STATUS + "=? OR " + ProviderTableMeta.UPLOADS_STATUS + "=? AND " +
|
||||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + " AND " +
|
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + AND +
|
||||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_CHARGING.getValue(),
|
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_CHARGING.getValue(),
|
||||||
whereArgs
|
whereArgs
|
||||||
);
|
);
|
||||||
|
|
|
@ -43,17 +43,18 @@ public class ProviderMeta {
|
||||||
public static final String OCSHARES_TABLE_NAME = "ocshares";
|
public static final String OCSHARES_TABLE_NAME = "ocshares";
|
||||||
public static final String CAPABILITIES_TABLE_NAME = "capabilities";
|
public static final String CAPABILITIES_TABLE_NAME = "capabilities";
|
||||||
public static final String UPLOADS_TABLE_NAME = "list_of_uploads";
|
public static final String UPLOADS_TABLE_NAME = "list_of_uploads";
|
||||||
public static final Uri CONTENT_URI = Uri.parse("content://"
|
private static final String CONTENT_PREFIX = "content://";
|
||||||
|
public static final Uri CONTENT_URI = Uri.parse(CONTENT_PREFIX
|
||||||
+ MainApp.getAuthority() + "/");
|
+ MainApp.getAuthority() + "/");
|
||||||
public static final Uri CONTENT_URI_FILE = Uri.parse("content://"
|
public static final Uri CONTENT_URI_FILE = Uri.parse(CONTENT_PREFIX
|
||||||
+ MainApp.getAuthority() + "/file");
|
+ MainApp.getAuthority() + "/file");
|
||||||
public static final Uri CONTENT_URI_DIR = Uri.parse("content://"
|
public static final Uri CONTENT_URI_DIR = Uri.parse(CONTENT_PREFIX
|
||||||
+ MainApp.getAuthority() + "/dir");
|
+ MainApp.getAuthority() + "/dir");
|
||||||
public static final Uri CONTENT_URI_SHARE = Uri.parse("content://"
|
public static final Uri CONTENT_URI_SHARE = Uri.parse(CONTENT_PREFIX
|
||||||
+ MainApp.getAuthority() + "/shares");
|
+ MainApp.getAuthority() + "/shares");
|
||||||
public static final Uri CONTENT_URI_CAPABILITIES = Uri.parse("content://"
|
public static final Uri CONTENT_URI_CAPABILITIES = Uri.parse(CONTENT_PREFIX
|
||||||
+ MainApp.getAuthority() + "/capabilities");
|
+ MainApp.getAuthority() + "/capabilities");
|
||||||
public static final Uri CONTENT_URI_UPLOADS = Uri.parse("content://"
|
public static final Uri CONTENT_URI_UPLOADS = Uri.parse(CONTENT_PREFIX
|
||||||
+ MainApp.getAuthority() + "/uploads");
|
+ MainApp.getAuthority() + "/uploads");
|
||||||
|
|
||||||
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.owncloud.file";
|
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.owncloud.file";
|
||||||
|
|
|
@ -35,7 +35,7 @@ import android.content.Intent;
|
||||||
*/
|
*/
|
||||||
public class BootupBroadcastReceiver extends BroadcastReceiver {
|
public class BootupBroadcastReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
private static String TAG = BootupBroadcastReceiver.class.getSimpleName();
|
private static final String TAG = BootupBroadcastReceiver.class.getSimpleName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receives broadcast intent reporting that the system was just boot up.
|
* Receives broadcast intent reporting that the system was just boot up.
|
||||||
|
|
|
@ -42,17 +42,17 @@ import com.owncloud.android.utils.FileStorageUtils;
|
||||||
|
|
||||||
public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
|
public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
private static String TAG = InstantUploadBroadcastReceiver.class.getName();
|
private static final String TAG = InstantUploadBroadcastReceiver.class.getName();
|
||||||
// Image action
|
// Image action
|
||||||
// Unofficial action, works for most devices but not HTC. See: https://github.com/owncloud/android/issues/6
|
// Unofficial action, works for most devices but not HTC. See: https://github.com/owncloud/android/issues/6
|
||||||
private static String NEW_PHOTO_ACTION_UNOFFICIAL = "com.android.camera.NEW_PICTURE";
|
private static final String NEW_PHOTO_ACTION_UNOFFICIAL = "com.android.camera.NEW_PICTURE";
|
||||||
// Officially supported action since SDK 14:
|
// Officially supported action since SDK 14:
|
||||||
// http://developer.android.com/reference/android/hardware/Camera.html#ACTION_NEW_PICTURE
|
// http://developer.android.com/reference/android/hardware/Camera.html#ACTION_NEW_PICTURE
|
||||||
private static String NEW_PHOTO_ACTION = "android.hardware.action.NEW_PICTURE";
|
private static final String NEW_PHOTO_ACTION = "android.hardware.action.NEW_PICTURE";
|
||||||
// Video action
|
// Video action
|
||||||
// Officially supported action since SDK 14:
|
// Officially supported action since SDK 14:
|
||||||
// http://developer.android.com/reference/android/hardware/Camera.html#ACTION_NEW_VIDEO
|
// http://developer.android.com/reference/android/hardware/Camera.html#ACTION_NEW_VIDEO
|
||||||
private static String NEW_VIDEO_ACTION = "android.hardware.action.NEW_VIDEO";
|
private static final String NEW_VIDEO_ACTION = "android.hardware.action.NEW_VIDEO";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
|
|
@ -70,22 +70,20 @@ public class ConnectivityActionReceiver extends BroadcastReceiver {
|
||||||
Log_OC.v(TAG, "no extras");
|
Log_OC.v(TAG, "no extras");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intent.getAction().equals(Intent.ACTION_POWER_CONNECTED)) {
|
if (intent.getAction().equals(Intent.ACTION_POWER_CONNECTED) &&
|
||||||
|
(PreferenceManager.instantPictureUploadEnabled(context) &&
|
||||||
|
PreferenceManager.instantPictureUploadWhenChargingOnly(context)) ||
|
||||||
|
(PreferenceManager.instantVideoUploadEnabled(context) &&
|
||||||
|
PreferenceManager.instantVideoUploadWhenChargingOnly(context))
|
||||||
|
) {
|
||||||
// for the moment, only recovery of instant uploads, similar to behaviour in release 1.9.1
|
// for the moment, only recovery of instant uploads, similar to behaviour in release 1.9.1
|
||||||
if (
|
Log_OC.d(TAG, "Requesting retry of instant uploads (& friends) due to charging");
|
||||||
(PreferenceManager.instantPictureUploadEnabled(context) &&
|
FileUploader.UploadRequester requester = new FileUploader.UploadRequester();
|
||||||
PreferenceManager.instantPictureUploadWhenChargingOnly(context)) ||
|
requester.retryFailedUploads(
|
||||||
(PreferenceManager.instantVideoUploadEnabled(context) &&
|
context,
|
||||||
PreferenceManager.instantVideoUploadWhenChargingOnly(context))
|
null,
|
||||||
) {
|
UploadResult.DELAYED_FOR_CHARGING // for the rest of enqueued when Wifi fell
|
||||||
Log_OC.d(TAG, "Requesting retry of instant uploads (& friends) due to charging");
|
);
|
||||||
FileUploader.UploadRequester requester = new FileUploader.UploadRequester();
|
|
||||||
requester.retryFailedUploads(
|
|
||||||
context,
|
|
||||||
null,
|
|
||||||
UploadResult.DELAYED_FOR_CHARGING // for the rest of enqueued when Wifi fell
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -297,7 +297,9 @@ public class FileDownloader extends Service
|
||||||
* @param file A file that could be in the queue of downloads.
|
* @param file A file that could be in the queue of downloads.
|
||||||
*/
|
*/
|
||||||
public boolean isDownloading(Account account, OCFile file) {
|
public boolean isDownloading(Account account, OCFile file) {
|
||||||
if (account == null || file == null) return false;
|
if (account == null || file == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return (mPendingDownloads.contains(account.name, file.getRemotePath()));
|
return (mPendingDownloads.contains(account.name, file.getRemotePath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +314,9 @@ public class FileDownloader extends Service
|
||||||
public void addDatatransferProgressListener(
|
public void addDatatransferProgressListener(
|
||||||
OnDatatransferProgressListener listener, Account account, OCFile file
|
OnDatatransferProgressListener listener, Account account, OCFile file
|
||||||
) {
|
) {
|
||||||
if (account == null || file == null || listener == null) return;
|
if (account == null || file == null || listener == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
mBoundListeners.put(file.getFileId(), listener);
|
mBoundListeners.put(file.getFileId(), listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,7 +331,9 @@ public class FileDownloader extends Service
|
||||||
public void removeDatatransferProgressListener(
|
public void removeDatatransferProgressListener(
|
||||||
OnDatatransferProgressListener listener, Account account, OCFile file
|
OnDatatransferProgressListener listener, Account account, OCFile file
|
||||||
) {
|
) {
|
||||||
if (account == null || file == null || listener == null) return;
|
if (account == null || file == null || listener == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Long fileId = file.getFileId();
|
Long fileId = file.getFileId();
|
||||||
if (mBoundListeners.get(fileId) == listener) {
|
if (mBoundListeners.get(fileId) == listener) {
|
||||||
mBoundListeners.remove(fileId);
|
mBoundListeners.remove(fileId);
|
||||||
|
@ -359,8 +365,9 @@ public class FileDownloader extends Service
|
||||||
|
|
||||||
public ServiceHandler(Looper looper, FileDownloader service) {
|
public ServiceHandler(Looper looper, FileDownloader service) {
|
||||||
super(looper);
|
super(looper);
|
||||||
if (service == null)
|
if (service == null) {
|
||||||
throw new IllegalArgumentException("Received invalid NULL in parameter 'service'");
|
throw new IllegalArgumentException("Received invalid NULL in parameter 'service'");
|
||||||
|
}
|
||||||
mService = service;
|
mService = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -721,8 +721,9 @@ public class FileUploader extends Service
|
||||||
* @param file A file that could be in the queue of pending uploads
|
* @param file A file that could be in the queue of pending uploads
|
||||||
*/
|
*/
|
||||||
public boolean isUploading(Account account, OCFile file) {
|
public boolean isUploading(Account account, OCFile file) {
|
||||||
if (account == null || file == null)
|
if (account == null || file == null) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return (mPendingUploads.contains(account.name, file.getRemotePath()));
|
return (mPendingUploads.contains(account.name, file.getRemotePath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -750,7 +751,9 @@ public class FileUploader extends Service
|
||||||
Account account,
|
Account account,
|
||||||
OCFile file
|
OCFile file
|
||||||
) {
|
) {
|
||||||
if (account == null || file == null || listener == null) return;
|
if (account == null || file == null || listener == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
String targetKey = buildRemoteName(account.name, file.getRemotePath());
|
String targetKey = buildRemoteName(account.name, file.getRemotePath());
|
||||||
mBoundListeners.put(targetKey, listener);
|
mBoundListeners.put(targetKey, listener);
|
||||||
}
|
}
|
||||||
|
@ -766,7 +769,9 @@ public class FileUploader extends Service
|
||||||
OnDatatransferProgressListener listener,
|
OnDatatransferProgressListener listener,
|
||||||
OCUpload ocUpload
|
OCUpload ocUpload
|
||||||
) {
|
) {
|
||||||
if (ocUpload == null || listener == null) return;
|
if (ocUpload == null || listener == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
String targetKey = buildRemoteName(ocUpload.getAccountName(), ocUpload.getRemotePath());
|
String targetKey = buildRemoteName(ocUpload.getAccountName(), ocUpload.getRemotePath());
|
||||||
mBoundListeners.put(targetKey, listener);
|
mBoundListeners.put(targetKey, listener);
|
||||||
}
|
}
|
||||||
|
@ -784,7 +789,9 @@ public class FileUploader extends Service
|
||||||
Account account,
|
Account account,
|
||||||
OCFile file
|
OCFile file
|
||||||
) {
|
) {
|
||||||
if (account == null || file == null || listener == null) return;
|
if (account == null || file == null || listener == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
String targetKey = buildRemoteName(account.name, file.getRemotePath());
|
String targetKey = buildRemoteName(account.name, file.getRemotePath());
|
||||||
if (mBoundListeners.get(targetKey) == listener) {
|
if (mBoundListeners.get(targetKey) == listener) {
|
||||||
mBoundListeners.remove(targetKey);
|
mBoundListeners.remove(targetKey);
|
||||||
|
@ -802,7 +809,9 @@ public class FileUploader extends Service
|
||||||
OnDatatransferProgressListener listener,
|
OnDatatransferProgressListener listener,
|
||||||
OCUpload ocUpload
|
OCUpload ocUpload
|
||||||
) {
|
) {
|
||||||
if (ocUpload == null || listener == null) return;
|
if (ocUpload == null || listener == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
String targetKey = buildRemoteName(ocUpload.getAccountName(), ocUpload.getRemotePath());
|
String targetKey = buildRemoteName(ocUpload.getAccountName(), ocUpload.getRemotePath());
|
||||||
if (mBoundListeners.get(targetKey) == listener) {
|
if (mBoundListeners.get(targetKey) == listener) {
|
||||||
mBoundListeners.remove(targetKey);
|
mBoundListeners.remove(targetKey);
|
||||||
|
@ -851,8 +860,9 @@ public class FileUploader extends Service
|
||||||
|
|
||||||
public ServiceHandler(Looper looper, FileUploader service) {
|
public ServiceHandler(Looper looper, FileUploader service) {
|
||||||
super(looper);
|
super(looper);
|
||||||
if (service == null)
|
if (service == null) {
|
||||||
throw new IllegalArgumentException("Received invalid NULL in parameter 'service'");
|
throw new IllegalArgumentException("Received invalid NULL in parameter 'service'");
|
||||||
|
}
|
||||||
mService = service;
|
mService = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ public class IndexedForest<V> {
|
||||||
|
|
||||||
private ConcurrentMap<String, Node<V>> mMap = new ConcurrentHashMap<String, Node<V>>();
|
private ConcurrentMap<String, Node<V>> mMap = new ConcurrentHashMap<String, Node<V>>();
|
||||||
|
|
||||||
|
@SuppressWarnings("PMD.ShortClassName")
|
||||||
private class Node<V> {
|
private class Node<V> {
|
||||||
String mKey = null;
|
String mKey = null;
|
||||||
Node<V> mParent = null;
|
Node<V> mParent = null;
|
||||||
|
@ -168,7 +169,6 @@ public class IndexedForest<V> {
|
||||||
/// remove ancestors if only here due to firstRemoved
|
/// remove ancestors if only here due to firstRemoved
|
||||||
Node<V> removed = firstRemoved;
|
Node<V> removed = firstRemoved;
|
||||||
Node<V> parent = removed.getParent();
|
Node<V> parent = removed.getParent();
|
||||||
boolean unlinked = false;
|
|
||||||
while (parent != null) {
|
while (parent != null) {
|
||||||
parent.removeChild(removed);
|
parent.removeChild(removed);
|
||||||
if (!parent.hasChildren()) {
|
if (!parent.hasChildren()) {
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
/**
|
|
||||||
* ownCloud Android client application
|
|
||||||
*
|
|
||||||
* Copyright (C) 2012 Bartek Przybylski
|
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License version 2,
|
|
||||||
* as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.owncloud.android.files.services;
|
|
||||||
|
|
||||||
public interface OnUploadCompletedListener extends Runnable {
|
|
||||||
|
|
||||||
public boolean getUploadResult();
|
|
||||||
|
|
||||||
public void setUploadResult(boolean result);
|
|
||||||
}
|
|
|
@ -65,8 +65,6 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
|
||||||
private TextView mEndTime, mCurrentTime;
|
private TextView mEndTime, mCurrentTime;
|
||||||
private boolean mDragging;
|
private boolean mDragging;
|
||||||
private static final int SHOW_PROGRESS = 1;
|
private static final int SHOW_PROGRESS = 1;
|
||||||
StringBuilder mFormatBuilder;
|
|
||||||
Formatter mFormatter;
|
|
||||||
private ImageButton mPauseButton;
|
private ImageButton mPauseButton;
|
||||||
private ImageButton mFfwdButton;
|
private ImageButton mFfwdButton;
|
||||||
private ImageButton mRewButton;
|
private ImageButton mRewButton;
|
||||||
|
@ -231,9 +229,6 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
|
||||||
|
|
||||||
mEndTime = (TextView) v.findViewById(R.id.totalTimeText);
|
mEndTime = (TextView) v.findViewById(R.id.totalTimeText);
|
||||||
mCurrentTime = (TextView) v.findViewById(R.id.currentTimeText);
|
mCurrentTime = (TextView) v.findViewById(R.id.currentTimeText);
|
||||||
mFormatBuilder = new StringBuilder();
|
|
||||||
mFormatter = new Formatter(mFormatBuilder, Locale.getDefault());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -282,7 +277,8 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
|
||||||
int minutes = (totalSeconds / 60) % 60;
|
int minutes = (totalSeconds / 60) % 60;
|
||||||
int hours = totalSeconds / 3600;
|
int hours = totalSeconds / 3600;
|
||||||
|
|
||||||
mFormatBuilder.setLength(0);
|
final StringBuilder mFormatBuilder = new StringBuilder();
|
||||||
|
final Formatter mFormatter = new Formatter(mFormatBuilder, Locale.getDefault());
|
||||||
if (hours > 0) {
|
if (hours > 0) {
|
||||||
return mFormatter.format("%d:%02d:%02d", hours, minutes, seconds).toString();
|
return mFormatter.format("%d:%02d:%02d", hours, minutes, seconds).toString();
|
||||||
} else {
|
} else {
|
||||||
|
@ -306,11 +302,12 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
|
||||||
mProgress.setSecondaryProgress(percent * 10);
|
mProgress.setSecondaryProgress(percent * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mEndTime != null)
|
if (mEndTime != null) {
|
||||||
mEndTime.setText(stringForTime(duration));
|
mEndTime.setText(stringForTime(duration));
|
||||||
if (mCurrentTime != null)
|
}
|
||||||
|
if (mCurrentTime != null) {
|
||||||
mCurrentTime.setText(stringForTime(position));
|
mCurrentTime.setText(stringForTime(position));
|
||||||
|
}
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,8 +350,9 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePausePlay() {
|
public void updatePausePlay() {
|
||||||
if (mRoot == null || mPauseButton == null)
|
if (mRoot == null || mPauseButton == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mPlayer.isPlaying()) {
|
if (mPlayer.isPlaying()) {
|
||||||
mPauseButton.setImageResource(android.R.drawable.ic_media_pause);
|
mPauseButton.setImageResource(android.R.drawable.ic_media_pause);
|
||||||
|
@ -404,7 +402,9 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
|
||||||
pos = mPlayer.getCurrentPosition();
|
pos = mPlayer.getCurrentPosition();
|
||||||
pos -= 5000;
|
pos -= 5000;
|
||||||
mPlayer.seekTo(pos);
|
mPlayer.seekTo(pos);
|
||||||
if (!playing) mPlayer.pause(); // necessary in some 2.3.x devices
|
if (!playing) {
|
||||||
|
mPlayer.pause(); // necessary in some 2.3.x devices
|
||||||
|
}
|
||||||
setProgress();
|
setProgress();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -412,7 +412,9 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
|
||||||
pos = mPlayer.getCurrentPosition();
|
pos = mPlayer.getCurrentPosition();
|
||||||
pos += 15000;
|
pos += 15000;
|
||||||
mPlayer.seekTo(pos);
|
mPlayer.seekTo(pos);
|
||||||
if (!playing) mPlayer.pause(); // necessary in some 2.3.x devices
|
if (!playing) {
|
||||||
|
mPlayer.pause(); // necessary in some 2.3.x devices
|
||||||
|
}
|
||||||
setProgress();
|
setProgress();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -430,8 +432,9 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
|
||||||
long duration = mPlayer.getDuration();
|
long duration = mPlayer.getDuration();
|
||||||
long newposition = (duration * progress) / 1000L;
|
long newposition = (duration * progress) / 1000L;
|
||||||
mPlayer.seekTo( (int) newposition);
|
mPlayer.seekTo( (int) newposition);
|
||||||
if (mCurrentTime != null)
|
if (mCurrentTime != null) {
|
||||||
mCurrentTime.setText(stringForTime( (int) newposition));
|
mCurrentTime.setText(stringForTime((int) newposition));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -621,16 +621,18 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
|
||||||
// focus gain; check AudioManager.AUDIOFOCUS_* values
|
// focus gain; check AudioManager.AUDIOFOCUS_* values
|
||||||
mAudioFocus = AudioFocus.FOCUS;
|
mAudioFocus = AudioFocus.FOCUS;
|
||||||
// restart media player with new focus settings
|
// restart media player with new focus settings
|
||||||
if (mState == State.PLAYING)
|
if (mState == State.PLAYING) {
|
||||||
configAndStartMediaPlayer();
|
configAndStartMediaPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
} else if (focusChange < 0) {
|
} else if (focusChange < 0) {
|
||||||
// focus loss; check AudioManager.AUDIOFOCUS_* values
|
// focus loss; check AudioManager.AUDIOFOCUS_* values
|
||||||
boolean canDuck = AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK == focusChange;
|
boolean canDuck = AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK == focusChange;
|
||||||
mAudioFocus = canDuck ? AudioFocus.NO_FOCUS_CAN_DUCK : AudioFocus.NO_FOCUS;
|
mAudioFocus = canDuck ? AudioFocus.NO_FOCUS_CAN_DUCK : AudioFocus.NO_FOCUS;
|
||||||
// start/restart/pause media player with new focus settings
|
// start/restart/pause media player with new focus settings
|
||||||
if (mPlayer != null && mPlayer.isPlaying())
|
if (mPlayer != null && mPlayer.isPlaying()) {
|
||||||
configAndStartMediaPlayer();
|
configAndStartMediaPlayer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,11 +85,9 @@ public class CreateShareWithShareeOperation extends SyncOperation {
|
||||||
RemoteOperationResult result = operation.execute(client);
|
RemoteOperationResult result = operation.execute(client);
|
||||||
|
|
||||||
|
|
||||||
if (result.isSuccess()) {
|
if (result.isSuccess() && result.getData().size() > 0) {
|
||||||
if (result.getData().size() > 0) {
|
OCShare share = (OCShare) result.getData().get(0);
|
||||||
OCShare share = (OCShare) result.getData().get(0);
|
updateData(share);
|
||||||
updateData(share);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -58,16 +58,17 @@ public class DownloadFileOperation extends RemoteOperation {
|
||||||
|
|
||||||
|
|
||||||
public DownloadFileOperation(Account account, OCFile file) {
|
public DownloadFileOperation(Account account, OCFile file) {
|
||||||
if (account == null)
|
if (account == null) {
|
||||||
throw new IllegalArgumentException("Illegal null account in DownloadFileOperation " +
|
throw new IllegalArgumentException("Illegal null account in DownloadFileOperation " +
|
||||||
"creation");
|
"creation");
|
||||||
if (file == null)
|
}
|
||||||
|
if (file == null) {
|
||||||
throw new IllegalArgumentException("Illegal null file in DownloadFileOperation " +
|
throw new IllegalArgumentException("Illegal null file in DownloadFileOperation " +
|
||||||
"creation");
|
"creation");
|
||||||
|
}
|
||||||
|
|
||||||
mAccount = account;
|
mAccount = account;
|
||||||
mFile = file;
|
mFile = file;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -162,9 +163,10 @@ public class DownloadFileOperation extends RemoteOperation {
|
||||||
newFile = new File(getSavePath());
|
newFile = new File(getSavePath());
|
||||||
newFile.getParentFile().mkdirs();
|
newFile.getParentFile().mkdirs();
|
||||||
moved = tmpFile.renameTo(newFile);
|
moved = tmpFile.renameTo(newFile);
|
||||||
if (!moved)
|
if (!moved) {
|
||||||
result = new RemoteOperationResult(
|
result = new RemoteOperationResult(
|
||||||
RemoteOperationResult.ResultCode.LOCAL_STORAGE_NOT_MOVED);
|
RemoteOperationResult.ResultCode.LOCAL_STORAGE_NOT_MOVED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Log_OC.i(TAG, "Download of " + mFile.getRemotePath() + " to " + getSavePath() + ": " +
|
Log_OC.i(TAG, "Download of " + mFile.getRemotePath() + " to " + getSavePath() + ": " +
|
||||||
result.getLogMessage());
|
result.getLogMessage());
|
||||||
|
|
|
@ -35,14 +35,13 @@ public class GetCapabilitiesOperarion extends SyncOperation {
|
||||||
GetRemoteCapabilitiesOperation getCapabilities = new GetRemoteCapabilitiesOperation();
|
GetRemoteCapabilitiesOperation getCapabilities = new GetRemoteCapabilitiesOperation();
|
||||||
RemoteOperationResult result = getCapabilities.execute(client);
|
RemoteOperationResult result = getCapabilities.execute(client);
|
||||||
|
|
||||||
if (result.isSuccess()){
|
if (result.isSuccess()
|
||||||
|
&& result.getData() != null && result.getData().size() > 0) {
|
||||||
// Read data from the result
|
// Read data from the result
|
||||||
if( result.getData()!= null && result.getData().size() > 0) {
|
OCCapability capability = (OCCapability) result.getData().get(0);
|
||||||
OCCapability capability = (OCCapability) result.getData().get(0);
|
|
||||||
|
|
||||||
// Save the capabilities into database
|
// Save the capabilities into database
|
||||||
getStorageManager().saveCapabilities(capability);
|
getStorageManager().saveCapabilities(capability);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -65,6 +65,7 @@ public class OAuth2GetAccessToken extends RemoteOperation {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
||||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||||
RemoteOperationResult result = null;
|
RemoteOperationResult result = null;
|
||||||
PostMethod postMethod = null;
|
PostMethod postMethod = null;
|
||||||
|
@ -115,20 +116,20 @@ public class OAuth2GetAccessToken extends RemoteOperation {
|
||||||
result = new RemoteOperationResult(e);
|
result = new RemoteOperationResult(e);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if (postMethod != null)
|
if (postMethod != null) {
|
||||||
postMethod.releaseConnection(); // let the connection available for other methods
|
postMethod.releaseConnection(); // let the connection available for other methods
|
||||||
|
}
|
||||||
if (result.isSuccess()) {
|
|
||||||
Log_OC.i(TAG, "OAuth2 TOKEN REQUEST with auth code " + mOAuth2ParsedAuthorizationResponse.get("code") + " to " + client.getWebdavUri() + ": " + result.getLogMessage());
|
final String code = "code";
|
||||||
|
final String oauth_token_request = "OAuth2 TOKEN REQUEST with auth code ";
|
||||||
|
if (result != null && result.isSuccess()) {
|
||||||
|
Log_OC.i(TAG, oauth_token_request + mOAuth2ParsedAuthorizationResponse.get(code) + " to " + client.getWebdavUri() + ": " + result.getLogMessage());
|
||||||
} else if (result.getException() != null) {
|
} else if (result.getException() != null) {
|
||||||
Log_OC.e(TAG, "OAuth2 TOKEN REQUEST with auth code " + mOAuth2ParsedAuthorizationResponse.get("code") + " to " + client.getWebdavUri() + ": " + result.getLogMessage(), result.getException());
|
Log_OC.e(TAG, oauth_token_request + mOAuth2ParsedAuthorizationResponse.get(code) + " to " + client.getWebdavUri() + ": " + result.getLogMessage(), result.getException());
|
||||||
|
|
||||||
} else if (result.getCode() == ResultCode.OAUTH2_ERROR) {
|
} else if (result.getCode() == ResultCode.OAUTH2_ERROR) {
|
||||||
Log_OC.e(TAG, "OAuth2 TOKEN REQUEST with auth code " + mOAuth2ParsedAuthorizationResponse.get("code") + " to " + client.getWebdavUri() + ": " + ((mResultTokenMap != null) ? mResultTokenMap.get(OAuth2Constants.KEY_ERROR) : "NULL"));
|
Log_OC.e(TAG, oauth_token_request + mOAuth2ParsedAuthorizationResponse.get(code) + " to " + client.getWebdavUri() + ": " + ((mResultTokenMap != null) ? mResultTokenMap.get(OAuth2Constants.KEY_ERROR) : "NULL"));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log_OC.e(TAG, "OAuth2 TOKEN REQUEST with auth code " + mOAuth2ParsedAuthorizationResponse.get("code") + " to " + client.getWebdavUri() + ": " + result.getLogMessage());
|
Log_OC.e(TAG, oauth_token_request + mOAuth2ParsedAuthorizationResponse.get(code) + " to " + client.getWebdavUri() + ": " + result.getLogMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ import java.util.Vector;
|
||||||
*
|
*
|
||||||
* Does NOT enter in the child folders to synchronize their contents also.
|
* Does NOT enter in the child folders to synchronize their contents also.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
||||||
public class RefreshFolderOperation extends RemoteOperation {
|
public class RefreshFolderOperation extends RemoteOperation {
|
||||||
|
|
||||||
private static final String TAG = RefreshFolderOperation.class.getSimpleName();
|
private static final String TAG = RefreshFolderOperation.class.getSimpleName();
|
||||||
|
@ -319,8 +320,9 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||||
// should be a different result code, but will do the job
|
// should be a different result code, but will do the job
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (result.getCode() == ResultCode.FILE_NOT_FOUND)
|
if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
|
||||||
removeLocalFolder();
|
removeLocalFolder();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import com.owncloud.android.MainApp;
|
import com.owncloud.android.MainApp;
|
||||||
|
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||||
import com.owncloud.android.datamodel.OCFile;
|
import com.owncloud.android.datamodel.OCFile;
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
|
@ -128,8 +129,9 @@ public class RenameFileOperation extends SyncOperation {
|
||||||
String oldPath = mFile.getStoragePath();
|
String oldPath = mFile.getStoragePath();
|
||||||
File f = new File(oldPath);
|
File f = new File(oldPath);
|
||||||
String parentStoragePath = f.getParent();
|
String parentStoragePath = f.getParent();
|
||||||
if (!parentStoragePath.endsWith(File.separator))
|
if (!parentStoragePath.endsWith(File.separator)) {
|
||||||
parentStoragePath += File.separator;
|
parentStoragePath += File.separator;
|
||||||
|
}
|
||||||
if (f.renameTo(new File(parentStoragePath + mNewName))) {
|
if (f.renameTo(new File(parentStoragePath + mNewName))) {
|
||||||
String newPath = parentStoragePath + mNewName;
|
String newPath = parentStoragePath + mNewName;
|
||||||
mFile.setStoragePath(newPath);
|
mFile.setStoragePath(newPath);
|
||||||
|
@ -137,7 +139,7 @@ public class RenameFileOperation extends SyncOperation {
|
||||||
// notify MediaScanner about removed file
|
// notify MediaScanner about removed file
|
||||||
getStorageManager().deleteFileInMediaScan(oldPath);
|
getStorageManager().deleteFileInMediaScan(oldPath);
|
||||||
// notify to scan about new file
|
// notify to scan about new file
|
||||||
getStorageManager().triggerMediaScan(newPath);
|
FileDataStorageManager.triggerMediaScan(newPath);
|
||||||
}
|
}
|
||||||
// else - NOTHING: the link to the local file is kept although the local name
|
// else - NOTHING: the link to the local file is kept although the local name
|
||||||
// can't be updated
|
// can't be updated
|
||||||
|
|
|
@ -24,6 +24,7 @@ package com.owncloud.android.operations;
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.owncloud.android.datamodel.OCFile;
|
import com.owncloud.android.datamodel.OCFile;
|
||||||
import com.owncloud.android.files.services.FileDownloader;
|
import com.owncloud.android.files.services.FileDownloader;
|
||||||
|
@ -43,7 +44,7 @@ import com.owncloud.android.utils.FileStorageUtils;
|
||||||
|
|
||||||
public class SynchronizeFileOperation extends SyncOperation {
|
public class SynchronizeFileOperation extends SyncOperation {
|
||||||
|
|
||||||
private String TAG = SynchronizeFileOperation.class.getSimpleName();
|
private static final String TAG = SynchronizeFileOperation.class.getSimpleName();
|
||||||
|
|
||||||
private OCFile mLocalFile;
|
private OCFile mLocalFile;
|
||||||
private String mRemotePath;
|
private String mRemotePath;
|
||||||
|
@ -234,6 +235,7 @@ public class SynchronizeFileOperation extends SyncOperation {
|
||||||
// So, an instance of SynchronizeFileOperation created with
|
// So, an instance of SynchronizeFileOperation created with
|
||||||
// syncFileContents == false is completely useless when we suspect
|
// syncFileContents == false is completely useless when we suspect
|
||||||
// that an upload is necessary (for instance, in FileObserverService).
|
// that an upload is necessary (for instance, in FileObserverService).
|
||||||
|
Log_OC.d(TAG, "Nothing to do here");
|
||||||
}
|
}
|
||||||
result = new RemoteOperationResult(ResultCode.OK);
|
result = new RemoteOperationResult(ResultCode.OK);
|
||||||
|
|
||||||
|
|
|
@ -233,8 +233,9 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
||||||
// should be a different result code, but will do the job
|
// should be a different result code, but will do the job
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (result.getCode() == ResultCode.FILE_NOT_FOUND)
|
if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
|
||||||
removeLocalFolder();
|
removeLocalFolder();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -107,8 +107,9 @@ public class UpdateOCVersionOperation extends RemoteOperation {
|
||||||
Log_OC.e(TAG, "Check for update of ownCloud server version at " + client.getWebdavUri() + ": " + result.getLogMessage(), e);
|
Log_OC.e(TAG, "Check for update of ownCloud server version at " + client.getWebdavUri() + ": " + result.getLogMessage(), e);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if (get != null)
|
if (get != null) {
|
||||||
get.releaseConnection();
|
get.releaseConnection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,11 +147,13 @@ public class UploadFileOperation extends SyncOperation {
|
||||||
int localBehaviour,
|
int localBehaviour,
|
||||||
Context context
|
Context context
|
||||||
) {
|
) {
|
||||||
if (account == null)
|
if (account == null) {
|
||||||
throw new IllegalArgumentException("Illegal NULL account in UploadFileOperation " +
|
throw new IllegalArgumentException("Illegal NULL account in UploadFileOperation " +
|
||||||
"creation");
|
"creation");
|
||||||
if (upload == null)
|
}
|
||||||
|
if (upload == null) {
|
||||||
throw new IllegalArgumentException("Illegal NULL file in UploadFileOperation creation");
|
throw new IllegalArgumentException("Illegal NULL file in UploadFileOperation creation");
|
||||||
|
}
|
||||||
if (upload.getLocalPath() == null || upload.getLocalPath().length() <= 0) {
|
if (upload.getLocalPath() == null || upload.getLocalPath().length() <= 0) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Illegal file in UploadFileOperation; storage path invalid: "
|
"Illegal file in UploadFileOperation; storage path invalid: "
|
||||||
|
@ -286,6 +288,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
||||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||||
mCancellationRequested.set(false);
|
mCancellationRequested.set(false);
|
||||||
mUploadStarted.set(true);
|
mUploadStarted.set(true);
|
||||||
|
@ -308,7 +311,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||||
|
|
||||||
/// check if the file continues existing before schedule the operation
|
/// check if the file continues existing before schedule the operation
|
||||||
if (!originalFile.exists()) {
|
if (!originalFile.exists()) {
|
||||||
Log_OC.d(TAG, mOriginalStoragePath.toString() + " not exists anymore");
|
Log_OC.d(TAG, mOriginalStoragePath + " not exists anymore");
|
||||||
return new RemoteOperationResult(ResultCode.LOCAL_FILE_NOT_FOUND);
|
return new RemoteOperationResult(ResultCode.LOCAL_FILE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -581,7 +584,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||||
return remotePath;
|
return remotePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pos = remotePath.lastIndexOf(".");
|
int pos = remotePath.lastIndexOf('.');
|
||||||
String suffix = "";
|
String suffix = "";
|
||||||
String extension = "";
|
String extension = "";
|
||||||
if (pos >= 0) {
|
if (pos >= 0) {
|
||||||
|
@ -709,15 +712,17 @@ public class UploadFileOperation extends SyncOperation {
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (in != null)
|
if (in != null) {
|
||||||
in.close();
|
in.close();
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log_OC.d(TAG, "Weird exception while closing input stream for " +
|
Log_OC.d(TAG, "Weird exception while closing input stream for " +
|
||||||
mOriginalStoragePath + " (ignoring)", e);
|
mOriginalStoragePath + " (ignoring)", e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (out != null)
|
if (out != null) {
|
||||||
out.close();
|
out.close();
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log_OC.d(TAG, "Weird exception while closing output stream for " +
|
Log_OC.d(TAG, "Weird exception while closing output stream for " +
|
||||||
targetFile.getAbsolutePath() + " (ignoring)", e);
|
targetFile.getAbsolutePath() + " (ignoring)", e);
|
||||||
|
@ -760,8 +765,12 @@ public class UploadFileOperation extends SyncOperation {
|
||||||
// the best option could be show a warning message
|
// the best option could be show a warning message
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (inChannel != null) inChannel.close();
|
if (inChannel != null) {
|
||||||
if (outChannel != null) outChannel.close();
|
inChannel.close();
|
||||||
|
}
|
||||||
|
if (outChannel != null) {
|
||||||
|
outChannel.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,9 +85,10 @@ public abstract class SyncOperation extends RemoteOperation {
|
||||||
*/
|
*/
|
||||||
public RemoteOperationResult execute(OwnCloudClient client,
|
public RemoteOperationResult execute(OwnCloudClient client,
|
||||||
FileDataStorageManager storageManager) {
|
FileDataStorageManager storageManager) {
|
||||||
if (storageManager == null)
|
if (storageManager == null) {
|
||||||
throw new IllegalArgumentException("Trying to execute a sync operation with a " +
|
throw new IllegalArgumentException("Trying to execute a sync operation with a " +
|
||||||
"NULL storage manager");
|
"NULL storage manager");
|
||||||
|
}
|
||||||
mStorageManager = storageManager;
|
mStorageManager = storageManager;
|
||||||
return super.execute(client);
|
return super.execute(client);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,10 +55,12 @@ import com.owncloud.android.utils.MimeType;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ContentProvider for the ownCloud App.
|
* The ContentProvider for the ownCloud App.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
||||||
public class FileContentProvider extends ContentProvider {
|
public class FileContentProvider extends ContentProvider {
|
||||||
|
|
||||||
private DataBaseHelper mDbHelper;
|
private DataBaseHelper mDbHelper;
|
||||||
|
@ -72,9 +74,15 @@ public class FileContentProvider extends ContentProvider {
|
||||||
|
|
||||||
private static final String TAG = FileContentProvider.class.getSimpleName();
|
private static final String TAG = FileContentProvider.class.getSimpleName();
|
||||||
|
|
||||||
private final String MAX_SUCCESSFUL_UPLOADS = "30";
|
|
||||||
|
|
||||||
private UriMatcher mUriMatcher;
|
private UriMatcher mUriMatcher;
|
||||||
|
// todo avoid string concatenation and use string formatting instead later.
|
||||||
|
private static final String ERROR = "ERROR ";
|
||||||
|
private static final String SQL = "SQL";
|
||||||
|
private static final String INTEGER = " INTEGER, ";
|
||||||
|
private static final String TEXT = " TEXT, ";
|
||||||
|
private static final String ALTER_TABLE = "ALTER TABLE ";
|
||||||
|
private static final String ADD_COLUMN = " ADD COLUMN ";
|
||||||
|
private static final String UPGRADE_VERSION_MSG = "OUT of the ADD in onUpgrade; oldVersion == %d, newVersion == %d";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int delete(Uri uri, String where, String[] whereArgs) {
|
public int delete(Uri uri, String where, String[] whereArgs) {
|
||||||
|
@ -245,7 +253,7 @@ public class FileContentProvider extends ContentProvider {
|
||||||
if (rowId > 0) {
|
if (rowId > 0) {
|
||||||
return ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILE, rowId);
|
return ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILE, rowId);
|
||||||
} else {
|
} else {
|
||||||
throw new SQLException("ERROR " + uri);
|
throw new SQLException(ERROR + uri);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// file is already inserted; race condition, let's avoid a duplicated entry
|
// file is already inserted; race condition, let's avoid a duplicated entry
|
||||||
|
@ -265,7 +273,7 @@ public class FileContentProvider extends ContentProvider {
|
||||||
insertedShareUri =
|
insertedShareUri =
|
||||||
ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_SHARE, rowId);
|
ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_SHARE, rowId);
|
||||||
} else {
|
} else {
|
||||||
throw new SQLException("ERROR " + uri);
|
throw new SQLException(ERROR + uri);
|
||||||
|
|
||||||
}
|
}
|
||||||
updateFilesTableAccordingToShareInsertion(db, values);
|
updateFilesTableAccordingToShareInsertion(db, values);
|
||||||
|
@ -278,7 +286,7 @@ public class FileContentProvider extends ContentProvider {
|
||||||
insertedCapUri =
|
insertedCapUri =
|
||||||
ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_CAPABILITIES, id);
|
ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_CAPABILITIES, id);
|
||||||
} else {
|
} else {
|
||||||
throw new SQLException("ERROR " + uri);
|
throw new SQLException(ERROR + uri);
|
||||||
|
|
||||||
}
|
}
|
||||||
return insertedCapUri;
|
return insertedCapUri;
|
||||||
|
@ -291,7 +299,7 @@ public class FileContentProvider extends ContentProvider {
|
||||||
ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_UPLOADS, uploadId);
|
ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_UPLOADS, uploadId);
|
||||||
trimSuccessfulUploads(db);
|
trimSuccessfulUploads(db);
|
||||||
} else {
|
} else {
|
||||||
throw new SQLException("ERROR " + uri);
|
throw new SQLException(ERROR + uri);
|
||||||
|
|
||||||
}
|
}
|
||||||
return insertedUploadUri;
|
return insertedUploadUri;
|
||||||
|
@ -530,7 +538,7 @@ public class FileContentProvider extends ContentProvider {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(SQLiteDatabase db) {
|
public void onCreate(SQLiteDatabase db) {
|
||||||
// files table
|
// files table
|
||||||
Log_OC.i("SQL", "Entering in onCreate");
|
Log_OC.i(SQL, "Entering in onCreate");
|
||||||
createFilesTable(db);
|
createFilesTable(db);
|
||||||
|
|
||||||
// Create ocshares table
|
// Create ocshares table
|
||||||
|
@ -546,21 +554,21 @@ public class FileContentProvider extends ContentProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
Log_OC.i("SQL", "Entering in onUpgrade");
|
Log_OC.i(SQL, "Entering in onUpgrade");
|
||||||
boolean upgraded = false;
|
boolean upgraded = false;
|
||||||
if (oldVersion == 1 && newVersion >= 2) {
|
if (oldVersion == 1 && newVersion >= 2) {
|
||||||
Log_OC.i("SQL", "Entering in the #1 ADD in onUpgrade");
|
Log_OC.i(SQL, "Entering in the #1 ADD in onUpgrade");
|
||||||
db.execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
|
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||||
" ADD COLUMN " + ProviderTableMeta.FILE_KEEP_IN_SYNC + " INTEGER " +
|
ADD_COLUMN + ProviderTableMeta.FILE_KEEP_IN_SYNC + " INTEGER " +
|
||||||
" DEFAULT 0");
|
" DEFAULT 0");
|
||||||
upgraded = true;
|
upgraded = true;
|
||||||
}
|
}
|
||||||
if (oldVersion < 3 && newVersion >= 3) {
|
if (oldVersion < 3 && newVersion >= 3) {
|
||||||
Log_OC.i("SQL", "Entering in the #2 ADD in onUpgrade");
|
Log_OC.i(SQL, "Entering in the #2 ADD in onUpgrade");
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
try {
|
try {
|
||||||
db.execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
|
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||||
" ADD COLUMN " + ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA +
|
ADD_COLUMN + ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA +
|
||||||
" INTEGER " + " DEFAULT 0");
|
" INTEGER " + " DEFAULT 0");
|
||||||
|
|
||||||
// assume there are not local changes pending to upload
|
// assume there are not local changes pending to upload
|
||||||
|
@ -576,11 +584,11 @@ public class FileContentProvider extends ContentProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (oldVersion < 4 && newVersion >= 4) {
|
if (oldVersion < 4 && newVersion >= 4) {
|
||||||
Log_OC.i("SQL", "Entering in the #3 ADD in onUpgrade");
|
Log_OC.i(SQL, "Entering in the #3 ADD in onUpgrade");
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
try {
|
try {
|
||||||
db.execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
|
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||||
" ADD COLUMN " + ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA +
|
ADD_COLUMN + ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA +
|
||||||
" INTEGER " + " DEFAULT 0");
|
" INTEGER " + " DEFAULT 0");
|
||||||
|
|
||||||
db.execSQL("UPDATE " + ProviderTableMeta.FILE_TABLE_NAME +
|
db.execSQL("UPDATE " + ProviderTableMeta.FILE_TABLE_NAME +
|
||||||
|
@ -594,16 +602,16 @@ public class FileContentProvider extends ContentProvider {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!upgraded)
|
if (!upgraded) {
|
||||||
Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
|
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||||
", newVersion == " + newVersion);
|
}
|
||||||
|
|
||||||
if (oldVersion < 5 && newVersion >= 5) {
|
if (oldVersion < 5 && newVersion >= 5) {
|
||||||
Log_OC.i("SQL", "Entering in the #4 ADD in onUpgrade");
|
Log_OC.i(SQL, "Entering in the #4 ADD in onUpgrade");
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
try {
|
try {
|
||||||
db.execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
|
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||||
" ADD COLUMN " + ProviderTableMeta.FILE_ETAG + " TEXT " +
|
ADD_COLUMN + ProviderTableMeta.FILE_ETAG + " TEXT " +
|
||||||
" DEFAULT NULL");
|
" DEFAULT NULL");
|
||||||
|
|
||||||
upgraded = true;
|
upgraded = true;
|
||||||
|
@ -612,20 +620,20 @@ public class FileContentProvider extends ContentProvider {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!upgraded)
|
if (!upgraded) {
|
||||||
Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
|
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||||
", newVersion == " + newVersion);
|
}
|
||||||
|
|
||||||
if (oldVersion < 6 && newVersion >= 6) {
|
if (oldVersion < 6 && newVersion >= 6) {
|
||||||
Log_OC.i("SQL", "Entering in the #5 ADD in onUpgrade");
|
Log_OC.i(SQL, "Entering in the #5 ADD in onUpgrade");
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
try {
|
try {
|
||||||
db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
|
db .execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||||
" ADD COLUMN " + ProviderTableMeta.FILE_SHARED_VIA_LINK + " INTEGER " +
|
ADD_COLUMN + ProviderTableMeta.FILE_SHARED_VIA_LINK + " INTEGER " +
|
||||||
" DEFAULT 0");
|
" DEFAULT 0");
|
||||||
|
|
||||||
db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
|
db .execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||||
" ADD COLUMN " + ProviderTableMeta.FILE_PUBLIC_LINK + " TEXT " +
|
ADD_COLUMN + ProviderTableMeta.FILE_PUBLIC_LINK + " TEXT " +
|
||||||
" DEFAULT NULL");
|
" DEFAULT NULL");
|
||||||
|
|
||||||
// Create table ocshares
|
// Create table ocshares
|
||||||
|
@ -637,20 +645,20 @@ public class FileContentProvider extends ContentProvider {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!upgraded)
|
if (!upgraded) {
|
||||||
Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
|
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||||
", newVersion == " + newVersion);
|
}
|
||||||
|
|
||||||
if (oldVersion < 7 && newVersion >= 7) {
|
if (oldVersion < 7 && newVersion >= 7) {
|
||||||
Log_OC.i("SQL", "Entering in the #7 ADD in onUpgrade");
|
Log_OC.i(SQL, "Entering in the #7 ADD in onUpgrade");
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
try {
|
try {
|
||||||
db.execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
|
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||||
" ADD COLUMN " + ProviderTableMeta.FILE_PERMISSIONS + " TEXT " +
|
ADD_COLUMN + ProviderTableMeta.FILE_PERMISSIONS + " TEXT " +
|
||||||
" DEFAULT NULL");
|
" DEFAULT NULL");
|
||||||
|
|
||||||
db.execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
|
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||||
" ADD COLUMN " + ProviderTableMeta.FILE_REMOTE_ID + " TEXT " +
|
ADD_COLUMN + ProviderTableMeta.FILE_REMOTE_ID + " TEXT " +
|
||||||
" DEFAULT NULL");
|
" DEFAULT NULL");
|
||||||
|
|
||||||
upgraded = true;
|
upgraded = true;
|
||||||
|
@ -659,16 +667,16 @@ public class FileContentProvider extends ContentProvider {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!upgraded)
|
if (!upgraded) {
|
||||||
Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
|
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||||
", newVersion == " + newVersion);
|
}
|
||||||
|
|
||||||
if (oldVersion < 8 && newVersion >= 8) {
|
if (oldVersion < 8 && newVersion >= 8) {
|
||||||
Log_OC.i("SQL", "Entering in the #8 ADD in onUpgrade");
|
Log_OC.i(SQL, "Entering in the #8 ADD in onUpgrade");
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
try {
|
try {
|
||||||
db.execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
|
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||||
" ADD COLUMN " + ProviderTableMeta.FILE_UPDATE_THUMBNAIL + " INTEGER " +
|
ADD_COLUMN + ProviderTableMeta.FILE_UPDATE_THUMBNAIL + " INTEGER " +
|
||||||
" DEFAULT 0");
|
" DEFAULT 0");
|
||||||
|
|
||||||
upgraded = true;
|
upgraded = true;
|
||||||
|
@ -677,16 +685,16 @@ public class FileContentProvider extends ContentProvider {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!upgraded)
|
if (!upgraded) {
|
||||||
Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
|
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||||
", newVersion == " + newVersion);
|
}
|
||||||
|
|
||||||
if (oldVersion < 9 && newVersion >= 9) {
|
if (oldVersion < 9 && newVersion >= 9) {
|
||||||
Log_OC.i("SQL", "Entering in the #9 ADD in onUpgrade");
|
Log_OC.i(SQL, "Entering in the #9 ADD in onUpgrade");
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
try {
|
try {
|
||||||
db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
|
db .execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||||
" ADD COLUMN " + ProviderTableMeta.FILE_IS_DOWNLOADING + " INTEGER " +
|
ADD_COLUMN + ProviderTableMeta.FILE_IS_DOWNLOADING + " INTEGER " +
|
||||||
" DEFAULT 0");
|
" DEFAULT 0");
|
||||||
|
|
||||||
upgraded = true;
|
upgraded = true;
|
||||||
|
@ -695,25 +703,25 @@ public class FileContentProvider extends ContentProvider {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!upgraded)
|
if (!upgraded) {
|
||||||
Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
|
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||||
", newVersion == " + newVersion);
|
}
|
||||||
|
|
||||||
if (oldVersion < 10 && newVersion >= 10) {
|
if (oldVersion < 10 && newVersion >= 10) {
|
||||||
Log_OC.i("SQL", "Entering in the #10 ADD in onUpgrade");
|
Log_OC.i(SQL, "Entering in the #10 ADD in onUpgrade");
|
||||||
updateAccountName(db);
|
updateAccountName(db);
|
||||||
upgraded = true;
|
upgraded = true;
|
||||||
}
|
}
|
||||||
if (!upgraded)
|
if (!upgraded) {
|
||||||
Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
|
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||||
", newVersion == " + newVersion);
|
}
|
||||||
|
|
||||||
if (oldVersion < 11 && newVersion >= 11) {
|
if (oldVersion < 11 && newVersion >= 11) {
|
||||||
Log_OC.i("SQL", "Entering in the #11 ADD in onUpgrade");
|
Log_OC.i(SQL, "Entering in the #11 ADD in onUpgrade");
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
try {
|
try {
|
||||||
db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
|
db .execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||||
" ADD COLUMN " + ProviderTableMeta.FILE_ETAG_IN_CONFLICT + " TEXT " +
|
ADD_COLUMN + ProviderTableMeta.FILE_ETAG_IN_CONFLICT + " TEXT " +
|
||||||
" DEFAULT NULL");
|
" DEFAULT NULL");
|
||||||
|
|
||||||
upgraded = true;
|
upgraded = true;
|
||||||
|
@ -722,16 +730,16 @@ public class FileContentProvider extends ContentProvider {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!upgraded)
|
if (!upgraded) {
|
||||||
Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
|
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||||
", newVersion == " + newVersion);
|
}
|
||||||
|
|
||||||
if (oldVersion < 12 && newVersion >= 12) {
|
if (oldVersion < 12 && newVersion >= 12) {
|
||||||
Log_OC.i("SQL", "Entering in the #12 ADD in onUpgrade");
|
Log_OC.i(SQL, "Entering in the #12 ADD in onUpgrade");
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
try {
|
try {
|
||||||
db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
|
db .execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||||
" ADD COLUMN " + ProviderTableMeta.FILE_SHARED_WITH_SHAREE + " INTEGER " +
|
ADD_COLUMN + ProviderTableMeta.FILE_SHARED_WITH_SHAREE + " INTEGER " +
|
||||||
" DEFAULT 0");
|
" DEFAULT 0");
|
||||||
upgraded = true;
|
upgraded = true;
|
||||||
db.setTransactionSuccessful();
|
db.setTransactionSuccessful();
|
||||||
|
@ -739,12 +747,12 @@ public class FileContentProvider extends ContentProvider {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!upgraded)
|
if (!upgraded) {
|
||||||
Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
|
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||||
", newVersion == " + newVersion);
|
}
|
||||||
|
|
||||||
if (oldVersion < 13 && newVersion >= 13) {
|
if (oldVersion < 13 && newVersion >= 13) {
|
||||||
Log_OC.i("SQL", "Entering in the #13 ADD in onUpgrade");
|
Log_OC.i(SQL, "Entering in the #13 ADD in onUpgrade");
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
try {
|
try {
|
||||||
// Create capabilities table
|
// Create capabilities table
|
||||||
|
@ -757,7 +765,7 @@ public class FileContentProvider extends ContentProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldVersion < 14 && newVersion >= 14) {
|
if (oldVersion < 14 && newVersion >= 14) {
|
||||||
Log_OC.i("SQL", "Entering in the #14 ADD in onUpgrade");
|
Log_OC.i(SQL, "Entering in the #14 ADD in onUpgrade");
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
try {
|
try {
|
||||||
// drop old instant_upload table
|
// drop old instant_upload table
|
||||||
|
@ -772,7 +780,7 @@ public class FileContentProvider extends ContentProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldVersion < 15 && newVersion >= 15) {
|
if (oldVersion < 15 && newVersion >= 15) {
|
||||||
Log_OC.i("SQL", "Entering in the #15 ADD in onUpgrade");
|
Log_OC.i(SQL, "Entering in the #15 ADD in onUpgrade");
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
try {
|
try {
|
||||||
// drop old capabilities table
|
// drop old capabilities table
|
||||||
|
@ -786,37 +794,38 @@ public class FileContentProvider extends ContentProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!upgraded)
|
if (!upgraded) {
|
||||||
Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion +
|
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||||
", newVersion == " + newVersion);
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createFilesTable(SQLiteDatabase db){
|
private void createFilesTable(SQLiteDatabase db){
|
||||||
|
|
||||||
db.execSQL("CREATE TABLE " + ProviderTableMeta.FILE_TABLE_NAME + "("
|
db.execSQL("CREATE TABLE " + ProviderTableMeta.FILE_TABLE_NAME + "("
|
||||||
+ ProviderTableMeta._ID + " INTEGER PRIMARY KEY, "
|
+ ProviderTableMeta._ID + " INTEGER PRIMARY KEY, "
|
||||||
+ ProviderTableMeta.FILE_NAME + " TEXT, "
|
+ ProviderTableMeta.FILE_NAME + TEXT
|
||||||
+ ProviderTableMeta.FILE_PATH + " TEXT, "
|
+ ProviderTableMeta.FILE_PATH + TEXT
|
||||||
+ ProviderTableMeta.FILE_PARENT + " INTEGER, "
|
+ ProviderTableMeta.FILE_PARENT + INTEGER
|
||||||
+ ProviderTableMeta.FILE_CREATION + " INTEGER, "
|
+ ProviderTableMeta.FILE_CREATION + INTEGER
|
||||||
+ ProviderTableMeta.FILE_MODIFIED + " INTEGER, "
|
+ ProviderTableMeta.FILE_MODIFIED + INTEGER
|
||||||
+ ProviderTableMeta.FILE_CONTENT_TYPE + " TEXT, "
|
+ ProviderTableMeta.FILE_CONTENT_TYPE + TEXT
|
||||||
+ ProviderTableMeta.FILE_CONTENT_LENGTH + " INTEGER, "
|
+ ProviderTableMeta.FILE_CONTENT_LENGTH + INTEGER
|
||||||
+ ProviderTableMeta.FILE_STORAGE_PATH + " TEXT, "
|
+ ProviderTableMeta.FILE_STORAGE_PATH + TEXT
|
||||||
+ ProviderTableMeta.FILE_ACCOUNT_OWNER + " TEXT, "
|
+ ProviderTableMeta.FILE_ACCOUNT_OWNER + TEXT
|
||||||
+ ProviderTableMeta.FILE_LAST_SYNC_DATE + " INTEGER, "
|
+ ProviderTableMeta.FILE_LAST_SYNC_DATE + INTEGER
|
||||||
+ ProviderTableMeta.FILE_KEEP_IN_SYNC + " INTEGER, "
|
+ ProviderTableMeta.FILE_KEEP_IN_SYNC + INTEGER
|
||||||
+ ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA + " INTEGER, "
|
+ ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA + INTEGER
|
||||||
+ ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA + " INTEGER, "
|
+ ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA + INTEGER
|
||||||
+ ProviderTableMeta.FILE_ETAG + " TEXT, "
|
+ ProviderTableMeta.FILE_ETAG + TEXT
|
||||||
+ ProviderTableMeta.FILE_SHARED_VIA_LINK + " INTEGER, "
|
+ ProviderTableMeta.FILE_SHARED_VIA_LINK + INTEGER
|
||||||
+ ProviderTableMeta.FILE_PUBLIC_LINK + " TEXT, "
|
+ ProviderTableMeta.FILE_PUBLIC_LINK + TEXT
|
||||||
+ ProviderTableMeta.FILE_PERMISSIONS + " TEXT null,"
|
+ ProviderTableMeta.FILE_PERMISSIONS + " TEXT null,"
|
||||||
+ ProviderTableMeta.FILE_REMOTE_ID + " TEXT null,"
|
+ ProviderTableMeta.FILE_REMOTE_ID + " TEXT null,"
|
||||||
+ ProviderTableMeta.FILE_UPDATE_THUMBNAIL + " INTEGER," //boolean
|
+ ProviderTableMeta.FILE_UPDATE_THUMBNAIL + INTEGER //boolean
|
||||||
+ ProviderTableMeta.FILE_IS_DOWNLOADING + " INTEGER," //boolean
|
+ ProviderTableMeta.FILE_IS_DOWNLOADING + INTEGER //boolean
|
||||||
+ ProviderTableMeta.FILE_ETAG_IN_CONFLICT + " TEXT,"
|
+ ProviderTableMeta.FILE_ETAG_IN_CONFLICT + TEXT
|
||||||
+ ProviderTableMeta.FILE_SHARED_WITH_SHAREE + " INTEGER);"
|
+ ProviderTableMeta.FILE_SHARED_WITH_SHAREE + " INTEGER);"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -825,19 +834,19 @@ public class FileContentProvider extends ContentProvider {
|
||||||
// Create ocshares table
|
// Create ocshares table
|
||||||
db.execSQL("CREATE TABLE " + ProviderTableMeta.OCSHARES_TABLE_NAME + "("
|
db.execSQL("CREATE TABLE " + ProviderTableMeta.OCSHARES_TABLE_NAME + "("
|
||||||
+ ProviderTableMeta._ID + " INTEGER PRIMARY KEY, "
|
+ ProviderTableMeta._ID + " INTEGER PRIMARY KEY, "
|
||||||
+ ProviderTableMeta.OCSHARES_FILE_SOURCE + " INTEGER, "
|
+ ProviderTableMeta.OCSHARES_FILE_SOURCE + INTEGER
|
||||||
+ ProviderTableMeta.OCSHARES_ITEM_SOURCE + " INTEGER, "
|
+ ProviderTableMeta.OCSHARES_ITEM_SOURCE + INTEGER
|
||||||
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + " INTEGER, "
|
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + INTEGER
|
||||||
+ ProviderTableMeta.OCSHARES_SHARE_WITH + " TEXT, "
|
+ ProviderTableMeta.OCSHARES_SHARE_WITH + TEXT
|
||||||
+ ProviderTableMeta.OCSHARES_PATH + " TEXT, "
|
+ ProviderTableMeta.OCSHARES_PATH + TEXT
|
||||||
+ ProviderTableMeta.OCSHARES_PERMISSIONS+ " INTEGER, "
|
+ ProviderTableMeta.OCSHARES_PERMISSIONS+ INTEGER
|
||||||
+ ProviderTableMeta.OCSHARES_SHARED_DATE + " INTEGER, "
|
+ ProviderTableMeta.OCSHARES_SHARED_DATE + INTEGER
|
||||||
+ ProviderTableMeta.OCSHARES_EXPIRATION_DATE + " INTEGER, "
|
+ ProviderTableMeta.OCSHARES_EXPIRATION_DATE + INTEGER
|
||||||
+ ProviderTableMeta.OCSHARES_TOKEN + " TEXT, "
|
+ ProviderTableMeta.OCSHARES_TOKEN + TEXT
|
||||||
+ ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME + " TEXT, "
|
+ ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME + TEXT
|
||||||
+ ProviderTableMeta.OCSHARES_IS_DIRECTORY + " INTEGER, " // boolean
|
+ ProviderTableMeta.OCSHARES_IS_DIRECTORY + INTEGER // boolean
|
||||||
+ ProviderTableMeta.OCSHARES_USER_ID + " INTEGER, "
|
+ ProviderTableMeta.OCSHARES_USER_ID + INTEGER
|
||||||
+ ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED + " INTEGER,"
|
+ ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED + INTEGER
|
||||||
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + " TEXT );" );
|
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + " TEXT );" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -845,28 +854,28 @@ public class FileContentProvider extends ContentProvider {
|
||||||
// Create capabilities table
|
// Create capabilities table
|
||||||
db.execSQL("CREATE TABLE " + ProviderTableMeta.CAPABILITIES_TABLE_NAME + "("
|
db.execSQL("CREATE TABLE " + ProviderTableMeta.CAPABILITIES_TABLE_NAME + "("
|
||||||
+ ProviderTableMeta._ID + " INTEGER PRIMARY KEY, "
|
+ ProviderTableMeta._ID + " INTEGER PRIMARY KEY, "
|
||||||
+ ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + " TEXT, "
|
+ ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + TEXT
|
||||||
+ ProviderTableMeta.CAPABILITIES_VERSION_MAYOR + " INTEGER, "
|
+ ProviderTableMeta.CAPABILITIES_VERSION_MAYOR + INTEGER
|
||||||
+ ProviderTableMeta.CAPABILITIES_VERSION_MINOR + " INTEGER, "
|
+ ProviderTableMeta.CAPABILITIES_VERSION_MINOR + INTEGER
|
||||||
+ ProviderTableMeta.CAPABILITIES_VERSION_MICRO + " INTEGER, "
|
+ ProviderTableMeta.CAPABILITIES_VERSION_MICRO + INTEGER
|
||||||
+ ProviderTableMeta.CAPABILITIES_VERSION_STRING + " TEXT, "
|
+ ProviderTableMeta.CAPABILITIES_VERSION_STRING + TEXT
|
||||||
+ ProviderTableMeta.CAPABILITIES_VERSION_EDITION + " TEXT, "
|
+ ProviderTableMeta.CAPABILITIES_VERSION_EDITION + TEXT
|
||||||
+ ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL + " INTEGER, "
|
+ ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL + INTEGER
|
||||||
+ ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED + " INTEGER, " // boolean
|
+ ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED + INTEGER // boolean
|
||||||
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ENABLED + " INTEGER, " // boolean
|
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ENABLED + INTEGER // boolean
|
||||||
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_PASSWORD_ENFORCED + " INTEGER, " // boolean
|
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_PASSWORD_ENFORCED + INTEGER // boolean
|
||||||
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENABLED + " INTEGER, " // boolean
|
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENABLED + INTEGER // boolean
|
||||||
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_DAYS + " INTEGER, "
|
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_DAYS + INTEGER
|
||||||
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENFORCED + " INTEGER, " // boolean
|
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENFORCED + INTEGER // boolean
|
||||||
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_SEND_MAIL + " INTEGER, " // boolean
|
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_SEND_MAIL + INTEGER // boolean
|
||||||
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_UPLOAD + " INTEGER, " // boolean
|
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_UPLOAD + INTEGER // boolean
|
||||||
+ ProviderTableMeta.CAPABILITIES_SHARING_USER_SEND_MAIL + " INTEGER, " // boolean
|
+ ProviderTableMeta.CAPABILITIES_SHARING_USER_SEND_MAIL + INTEGER // boolean
|
||||||
+ ProviderTableMeta.CAPABILITIES_SHARING_RESHARING + " INTEGER, " // boolean
|
+ ProviderTableMeta.CAPABILITIES_SHARING_RESHARING + INTEGER // boolean
|
||||||
+ ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_OUTGOING + " INTEGER, " // boolean
|
+ ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_OUTGOING + INTEGER // boolean
|
||||||
+ ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_INCOMING + " INTEGER, " // boolean
|
+ ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_INCOMING + INTEGER // boolean
|
||||||
+ ProviderTableMeta.CAPABILITIES_FILES_BIGFILECHUNKING + " INTEGER, " // boolean
|
+ ProviderTableMeta.CAPABILITIES_FILES_BIGFILECHUNKING + INTEGER // boolean
|
||||||
+ ProviderTableMeta.CAPABILITIES_FILES_UNDELETE + " INTEGER, " // boolean
|
+ ProviderTableMeta.CAPABILITIES_FILES_UNDELETE + INTEGER // boolean
|
||||||
+ ProviderTableMeta.CAPABILITIES_FILES_VERSIONING + " INTEGER, " // boolean
|
+ ProviderTableMeta.CAPABILITIES_FILES_VERSIONING + INTEGER // boolean
|
||||||
+ ProviderTableMeta.CAPABILITIES_FILES_DROP + " INTEGER );" ); // boolean
|
+ ProviderTableMeta.CAPABILITIES_FILES_DROP + " INTEGER );" ); // boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -874,17 +883,17 @@ public class FileContentProvider extends ContentProvider {
|
||||||
// Create uploads table
|
// Create uploads table
|
||||||
db.execSQL("CREATE TABLE " + ProviderTableMeta.UPLOADS_TABLE_NAME + "("
|
db.execSQL("CREATE TABLE " + ProviderTableMeta.UPLOADS_TABLE_NAME + "("
|
||||||
+ ProviderTableMeta._ID + " INTEGER PRIMARY KEY, "
|
+ ProviderTableMeta._ID + " INTEGER PRIMARY KEY, "
|
||||||
+ ProviderTableMeta.UPLOADS_LOCAL_PATH + " TEXT, "
|
+ ProviderTableMeta.UPLOADS_LOCAL_PATH + TEXT
|
||||||
+ ProviderTableMeta.UPLOADS_REMOTE_PATH + " TEXT, "
|
+ ProviderTableMeta.UPLOADS_REMOTE_PATH + TEXT
|
||||||
+ ProviderTableMeta.UPLOADS_ACCOUNT_NAME + " TEXT, "
|
+ ProviderTableMeta.UPLOADS_ACCOUNT_NAME + TEXT
|
||||||
+ ProviderTableMeta.UPLOADS_FILE_SIZE + " LONG, "
|
+ ProviderTableMeta.UPLOADS_FILE_SIZE + " LONG, "
|
||||||
+ ProviderTableMeta.UPLOADS_STATUS + " INTEGER, " // UploadStatus
|
+ ProviderTableMeta.UPLOADS_STATUS + INTEGER // UploadStatus
|
||||||
+ ProviderTableMeta.UPLOADS_LOCAL_BEHAVIOUR + " INTEGER, " // Upload LocalBehaviour
|
+ ProviderTableMeta.UPLOADS_LOCAL_BEHAVIOUR + INTEGER // Upload LocalBehaviour
|
||||||
+ ProviderTableMeta.UPLOADS_UPLOAD_TIME + " INTEGER, "
|
+ ProviderTableMeta.UPLOADS_UPLOAD_TIME + INTEGER
|
||||||
+ ProviderTableMeta.UPLOADS_FORCE_OVERWRITE + " INTEGER, " // boolean
|
+ ProviderTableMeta.UPLOADS_FORCE_OVERWRITE + INTEGER // boolean
|
||||||
+ ProviderTableMeta.UPLOADS_IS_CREATE_REMOTE_FOLDER + " INTEGER, " // boolean
|
+ ProviderTableMeta.UPLOADS_IS_CREATE_REMOTE_FOLDER + INTEGER // boolean
|
||||||
+ ProviderTableMeta.UPLOADS_UPLOAD_END_TIMESTAMP + " INTEGER, "
|
+ ProviderTableMeta.UPLOADS_UPLOAD_END_TIMESTAMP + INTEGER
|
||||||
+ ProviderTableMeta.UPLOADS_LAST_RESULT + " INTEGER, " // Upload LastResult
|
+ ProviderTableMeta.UPLOADS_LAST_RESULT + INTEGER // Upload LastResult
|
||||||
+ ProviderTableMeta.UPLOADS_CREATED_BY + " INTEGER );" // Upload createdBy
|
+ ProviderTableMeta.UPLOADS_CREATED_BY + " INTEGER );" // Upload createdBy
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -909,7 +918,7 @@ public class FileContentProvider extends ContentProvider {
|
||||||
* @param db Database where table of files is included.
|
* @param db Database where table of files is included.
|
||||||
*/
|
*/
|
||||||
private void updateAccountName(SQLiteDatabase db){
|
private void updateAccountName(SQLiteDatabase db){
|
||||||
Log_OC.d("SQL", "THREAD: " + Thread.currentThread().getName());
|
Log_OC.d(SQL, "THREAD: " + Thread.currentThread().getName());
|
||||||
AccountManager ama = AccountManager.get(getContext());
|
AccountManager ama = AccountManager.get(getContext());
|
||||||
try {
|
try {
|
||||||
// get accounts from AccountManager ; we can't be sure if accounts in it are updated or not although
|
// get accounts from AccountManager ; we can't be sure if accounts in it are updated or not although
|
||||||
|
@ -935,7 +944,7 @@ public class FileContentProvider extends ContentProvider {
|
||||||
ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?",
|
ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?",
|
||||||
new String[]{oldAccountName});
|
new String[]{oldAccountName});
|
||||||
|
|
||||||
Log_OC.d("SQL", "Updated account in database: old name == " + oldAccountName +
|
Log_OC.d(SQL, "Updated account in database: old name == " + oldAccountName +
|
||||||
", new name == " + newAccountName + " (" + num + " rows updated )");
|
", new name == " + newAccountName + " (" + num + " rows updated )");
|
||||||
|
|
||||||
// update path for downloaded files
|
// update path for downloaded files
|
||||||
|
@ -1002,7 +1011,7 @@ public class FileContentProvider extends ContentProvider {
|
||||||
ProviderTableMeta.FILE_STORAGE_PATH + "=?",
|
ProviderTableMeta.FILE_STORAGE_PATH + "=?",
|
||||||
new String[]{oldPath});
|
new String[]{oldPath});
|
||||||
|
|
||||||
Log_OC.v("SQL", "Updated path of downloaded file: old file name == " + oldPath +
|
Log_OC.v(SQL, "Updated path of downloaded file: old file name == " + oldPath +
|
||||||
", new file name == " + newPath);
|
", new file name == " + newPath);
|
||||||
|
|
||||||
} while (c.moveToNext());
|
} while (c.moveToNext());
|
||||||
|
@ -1021,6 +1030,7 @@ public class FileContentProvider extends ContentProvider {
|
||||||
private void trimSuccessfulUploads(SQLiteDatabase db) {
|
private void trimSuccessfulUploads(SQLiteDatabase db) {
|
||||||
Cursor c = null;
|
Cursor c = null;
|
||||||
try {
|
try {
|
||||||
|
String MAX_SUCCESSFUL_UPLOADS = "30";
|
||||||
c = db.rawQuery(
|
c = db.rawQuery(
|
||||||
"delete from " + ProviderTableMeta.UPLOADS_TABLE_NAME +
|
"delete from " + ProviderTableMeta.UPLOADS_TABLE_NAME +
|
||||||
" where " + ProviderTableMeta.UPLOADS_STATUS + " == "
|
" where " + ProviderTableMeta.UPLOADS_STATUS + " == "
|
||||||
|
|
|
@ -218,14 +218,8 @@ public class OperationsService extends Service {
|
||||||
saveAllClients(this, MainApp.getAccountType());
|
saveAllClients(this, MainApp.getAccountType());
|
||||||
|
|
||||||
// TODO - get rid of these exceptions
|
// TODO - get rid of these exceptions
|
||||||
} catch (AccountNotFoundException e) {
|
} catch (AccountNotFoundException | IOException | OperationCanceledException | AuthenticatorException e) {
|
||||||
e.printStackTrace();
|
Log_OC.d(TAG, e.getMessage(), e);
|
||||||
} catch (AuthenticatorException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (OperationCanceledException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mUndispatchedFinishedOperations.clear();
|
mUndispatchedFinishedOperations.clear();
|
||||||
|
|
|
@ -79,8 +79,10 @@ class SyncFolderHandler extends Handler {
|
||||||
* @param account ownCloud account where the remote folder is stored.
|
* @param account ownCloud account where the remote folder is stored.
|
||||||
* @param remotePath The path to a folder that could be in the queue of synchronizations.
|
* @param remotePath The path to a folder that could be in the queue of synchronizations.
|
||||||
*/
|
*/
|
||||||
public boolean isSynchronizing(Account account, String remotePath) {
|
boolean isSynchronizing(Account account, String remotePath) {
|
||||||
if (account == null || remotePath == null) return false;
|
if (account == null || remotePath == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return (mPendingOperations.contains(account.name, remotePath));
|
return (mPendingOperations.contains(account.name, remotePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class FileObserverService extends Service {
|
||||||
private final static String ARG_FILE = "ARG_FILE";
|
private final static String ARG_FILE = "ARG_FILE";
|
||||||
private final static String ARG_ACCOUNT = "ARG_ACCOUNT";
|
private final static String ARG_ACCOUNT = "ARG_ACCOUNT";
|
||||||
|
|
||||||
private static String TAG = FileObserverService.class.getSimpleName();
|
private static final String TAG = FileObserverService.class.getSimpleName();
|
||||||
|
|
||||||
private Map<String, FolderObserver> mFolderObserversMap;
|
private Map<String, FolderObserver> mFolderObserversMap;
|
||||||
private DownloadCompletedReceiver mDownloadReceiver;
|
private DownloadCompletedReceiver mDownloadReceiver;
|
||||||
|
|
|
@ -52,14 +52,14 @@ import com.owncloud.android.ui.activity.ConflictsResolveActivity;
|
||||||
*/
|
*/
|
||||||
public class FolderObserver extends FileObserver {
|
public class FolderObserver extends FileObserver {
|
||||||
|
|
||||||
private static String TAG = FolderObserver.class.getSimpleName();
|
private static final String TAG = FolderObserver.class.getSimpleName();
|
||||||
|
|
||||||
private static int UPDATE_MASK = (
|
private static final int UPDATE_MASK = (
|
||||||
FileObserver.ATTRIB | FileObserver.MODIFY |
|
FileObserver.ATTRIB | FileObserver.MODIFY |
|
||||||
FileObserver.MOVED_TO | FileObserver.CLOSE_WRITE
|
FileObserver.MOVED_TO | FileObserver.CLOSE_WRITE
|
||||||
);
|
);
|
||||||
|
|
||||||
private static int IN_IGNORE = 32768;
|
private static final int IN_IGNORE = 32768;
|
||||||
/*
|
/*
|
||||||
private static int ALL_EVENTS_EVEN_THOSE_NOT_DOCUMENTED = 0x7fffffff; // NEVER use 0xffffffff
|
private static int ALL_EVENTS_EVEN_THOSE_NOT_DOCUMENTED = 0x7fffffff; // NEVER use 0xffffffff
|
||||||
*/
|
*/
|
||||||
|
@ -67,7 +67,7 @@ public class FolderObserver extends FileObserver {
|
||||||
private String mPath;
|
private String mPath;
|
||||||
private Account mAccount;
|
private Account mAccount;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private Map<String, Boolean> mObservedChildren;
|
private final Map<String, Boolean> mObservedChildren;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -82,12 +82,15 @@ public class FolderObserver extends FileObserver {
|
||||||
public FolderObserver(String path, Account account, Context context) {
|
public FolderObserver(String path, Account account, Context context) {
|
||||||
super(path, UPDATE_MASK);
|
super(path, UPDATE_MASK);
|
||||||
|
|
||||||
if (path == null)
|
if (path == null) {
|
||||||
throw new IllegalArgumentException("NULL path argument received");
|
throw new IllegalArgumentException("NULL path argument received");
|
||||||
if (account == null)
|
}
|
||||||
|
if (account == null) {
|
||||||
throw new IllegalArgumentException("NULL account argument received");
|
throw new IllegalArgumentException("NULL account argument received");
|
||||||
if (context == null)
|
}
|
||||||
|
if (context == null) {
|
||||||
throw new IllegalArgumentException("NULL context argument received");
|
throw new IllegalArgumentException("NULL context argument received");
|
||||||
|
}
|
||||||
|
|
||||||
mPath = path;
|
mPath = path;
|
||||||
mAccount = account;
|
mAccount = account;
|
||||||
|
@ -113,15 +116,14 @@ public class FolderObserver extends FileObserver {
|
||||||
|
|
||||||
if ( ((event & FileObserver.MODIFY) != 0) ||
|
if ( ((event & FileObserver.MODIFY) != 0) ||
|
||||||
((event & FileObserver.ATTRIB) != 0) ||
|
((event & FileObserver.ATTRIB) != 0) ||
|
||||||
((event & FileObserver.MOVED_TO) != 0) ) {
|
((event & FileObserver.MOVED_TO) != 0)
|
||||||
|
&& !mObservedChildren.get(path)) {
|
||||||
|
|
||||||
if (mObservedChildren.get(path) != true) {
|
mObservedChildren.put(path, true);
|
||||||
mObservedChildren.put(path, Boolean.valueOf(true));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((event & FileObserver.CLOSE_WRITE) != 0 && mObservedChildren.get(path)) {
|
if ((event & FileObserver.CLOSE_WRITE) != 0 && mObservedChildren.get(path)) {
|
||||||
mObservedChildren.put(path, Boolean.valueOf(false));
|
mObservedChildren.put(path, false);
|
||||||
shouldSynchronize = true;
|
shouldSynchronize = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,7 +148,7 @@ public class FolderObserver extends FileObserver {
|
||||||
public void startWatching(String fileName) {
|
public void startWatching(String fileName) {
|
||||||
synchronized (mObservedChildren) {
|
synchronized (mObservedChildren) {
|
||||||
if (!mObservedChildren.containsKey(fileName)) {
|
if (!mObservedChildren.containsKey(fileName)) {
|
||||||
mObservedChildren.put(fileName, Boolean.valueOf(false));
|
mObservedChildren.put(fileName, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,11 +89,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||||
|
|
||||||
/** Flag made 'true' when a request to cancel the synchronization is received */
|
/** Flag made 'true' when a request to cancel the synchronization is received */
|
||||||
private boolean mCancellation;
|
private boolean mCancellation;
|
||||||
|
|
||||||
/** When 'true' the process was requested by the user through the user interface;
|
|
||||||
* when 'false', it was requested automatically by the system */
|
|
||||||
private boolean mIsManualSync;
|
|
||||||
|
|
||||||
/** Counter for failed operations in the synchronization process */
|
/** Counter for failed operations in the synchronization process */
|
||||||
private int mFailedResultsCounter;
|
private int mFailedResultsCounter;
|
||||||
|
|
||||||
|
@ -146,7 +142,9 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||||
SyncResult syncResult) {
|
SyncResult syncResult) {
|
||||||
|
|
||||||
mCancellation = false;
|
mCancellation = false;
|
||||||
mIsManualSync = extras.getBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, false);
|
/* When 'true' the process was requested by the user through the user interface;
|
||||||
|
when 'false', it was requested automatically by the system */
|
||||||
|
boolean mIsManualSync = extras.getBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, false);
|
||||||
mFailedResultsCounter = 0;
|
mFailedResultsCounter = 0;
|
||||||
mLastFailedResult = null;
|
mLastFailedResult = null;
|
||||||
mConflictsFound = 0;
|
mConflictsFound = 0;
|
||||||
|
@ -162,20 +160,14 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.initClientForCurrentAccount();
|
this.initClientForCurrentAccount();
|
||||||
} catch (IOException e) {
|
} catch (IOException | AccountsException e) {
|
||||||
/// the account is unknown for the Synchronization Manager, unreachable this context,
|
|
||||||
// or can not be authenticated; don't try this again
|
|
||||||
mSyncResult.tooManyRetries = true;
|
|
||||||
notifyFailedSynchronization();
|
|
||||||
return;
|
|
||||||
} catch (AccountsException e) {
|
|
||||||
/// the account is unknown for the Synchronization Manager, unreachable this context,
|
/// the account is unknown for the Synchronization Manager, unreachable this context,
|
||||||
// or can not be authenticated; don't try this again
|
// or can not be authenticated; don't try this again
|
||||||
mSyncResult.tooManyRetries = true;
|
mSyncResult.tooManyRetries = true;
|
||||||
notifyFailedSynchronization();
|
notifyFailedSynchronization();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_OC.d(TAG, "Synchronization of ownCloud account " + account.name + " starting");
|
Log_OC.d(TAG, "Synchronization of ownCloud account " + account.name + " starting");
|
||||||
sendLocalBroadcast(EVENT_FULL_SYNC_START, null, null); // message to signal the start
|
sendLocalBroadcast(EVENT_FULL_SYNC_START, null, null); // message to signal the start
|
||||||
// of the synchronization to the UI
|
// of the synchronization to the UI
|
||||||
|
@ -262,8 +254,9 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||||
*/
|
*/
|
||||||
private void synchronizeFolder(OCFile folder) {
|
private void synchronizeFolder(OCFile folder) {
|
||||||
|
|
||||||
if (mFailedResultsCounter > MAX_FAILED_RESULTS || isFinisher(mLastFailedResult))
|
if (mFailedResultsCounter > MAX_FAILED_RESULTS || isFinisher(mLastFailedResult)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// folder synchronization
|
// folder synchronization
|
||||||
RefreshFolderOperation synchFolderOp = new RefreshFolderOperation( folder,
|
RefreshFolderOperation synchFolderOp = new RefreshFolderOperation( folder,
|
||||||
|
@ -355,9 +348,11 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCancellation && i <files.size()) Log_OC.d(TAG,
|
if (mCancellation && i <files.size()) {
|
||||||
"Leaving synchronization before synchronizing " + files.get(i).getRemotePath() +
|
Log_OC.d(TAG,
|
||||||
" due to cancelation request");
|
"Leaving synchronization before synchronizing " + files.get(i).getRemotePath() +
|
||||||
|
" due to cancelation request");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ import com.owncloud.android.ui.dialog.ConflictsResolveDialog.OnConflictDecisionM
|
||||||
*/
|
*/
|
||||||
public class ConflictsResolveActivity extends FileActivity implements OnConflictDecisionMadeListener {
|
public class ConflictsResolveActivity extends FileActivity implements OnConflictDecisionMadeListener {
|
||||||
|
|
||||||
private String TAG = ConflictsResolveActivity.class.getSimpleName();
|
private static final String TAG = ConflictsResolveActivity.class.getSimpleName();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
|
@ -173,7 +173,7 @@ public class FileDisplayActivity extends HookActivity
|
||||||
setupToolbar();
|
setupToolbar();
|
||||||
|
|
||||||
// setup drawer
|
// setup drawer
|
||||||
if(MainApp.getOnlyOnDevice()) {
|
if(MainApp.isOnlyOnDevice()) {
|
||||||
setupDrawer(R.id.nav_on_device);
|
setupDrawer(R.id.nav_on_device);
|
||||||
} else {
|
} else {
|
||||||
setupDrawer(R.id.nav_all_files);
|
setupDrawer(R.id.nav_all_files);
|
||||||
|
@ -251,6 +251,7 @@ public class FileDisplayActivity extends HookActivity
|
||||||
// toggle on is save since this is the only scenario this code gets accessed
|
// toggle on is save since this is the only scenario this code gets accessed
|
||||||
} else {
|
} else {
|
||||||
// permission denied --> do nothing
|
// permission denied --> do nothing
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -296,8 +297,9 @@ public class FileDisplayActivity extends HookActivity
|
||||||
// cache until the upload is successful get parent from path
|
// cache until the upload is successful get parent from path
|
||||||
parentPath = file.getRemotePath().substring(0,
|
parentPath = file.getRemotePath().substring(0,
|
||||||
file.getRemotePath().lastIndexOf(file.getFileName()));
|
file.getRemotePath().lastIndexOf(file.getFileName()));
|
||||||
if (getStorageManager().getFileByPath(parentPath) == null)
|
if (getStorageManager().getFileByPath(parentPath) == null) {
|
||||||
file = null; // not able to know the directory where the file is uploading
|
file = null; // not able to know the directory where the file is uploading
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
file = getStorageManager().getFileByPath(file.getRemotePath());
|
file = getStorageManager().getFileByPath(file.getRemotePath());
|
||||||
// currentDir = null if not in the current Account
|
// currentDir = null if not in the current Account
|
||||||
|
@ -342,7 +344,7 @@ public class FileDisplayActivity extends HookActivity
|
||||||
/// First fragment
|
/// First fragment
|
||||||
OCFileListFragment listOfFiles = getListOfFilesFragment();
|
OCFileListFragment listOfFiles = getListOfFilesFragment();
|
||||||
if (listOfFiles != null) {
|
if (listOfFiles != null) {
|
||||||
listOfFiles.listDirectory(getCurrentDir(), MainApp.getOnlyOnDevice());
|
listOfFiles.listDirectory(getCurrentDir(), MainApp.isOnlyOnDevice());
|
||||||
} else {
|
} else {
|
||||||
Log_OC.e(TAG, "Still have a chance to lose the initializacion of list fragment >(");
|
Log_OC.e(TAG, "Still have a chance to lose the initializacion of list fragment >(");
|
||||||
}
|
}
|
||||||
|
@ -356,8 +358,9 @@ public class FileDisplayActivity extends HookActivity
|
||||||
updateActionBarTitleAndHomeButton(file);
|
updateActionBarTitleAndHomeButton(file);
|
||||||
} else {
|
} else {
|
||||||
cleanSecondFragment();
|
cleanSecondFragment();
|
||||||
if (file.isDown() && PreviewTextFragment.canBePreviewed(file))
|
if (file.isDown() && PreviewTextFragment.canBePreviewed(file)) {
|
||||||
startTextPreview(file);
|
startTextPreview(file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -470,7 +473,7 @@ public class FileDisplayActivity extends HookActivity
|
||||||
protected void refreshListOfFilesFragment() {
|
protected void refreshListOfFilesFragment() {
|
||||||
OCFileListFragment fileListFragment = getListOfFilesFragment();
|
OCFileListFragment fileListFragment = getListOfFilesFragment();
|
||||||
if (fileListFragment != null) {
|
if (fileListFragment != null) {
|
||||||
fileListFragment.listDirectory(MainApp.getOnlyOnDevice());
|
fileListFragment.listDirectory(MainApp.isOnlyOnDevice());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,7 +482,7 @@ public class FileDisplayActivity extends HookActivity
|
||||||
FileFragment secondFragment = getSecondFragment();
|
FileFragment secondFragment = getSecondFragment();
|
||||||
boolean waitedPreview = (mWaitingToPreview != null &&
|
boolean waitedPreview = (mWaitingToPreview != null &&
|
||||||
mWaitingToPreview.getRemotePath().equals(downloadedRemotePath));
|
mWaitingToPreview.getRemotePath().equals(downloadedRemotePath));
|
||||||
if (secondFragment != null && secondFragment instanceof FileDetailFragment) {
|
if (secondFragment instanceof FileDetailFragment) {
|
||||||
FileDetailFragment detailsFragment = (FileDetailFragment) secondFragment;
|
FileDetailFragment detailsFragment = (FileDetailFragment) secondFragment;
|
||||||
OCFile fileInFragment = detailsFragment.getFile();
|
OCFile fileInFragment = detailsFragment.getFile();
|
||||||
if (fileInFragment != null &&
|
if (fileInFragment != null &&
|
||||||
|
@ -682,7 +685,6 @@ public class FileDisplayActivity extends HookActivity
|
||||||
} else if (requestCode == REQUEST_CODE__COPY_FILES && resultCode == RESULT_OK) {
|
} else if (requestCode == REQUEST_CODE__COPY_FILES && resultCode == RESULT_OK) {
|
||||||
|
|
||||||
final Intent fData = data;
|
final Intent fData = data;
|
||||||
final int fResultCode = resultCode;
|
|
||||||
getHandler().postDelayed(
|
getHandler().postDelayed(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -981,12 +983,11 @@ public class FileDisplayActivity extends HookActivity
|
||||||
currentFile = currentDir;
|
currentFile = currentDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (synchFolderRemotePath != null &&
|
if (currentDir.getRemotePath().equals(synchFolderRemotePath)) {
|
||||||
currentDir.getRemotePath().equals(synchFolderRemotePath)) {
|
|
||||||
OCFileListFragment fileListFragment = getListOfFilesFragment();
|
OCFileListFragment fileListFragment = getListOfFilesFragment();
|
||||||
if (fileListFragment != null) {
|
if (fileListFragment != null) {
|
||||||
fileListFragment.listDirectory(currentDir,
|
fileListFragment.listDirectory(currentDir,
|
||||||
MainApp.getOnlyOnDevice());
|
MainApp.isOnlyOnDevice());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setFile(currentFile);
|
setFile(currentFile);
|
||||||
|
@ -997,23 +998,22 @@ public class FileDisplayActivity extends HookActivity
|
||||||
.equals(event));
|
.equals(event));
|
||||||
|
|
||||||
if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.
|
if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.
|
||||||
equals(event)) {
|
equals(event) &&
|
||||||
|
synchResult != null && !synchResult.isSuccess()) {
|
||||||
|
|
||||||
if (synchResult != null && !synchResult.isSuccess()) {
|
/// TODO refactor and make common
|
||||||
/// TODO refactor and make common
|
|
||||||
|
|
||||||
if (checkForRemoteOperationError(synchResult)) {
|
if (checkForRemoteOperationError(synchResult)) {
|
||||||
|
|
||||||
requestCredentialsUpdate(context);
|
requestCredentialsUpdate(context);
|
||||||
|
|
||||||
} else if (RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED.equals(
|
} else if (RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED.equals(
|
||||||
synchResult.getCode())) {
|
synchResult.getCode())) {
|
||||||
|
|
||||||
showUntrustedCertDialog(synchResult);
|
showUntrustedCertDialog(synchResult);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
removeStickyBroadcast(intent);
|
removeStickyBroadcast(intent);
|
||||||
Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
|
Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
|
||||||
|
@ -1023,11 +1023,9 @@ public class FileDisplayActivity extends HookActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (synchResult != null) {
|
if (synchResult != null && synchResult.getCode().equals(
|
||||||
if (synchResult.getCode().equals(
|
RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)) {
|
||||||
RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)) {
|
mLastSslUntrustedServerResult = synchResult;
|
||||||
mLastSslUntrustedServerResult = synchResult;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
// avoid app crashes after changing the serial id of RemoteOperationResult
|
// avoid app crashes after changing the serial id of RemoteOperationResult
|
||||||
|
@ -1098,14 +1096,14 @@ public class FileDisplayActivity extends HookActivity
|
||||||
boolean sameFile = getFile().getRemotePath().equals(uploadedRemotePath) ||
|
boolean sameFile = getFile().getRemotePath().equals(uploadedRemotePath) ||
|
||||||
renamedInUpload;
|
renamedInUpload;
|
||||||
FileFragment details = getSecondFragment();
|
FileFragment details = getSecondFragment();
|
||||||
boolean detailFragmentIsShown = (details != null &&
|
boolean detailFragmentIsShown = (details instanceof FileDetailFragment);
|
||||||
details instanceof FileDetailFragment);
|
|
||||||
|
|
||||||
if (sameAccount && sameFile && detailFragmentIsShown) {
|
if (sameAccount && sameFile && detailFragmentIsShown) {
|
||||||
if (uploadWasFine) {
|
if (uploadWasFine) {
|
||||||
setFile(getStorageManager().getFileByPath(uploadedRemotePath));
|
setFile(getStorageManager().getFileByPath(uploadedRemotePath));
|
||||||
} else {
|
} else {
|
||||||
//TODO remove upload progress bar after upload failed.
|
//TODO remove upload progress bar after upload failed.
|
||||||
|
Log_OC.d(TAG, "Remove upload progress bar after upload failed");
|
||||||
}
|
}
|
||||||
if (renamedInUpload) {
|
if (renamedInUpload) {
|
||||||
String newName = (new File(uploadedRemotePath)).getName();
|
String newName = (new File(uploadedRemotePath)).getName();
|
||||||
|
@ -1126,10 +1124,12 @@ public class FileDisplayActivity extends HookActivity
|
||||||
// Force the preview if the file is an image or text file
|
// Force the preview if the file is an image or text file
|
||||||
if (uploadWasFine) {
|
if (uploadWasFine) {
|
||||||
OCFile ocFile = getFile();
|
OCFile ocFile = getFile();
|
||||||
if (PreviewImageFragment.canBePreviewed(ocFile))
|
if (PreviewImageFragment.canBePreviewed(ocFile)) {
|
||||||
startImagePreview(getFile());
|
startImagePreview(getFile());
|
||||||
else if (PreviewTextFragment.canBePreviewed(ocFile))
|
}
|
||||||
|
else if (PreviewTextFragment.canBePreviewed(ocFile)) {
|
||||||
startTextPreview(ocFile);
|
startTextPreview(ocFile);
|
||||||
|
}
|
||||||
// TODO what about other kind of previews?
|
// TODO what about other kind of previews?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1229,7 +1229,7 @@ public class FileDisplayActivity extends HookActivity
|
||||||
OCFileListFragment listOfFiles = getListOfFilesFragment();
|
OCFileListFragment listOfFiles = getListOfFilesFragment();
|
||||||
if (listOfFiles != null) { // should never be null, indeed
|
if (listOfFiles != null) { // should never be null, indeed
|
||||||
OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
|
OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
|
||||||
listOfFiles.listDirectory(root, MainApp.getOnlyOnDevice());
|
listOfFiles.listDirectory(root, MainApp.isOnlyOnDevice());
|
||||||
setFile(listOfFiles.getCurrentFile());
|
setFile(listOfFiles.getCurrentFile());
|
||||||
startSyncFolderOperation(root, false);
|
startSyncFolderOperation(root, false);
|
||||||
}
|
}
|
||||||
|
@ -1295,15 +1295,14 @@ public class FileDisplayActivity extends HookActivity
|
||||||
FileDisplayActivity.this, FileDownloader.class))) {
|
FileDisplayActivity.this, FileDownloader.class))) {
|
||||||
Log_OC.d(TAG, "Download service connected");
|
Log_OC.d(TAG, "Download service connected");
|
||||||
mDownloaderBinder = (FileDownloaderBinder) service;
|
mDownloaderBinder = (FileDownloaderBinder) service;
|
||||||
if (mWaitingToPreview != null)
|
if (mWaitingToPreview != null && getStorageManager() != null) {
|
||||||
if (getStorageManager() != null) {
|
// update the file
|
||||||
// update the file
|
mWaitingToPreview =
|
||||||
mWaitingToPreview =
|
getStorageManager().getFileById(mWaitingToPreview.getFileId());
|
||||||
getStorageManager().getFileById(mWaitingToPreview.getFileId());
|
if (!mWaitingToPreview.isDown()) {
|
||||||
if (!mWaitingToPreview.isDown()) {
|
requestForDownload();
|
||||||
requestForDownload();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else if (component.equals(new ComponentName(FileDisplayActivity.this,
|
} else if (component.equals(new ComponentName(FileDisplayActivity.this,
|
||||||
FileUploader.class))) {
|
FileUploader.class))) {
|
||||||
|
@ -1316,10 +1315,10 @@ public class FileDisplayActivity extends HookActivity
|
||||||
// getFileDownloadBinder() - THIS IS A MESS
|
// getFileDownloadBinder() - THIS IS A MESS
|
||||||
OCFileListFragment listOfFiles = getListOfFilesFragment();
|
OCFileListFragment listOfFiles = getListOfFilesFragment();
|
||||||
if (listOfFiles != null) {
|
if (listOfFiles != null) {
|
||||||
listOfFiles.listDirectory(MainApp.getOnlyOnDevice());
|
listOfFiles.listDirectory(MainApp.isOnlyOnDevice());
|
||||||
}
|
}
|
||||||
FileFragment secondFragment = getSecondFragment();
|
FileFragment secondFragment = getSecondFragment();
|
||||||
if (secondFragment != null && secondFragment instanceof FileDetailFragment) {
|
if (secondFragment instanceof FileDetailFragment) {
|
||||||
FileDetailFragment detailFragment = (FileDetailFragment) secondFragment;
|
FileDetailFragment detailFragment = (FileDetailFragment) secondFragment;
|
||||||
detailFragment.listenForTransferProgress();
|
detailFragment.listenForTransferProgress();
|
||||||
detailFragment.updateFileDetails(false, false);
|
detailFragment.updateFileDetails(false, false);
|
||||||
|
@ -1534,13 +1533,11 @@ public class FileDisplayActivity extends HookActivity
|
||||||
|
|
||||||
private void onSynchronizeFileOperationFinish(SynchronizeFileOperation operation,
|
private void onSynchronizeFileOperationFinish(SynchronizeFileOperation operation,
|
||||||
RemoteOperationResult result) {
|
RemoteOperationResult result) {
|
||||||
if (result.isSuccess()) {
|
if (result.isSuccess() && operation.transferWasRequested()) {
|
||||||
if (operation.transferWasRequested()) {
|
OCFile syncedFile = operation.getLocalFile();
|
||||||
OCFile syncedFile = operation.getLocalFile();
|
onTransferStateChanged(syncedFile, true, true);
|
||||||
onTransferStateChanged(syncedFile, true, true);
|
invalidateOptionsMenu();
|
||||||
invalidateOptionsMenu();
|
refreshShowDetails();
|
||||||
refreshShowDetails();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1576,7 +1573,7 @@ public class FileDisplayActivity extends HookActivity
|
||||||
public void onTransferStateChanged(OCFile file, boolean downloading, boolean uploading) {
|
public void onTransferStateChanged(OCFile file, boolean downloading, boolean uploading) {
|
||||||
refreshListOfFilesFragment();
|
refreshListOfFilesFragment();
|
||||||
FileFragment details = getSecondFragment();
|
FileFragment details = getSecondFragment();
|
||||||
if (details != null && details instanceof FileDetailFragment &&
|
if (details instanceof FileDetailFragment &&
|
||||||
file.equals(details.getFile())) {
|
file.equals(details.getFile())) {
|
||||||
if (downloading || uploading) {
|
if (downloading || uploading) {
|
||||||
((FileDetailFragment) details).updateFileDetails(file, getAccount());
|
((FileDetailFragment) details).updateFileDetails(file, getAccount());
|
||||||
|
|
|
@ -363,9 +363,9 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (v == mCancelBtn) {
|
if (v.equals(mCancelBtn)) {
|
||||||
finish();
|
finish();
|
||||||
} else if (v == mChooseBtn) {
|
} else if (v.equals(mChooseBtn)) {
|
||||||
Intent i = getIntent();
|
Intent i = getIntent();
|
||||||
ArrayList<Parcelable> targetFiles = i.getParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES);
|
ArrayList<Parcelable> targetFiles = i.getParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES);
|
||||||
|
|
||||||
|
@ -462,8 +462,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||||
currentFile = currentDir;
|
currentFile = currentDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (synchFolderRemotePath != null && currentDir.getRemotePath().
|
if (currentDir.getRemotePath().equals(synchFolderRemotePath)) {
|
||||||
equals(synchFolderRemotePath)) {
|
|
||||||
OCFileListFragment fileListFragment = getListOfFilesFragment();
|
OCFileListFragment fileListFragment = getListOfFilesFragment();
|
||||||
if (fileListFragment != null) {
|
if (fileListFragment != null) {
|
||||||
fileListFragment.listDirectory(currentDir, false);
|
fileListFragment.listDirectory(currentDir, false);
|
||||||
|
|
|
@ -105,13 +105,11 @@ public class GenericExplanationActivity extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
public View getView (int position, View convertView, ViewGroup parent) {
|
public View getView (int position, View convertView, ViewGroup parent) {
|
||||||
View view = super.getView(position, convertView, parent);
|
View view = super.getView(position, convertView, parent);
|
||||||
if (view != null) {
|
if (mList2 != null && mList2.size() > 0 && position >= 0 &&
|
||||||
if (mList2 != null && mList2.size() > 0 && position >= 0 &&
|
position < mList2.size()) {
|
||||||
position < mList2.size()) {
|
TextView text2 = (TextView) view.findViewById(android.R.id.text2);
|
||||||
TextView text2 = (TextView) view.findViewById(android.R.id.text2);
|
if (text2 != null) {
|
||||||
if (text2 != null) {
|
text2.setText(mList2.get(position));
|
||||||
text2.setText(mList2.get(position));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return view;
|
return view;
|
||||||
|
|
|
@ -70,9 +70,9 @@ public class PassCodeActivity extends AppCompatActivity {
|
||||||
private EditText[] mPassCodeEditTexts = new EditText[4];
|
private EditText[] mPassCodeEditTexts = new EditText[4];
|
||||||
|
|
||||||
private String [] mPassCodeDigits = {"","","",""};
|
private String [] mPassCodeDigits = {"","","",""};
|
||||||
private static String KEY_PASSCODE_DIGITS = "PASSCODE_DIGITS";
|
private static final String KEY_PASSCODE_DIGITS = "PASSCODE_DIGITS";
|
||||||
private boolean mConfirmingPassCode = false;
|
private boolean mConfirmingPassCode = false;
|
||||||
private static String KEY_CONFIRMING_PASSCODE = "CONFIRMING_PASSCODE";
|
private static final String KEY_CONFIRMING_PASSCODE = "CONFIRMING_PASSCODE";
|
||||||
|
|
||||||
private boolean mBChange = true; // to control that only one blocks jump
|
private boolean mBChange = true; // to control that only one blocks jump
|
||||||
|
|
||||||
|
@ -185,8 +185,9 @@ public class PassCodeActivity extends AppCompatActivity {
|
||||||
// used to control what's exactly happening with DEL, not any custom field...
|
// used to control what's exactly happening with DEL, not any custom field...
|
||||||
mPassCodeEditTexts[0].setText("");
|
mPassCodeEditTexts[0].setText("");
|
||||||
mPassCodeEditTexts[0].requestFocus();
|
mPassCodeEditTexts[0].requestFocus();
|
||||||
if (!mConfirmingPassCode)
|
if (!mConfirmingPassCode) {
|
||||||
mPassCodeDigits[0] = "";
|
mPassCodeDigits[0] = "";
|
||||||
|
}
|
||||||
mBChange = false;
|
mBChange = false;
|
||||||
|
|
||||||
} else if (!mBChange) {
|
} else if (!mBChange) {
|
||||||
|
@ -221,8 +222,9 @@ public class PassCodeActivity extends AppCompatActivity {
|
||||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_DEL && mBChange) {
|
if (keyCode == KeyEvent.KEYCODE_DEL && mBChange) {
|
||||||
mPassCodeEditTexts[1].requestFocus();
|
mPassCodeEditTexts[1].requestFocus();
|
||||||
if (!mConfirmingPassCode)
|
if (!mConfirmingPassCode) {
|
||||||
mPassCodeDigits[1] = "";
|
mPassCodeDigits[1] = "";
|
||||||
|
}
|
||||||
mPassCodeEditTexts[1].setText("");
|
mPassCodeEditTexts[1].setText("");
|
||||||
mBChange = false;
|
mBChange = false;
|
||||||
|
|
||||||
|
@ -258,8 +260,9 @@ public class PassCodeActivity extends AppCompatActivity {
|
||||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_DEL && mBChange) {
|
if (keyCode == KeyEvent.KEYCODE_DEL && mBChange) {
|
||||||
mPassCodeEditTexts[2].requestFocus();
|
mPassCodeEditTexts[2].requestFocus();
|
||||||
if (!mConfirmingPassCode)
|
if (!mConfirmingPassCode) {
|
||||||
mPassCodeDigits[2] = "";
|
mPassCodeDigits[2] = "";
|
||||||
|
}
|
||||||
mPassCodeEditTexts[2].setText("");
|
mPassCodeEditTexts[2].setText("");
|
||||||
mBChange = false;
|
mBChange = false;
|
||||||
|
|
||||||
|
|
|
@ -266,7 +266,6 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||||
case DIALOG_MULTIPLE_ACCOUNT:
|
case DIALOG_MULTIPLE_ACCOUNT:
|
||||||
Account accounts[] = mAccountManager.getAccountsByType(MainApp.getAccountType());
|
Account accounts[] = mAccountManager.getAccountsByType(MainApp.getAccountType());
|
||||||
CharSequence dialogItems[] = new CharSequence[accounts.length];
|
CharSequence dialogItems[] = new CharSequence[accounts.length];
|
||||||
OwnCloudAccount oca;
|
|
||||||
for (int i = 0; i < dialogItems.length; ++i) {
|
for (int i = 0; i < dialogItems.length; ++i) {
|
||||||
dialogItems[i] = DisplayUtils.getAccountNameDisplayText(
|
dialogItems[i] = DisplayUtils.getAccountNameDisplayText(
|
||||||
this, accounts[i], accounts[i].name, DisplayUtils.convertIdn(accounts[i].name, false));
|
this, accounts[i], accounts[i].name, DisplayUtils.convertIdn(accounts[i].name, false));
|
||||||
|
@ -316,11 +315,14 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||||
Vector<OCFile> tmpfiles = getStorageManager().getFolderContent(mFile , false);
|
Vector<OCFile> tmpfiles = getStorageManager().getFolderContent(mFile , false);
|
||||||
sortFileList(tmpfiles);
|
sortFileList(tmpfiles);
|
||||||
|
|
||||||
if (tmpfiles.size() <= 0) return;
|
if (tmpfiles.size() <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// filter on dirtype
|
// filter on dirtype
|
||||||
Vector<OCFile> files = new Vector<>();
|
Vector<OCFile> files = new Vector<>();
|
||||||
for (OCFile f : tmpfiles)
|
for (OCFile f : tmpfiles) {
|
||||||
files.add(f);
|
files.add(f);
|
||||||
|
}
|
||||||
if (files.size() < position) {
|
if (files.size() < position) {
|
||||||
throw new IndexOutOfBoundsException("Incorrect item selected");
|
throw new IndexOutOfBoundsException("Incorrect item selected");
|
||||||
}
|
}
|
||||||
|
@ -526,8 +528,9 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||||
private String generatePath(Stack<String> dirs) {
|
private String generatePath(Stack<String> dirs) {
|
||||||
String full_path = "";
|
String full_path = "";
|
||||||
|
|
||||||
for (String a : dirs)
|
for (String a : dirs) {
|
||||||
full_path += a + "/";
|
full_path += a + "/";
|
||||||
|
}
|
||||||
return full_path;
|
return full_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,7 +615,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||||
RemoteOperationResult result) {
|
RemoteOperationResult result) {
|
||||||
if (result.isSuccess()) {
|
if (result.isSuccess()) {
|
||||||
String remotePath = operation.getRemotePath().substring(0, operation.getRemotePath().length() - 1);
|
String remotePath = operation.getRemotePath().substring(0, operation.getRemotePath().length() - 1);
|
||||||
String newFolder = remotePath.substring(remotePath.lastIndexOf("/") + 1);
|
String newFolder = remotePath.substring(remotePath.lastIndexOf('/') + 1);
|
||||||
mParents.push(newFolder);
|
mParents.push(newFolder);
|
||||||
populateDirectoryList();
|
populateDirectoryList();
|
||||||
} else {
|
} else {
|
||||||
|
@ -647,8 +650,9 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||||
} else {
|
} else {
|
||||||
String[] dir_names = lastPath.split("/");
|
String[] dir_names = lastPath.split("/");
|
||||||
mParents.clear();
|
mParents.clear();
|
||||||
for (String dir : dir_names)
|
for (String dir : dir_names) {
|
||||||
mParents.add(dir);
|
mParents.add(dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//Make sure that path still exists, if it doesn't pop the stack and try the previous path
|
//Make sure that path still exists, if it doesn't pop the stack and try the previous path
|
||||||
while (!getStorageManager().fileExists(generatePath(mParents)) && mParents.size() > 1) {
|
while (!getStorageManager().fileExists(generatePath(mParents)) && mParents.size() > 1) {
|
||||||
|
@ -752,8 +756,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||||
currentFile = currentDir;
|
currentFile = currentDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (synchFolderRemotePath != null &&
|
if (currentDir.getRemotePath().equals(synchFolderRemotePath)) {
|
||||||
currentDir.getRemotePath().equals(synchFolderRemotePath)) {
|
|
||||||
populateDirectoryList();
|
populateDirectoryList();
|
||||||
}
|
}
|
||||||
mFile = currentFile;
|
mFile = currentFile;
|
||||||
|
|
|
@ -256,8 +256,9 @@ public class UploadFilesActivity extends FileActivity implements
|
||||||
// the next operation triggers a new call to this method, but it's necessary to
|
// the next operation triggers a new call to this method, but it's necessary to
|
||||||
// ensure that the name exposed in the action bar is the current directory when the
|
// ensure that the name exposed in the action bar is the current directory when the
|
||||||
// user selected it in the navigation list
|
// user selected it in the navigation list
|
||||||
if (itemPosition != 0)
|
if (itemPosition != 0) {
|
||||||
getSupportActionBar().setSelectedNavigationItem(0);
|
getSupportActionBar().setSelectedNavigationItem(0);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ public class DiskLruImageCache {
|
||||||
private static final int CACHE_VERSION = 1;
|
private static final int CACHE_VERSION = 1;
|
||||||
private static final int VALUE_COUNT = 1;
|
private static final int VALUE_COUNT = 1;
|
||||||
private static final int IO_BUFFER_SIZE = 8 * 1024;
|
private static final int IO_BUFFER_SIZE = 8 * 1024;
|
||||||
|
private static final String CACHE_TEST_DISK = "cache_test_DISK_";
|
||||||
|
|
||||||
private static final String TAG = DiskLruImageCache.class.getSimpleName();
|
private static final String TAG = DiskLruImageCache.class.getSimpleName();
|
||||||
|
|
||||||
|
@ -85,17 +86,17 @@ public class DiskLruImageCache {
|
||||||
mDiskCache.flush();
|
mDiskCache.flush();
|
||||||
editor.commit();
|
editor.commit();
|
||||||
if ( BuildConfig.DEBUG ) {
|
if ( BuildConfig.DEBUG ) {
|
||||||
Log_OC.d( "cache_test_DISK_", "image put on disk cache " + validKey );
|
Log_OC.d( CACHE_TEST_DISK, "image put on disk cache " + validKey );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
editor.abort();
|
editor.abort();
|
||||||
if ( BuildConfig.DEBUG ) {
|
if ( BuildConfig.DEBUG ) {
|
||||||
Log_OC.d( "cache_test_DISK_", "ERROR on: image put on disk cache " + validKey );
|
Log_OC.d( CACHE_TEST_DISK, "ERROR on: image put on disk cache " + validKey );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if ( BuildConfig.DEBUG ) {
|
if ( BuildConfig.DEBUG ) {
|
||||||
Log_OC.d( "cache_test_DISK_", "ERROR on: image put on disk cache " + validKey );
|
Log_OC.d( CACHE_TEST_DISK, "ERROR on: image put on disk cache " + validKey );
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if ( editor != null ) {
|
if ( editor != null ) {
|
||||||
|
@ -125,15 +126,15 @@ public class DiskLruImageCache {
|
||||||
bitmap = BitmapFactory.decodeStream( buffIn );
|
bitmap = BitmapFactory.decodeStream( buffIn );
|
||||||
}
|
}
|
||||||
} catch ( IOException e ) {
|
} catch ( IOException e ) {
|
||||||
e.printStackTrace();
|
Log_OC.d(TAG, e.getMessage(), e);
|
||||||
} finally {
|
} finally {
|
||||||
if ( snapshot != null ) {
|
if (snapshot != null) {
|
||||||
snapshot.close();
|
snapshot.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( BuildConfig.DEBUG ) {
|
if ( BuildConfig.DEBUG ) {
|
||||||
Log_OC.d("cache_test_DISK_", bitmap == null ?
|
Log_OC.d(CACHE_TEST_DISK, bitmap == null ?
|
||||||
"not found" : "image read from disk " + validKey);
|
"not found" : "image read from disk " + validKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,9 +151,9 @@ public class DiskLruImageCache {
|
||||||
snapshot = mDiskCache.get( validKey );
|
snapshot = mDiskCache.get( validKey );
|
||||||
contained = snapshot != null;
|
contained = snapshot != null;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Log_OC.d(TAG, e.getMessage(), e);
|
||||||
} finally {
|
} finally {
|
||||||
if ( snapshot != null ) {
|
if (snapshot != null) {
|
||||||
snapshot.close();
|
snapshot.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,12 +164,12 @@ public class DiskLruImageCache {
|
||||||
|
|
||||||
public void clearCache() {
|
public void clearCache() {
|
||||||
if ( BuildConfig.DEBUG ) {
|
if ( BuildConfig.DEBUG ) {
|
||||||
Log_OC.d( "cache_test_DISK_", "disk cache CLEARED");
|
Log_OC.d( CACHE_TEST_DISK, "disk cache CLEARED");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
mDiskCache.delete();
|
mDiskCache.delete();
|
||||||
} catch ( IOException e ) {
|
} catch ( IOException e ) {
|
||||||
e.printStackTrace();
|
Log_OC.d(TAG, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +191,7 @@ public class DiskLruImageCache {
|
||||||
mDiskCache.remove(validKey);
|
mDiskCache.remove(validKey);
|
||||||
Log_OC.d(TAG, "removeKey from cache: " + validKey);
|
Log_OC.d(TAG, "removeKey from cache: " + validKey);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Log_OC.d(TAG, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -112,15 +112,17 @@ public class FileListListAdapter extends BaseAdapter implements FilterableListAd
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getItem(int position) {
|
public Object getItem(int position) {
|
||||||
if (mFiles == null || mFiles.size() <= position)
|
if (mFiles == null || mFiles.size() <= position) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
return mFiles.get(position);
|
return mFiles.get(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getItemId(int position) {
|
public long getItemId(int position) {
|
||||||
if (mFiles == null || mFiles.size() <= position)
|
if (mFiles == null || mFiles.size() <= position) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
return mFiles.get(position).getFileId();
|
return mFiles.get(position).getFileId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,7 +386,7 @@ public class FileListListAdapter extends BaseAdapter implements FilterableListAd
|
||||||
*/
|
*/
|
||||||
public void swapDirectory(OCFile directory, FileDataStorageManager updatedStorageManager
|
public void swapDirectory(OCFile directory, FileDataStorageManager updatedStorageManager
|
||||||
, boolean onlyOnDevice) {
|
, boolean onlyOnDevice) {
|
||||||
if (updatedStorageManager != null && updatedStorageManager != mStorageManager) {
|
if (updatedStorageManager != null && updatedStorageManager.equals(mStorageManager)) {
|
||||||
mStorageManager = updatedStorageManager;
|
mStorageManager = updatedStorageManager;
|
||||||
mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
|
mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ import com.owncloud.android.utils.MimeTypeUtil;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
@ -56,7 +57,6 @@ public class LocalFileListAdapter extends BaseAdapter implements FilterableListA
|
||||||
private static final String TAG = LocalFileListAdapter.class.getSimpleName();
|
private static final String TAG = LocalFileListAdapter.class.getSimpleName();
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private File mDirectory;
|
|
||||||
private File[] mFiles = null;
|
private File[] mFiles = null;
|
||||||
private Vector<File> mFilesAll = new Vector<File>();
|
private Vector<File> mFilesAll = new Vector<File>();
|
||||||
|
|
||||||
|
@ -87,8 +87,9 @@ public class LocalFileListAdapter extends BaseAdapter implements FilterableListA
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getItem(int position) {
|
public Object getItem(int position) {
|
||||||
if (mFiles == null || mFiles.length <= position)
|
if (mFiles == null || mFiles.length <= position) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
return mFiles[position];
|
return mFiles[position];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,9 +268,8 @@ public class LocalFileListAdapter extends BaseAdapter implements FilterableListA
|
||||||
* Change the adapted directory for a new one
|
* Change the adapted directory for a new one
|
||||||
* @param directory New file to adapt. Can be NULL, meaning "no content to adapt".
|
* @param directory New file to adapt. Can be NULL, meaning "no content to adapt".
|
||||||
*/
|
*/
|
||||||
public void swapDirectory(File directory) {
|
public void swapDirectory(final File directory) {
|
||||||
mDirectory = directory;
|
mFiles = (directory != null ? directory.listFiles() : null);
|
||||||
mFiles = (mDirectory != null ? mDirectory.listFiles() : null);
|
|
||||||
if (mFiles != null) {
|
if (mFiles != null) {
|
||||||
Arrays.sort(mFiles, new Comparator<File>() {
|
Arrays.sort(mFiles, new Comparator<File>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -298,9 +298,7 @@ public class LocalFileListAdapter extends BaseAdapter implements FilterableListA
|
||||||
|
|
||||||
mFilesAll.clear();
|
mFilesAll.clear();
|
||||||
|
|
||||||
for (File mFile : mFiles) {
|
Collections.addAll(mFilesAll, mFiles);
|
||||||
mFilesAll.add(mFile);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,8 +63,9 @@ public class UploaderAdapter extends SimpleAdapter {
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
View vi = convertView;
|
View vi = convertView;
|
||||||
if (convertView == null)
|
if (convertView == null) {
|
||||||
vi = inflater.inflate(R.layout.uploader_list_item_layout, null);
|
vi = inflater.inflate(R.layout.uploader_list_item_layout, null);
|
||||||
|
}
|
||||||
|
|
||||||
HashMap<String, OCFile> data = (HashMap<String, OCFile>) getItem(position);
|
HashMap<String, OCFile> data = (HashMap<String, OCFile>) getItem(position);
|
||||||
OCFile file = data.get("dirname");
|
OCFile file = data.get("dirname");
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class X509CertificateViewAdapter implements SslUntrustedCertDialog.Certif
|
||||||
final int loVal = b & 0x0F;
|
final int loVal = b & 0x0F;
|
||||||
hex.append((char) ('0' + (hiVal + (hiVal / 10 * 7))));
|
hex.append((char) ('0' + (hiVal + (hiVal / 10 * 7))));
|
||||||
hex.append((char) ('0' + (loVal + (loVal / 10 * 7))));
|
hex.append((char) ('0' + (loVal + (loVal / 10 * 7))));
|
||||||
hex.append(":");
|
hex.append(':');
|
||||||
}
|
}
|
||||||
return digestType + ":" + newLine + hex.toString().replaceFirst("\\:$","") + newLine + newLine;
|
return digestType + ":" + newLine + hex.toString().replaceFirst("\\:$","") + newLine + newLine;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class CopyAndUploadContentUrisTask extends AsyncTask<Object, Void, Result
|
||||||
account,
|
account,
|
||||||
sourceUris,
|
sourceUris,
|
||||||
remotePaths,
|
remotePaths,
|
||||||
new Integer(behaviour),
|
Integer.valueOf(behaviour),
|
||||||
contentResolver
|
contentResolver
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -193,10 +193,8 @@ public class CopyAndUploadContentUrisTask extends AsyncTask<Object, Void, Result
|
||||||
// clean
|
// clean
|
||||||
if (fullTempPath != null) {
|
if (fullTempPath != null) {
|
||||||
File f = new File(fullTempPath);
|
File f = new File(fullTempPath);
|
||||||
if (f.exists()) {
|
if (f.exists() && !f.delete()) {
|
||||||
if (!f.delete()) {
|
Log_OC.e(TAG, "Could not delete temporary file " + fullTempPath);
|
||||||
Log_OC.e(TAG, "Could not delete temporary file " + fullTempPath);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,15 +92,15 @@ public class ConfirmationDialogFragment extends DialogFragment {
|
||||||
int posBtn = getArguments().getInt(ARG_POSITIVE_BTN_RES, -1);
|
int posBtn = getArguments().getInt(ARG_POSITIVE_BTN_RES, -1);
|
||||||
int neuBtn = getArguments().getInt(ARG_NEUTRAL_BTN_RES, -1);
|
int neuBtn = getArguments().getInt(ARG_NEUTRAL_BTN_RES, -1);
|
||||||
int negBtn = getArguments().getInt(ARG_NEGATIVE_BTN_RES, -1);
|
int negBtn = getArguments().getInt(ARG_NEGATIVE_BTN_RES, -1);
|
||||||
|
|
||||||
if (messageArguments == null) {
|
if (messageArguments == null) {
|
||||||
messageArguments = new String[]{};
|
messageArguments = new String[]{};
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.Theme_ownCloud_Dialog)
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.Theme_ownCloud_Dialog)
|
||||||
.setIcon(R.drawable.ic_warning)
|
.setIcon(R.drawable.ic_warning)
|
||||||
.setIconAttribute(android.R.attr.alertDialogIcon)
|
.setIconAttribute(android.R.attr.alertDialogIcon)
|
||||||
.setMessage(String.format(getString(messageId), messageArguments));
|
.setMessage(String.format(getString(messageId), messageArguments));
|
||||||
|
|
||||||
if (titleId == 0) {
|
if (titleId == 0) {
|
||||||
builder.setTitle(android.R.string.dialog_alert_title);
|
builder.setTitle(android.R.string.dialog_alert_title);
|
||||||
|
@ -108,7 +108,7 @@ public class ConfirmationDialogFragment extends DialogFragment {
|
||||||
builder.setTitle(titleId);
|
builder.setTitle(titleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (posBtn != -1)
|
if (posBtn != -1) {
|
||||||
builder.setPositiveButton(posBtn,
|
builder.setPositiveButton(posBtn,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
|
@ -118,7 +118,8 @@ public class ConfirmationDialogFragment extends DialogFragment {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (neuBtn != -1)
|
}
|
||||||
|
if (neuBtn != -1) {
|
||||||
builder.setNeutralButton(neuBtn,
|
builder.setNeutralButton(neuBtn,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
|
@ -128,7 +129,8 @@ public class ConfirmationDialogFragment extends DialogFragment {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (negBtn != -1)
|
}
|
||||||
|
if (negBtn != -1) {
|
||||||
builder.setNegativeButton(negBtn,
|
builder.setNegativeButton(negBtn,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -139,6 +141,7 @@ public class ConfirmationDialogFragment extends DialogFragment {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return builder.create();
|
return builder.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,24 +69,27 @@ public class ConflictsResolveDialog extends DialogFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (mListener != null)
|
if (mListener != null) {
|
||||||
mListener.conflictDecisionMade(Decision.OVERWRITE);
|
mListener.conflictDecisionMade(Decision.OVERWRITE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNeutralButton(R.string.conflict_keep_both,
|
.setNeutralButton(R.string.conflict_keep_both,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (mListener != null)
|
if (mListener != null) {
|
||||||
mListener.conflictDecisionMade(Decision.KEEP_BOTH);
|
mListener.conflictDecisionMade(Decision.KEEP_BOTH);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.conflict_use_server_version,
|
.setNegativeButton(R.string.conflict_use_server_version,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (mListener != null)
|
if (mListener != null) {
|
||||||
mListener.conflictDecisionMade(Decision.SERVER);
|
mListener.conflictDecisionMade(Decision.SERVER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.create();
|
.create();
|
||||||
|
|
|
@ -148,8 +148,9 @@ public class CredentialsDialogFragment extends DialogFragment
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
if (getDialog() != null && getRetainInstance())
|
if (getDialog() != null && getRetainInstance()) {
|
||||||
getDialog().setDismissMessage(null);
|
getDialog().setDismissMessage(null);
|
||||||
|
}
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,8 +76,9 @@ public class LoadingDialog extends DialogFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
if (getDialog() != null && getRetainInstance())
|
if (getDialog() != null && getRetainInstance()) {
|
||||||
getDialog().setDismissMessage(null);
|
getDialog().setDismissMessage(null);
|
||||||
|
}
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,8 +117,9 @@ implements ConfirmationDialogFragmentListener {
|
||||||
for(OCFile file: files) {
|
for(OCFile file: files) {
|
||||||
containsFavorite = file.isFavorite() || containsFavorite;
|
containsFavorite = file.isFavorite() || containsFavorite;
|
||||||
|
|
||||||
if (containsFavorite)
|
if (containsFavorite) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class RenameFileDialogFragment
|
||||||
EditText inputText = ((EditText)v.findViewById(R.id.user_input));
|
EditText inputText = ((EditText)v.findViewById(R.id.user_input));
|
||||||
inputText.setText(currentName);
|
inputText.setText(currentName);
|
||||||
int selectionStart = 0;
|
int selectionStart = 0;
|
||||||
int extensionStart = mTargetFile.isFolder() ? -1 : currentName.lastIndexOf(".");
|
int extensionStart = mTargetFile.isFolder() ? -1 : currentName.lastIndexOf('.');
|
||||||
int selectionEnd = (extensionStart >= 0) ? extensionStart : currentName.length();
|
int selectionEnd = (extensionStart >= 0) ? extensionStart : currentName.length();
|
||||||
if (selectionStart >= 0 && selectionEnd >= 0) {
|
if (selectionStart >= 0 && selectionEnd >= 0) {
|
||||||
inputText.setSelection(
|
inputText.setSelection(
|
||||||
|
|
|
@ -51,8 +51,6 @@ import com.owncloud.android.lib.common.utils.Log_OC;
|
||||||
*/
|
*/
|
||||||
public class SamlWebViewDialog extends DialogFragment {
|
public class SamlWebViewDialog extends DialogFragment {
|
||||||
|
|
||||||
public final String SAML_DIALOG_TAG = "SamlWebViewDialog";
|
|
||||||
|
|
||||||
private final static String TAG = SamlWebViewDialog.class.getSimpleName();
|
private final static String TAG = SamlWebViewDialog.class.getSimpleName();
|
||||||
|
|
||||||
private static final String ARG_INITIAL_URL = "INITIAL_URL";
|
private static final String ARG_INITIAL_URL = "INITIAL_URL";
|
||||||
|
@ -63,8 +61,6 @@ public class SamlWebViewDialog extends DialogFragment {
|
||||||
|
|
||||||
private String mInitialUrl;
|
private String mInitialUrl;
|
||||||
private String mTargetUrl;
|
private String mTargetUrl;
|
||||||
|
|
||||||
private Handler mHandler;
|
|
||||||
|
|
||||||
private SsoWebViewClientListener mSsoWebViewClientListener;
|
private SsoWebViewClientListener mSsoWebViewClientListener;
|
||||||
|
|
||||||
|
@ -97,7 +93,7 @@ public class SamlWebViewDialog extends DialogFragment {
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
try {
|
try {
|
||||||
mSsoWebViewClientListener = (SsoWebViewClientListener) activity;
|
mSsoWebViewClientListener = (SsoWebViewClientListener) activity;
|
||||||
mHandler = new Handler();
|
Handler mHandler = new Handler();
|
||||||
mWebViewClient = new SsoWebViewClient(activity, mHandler, mSsoWebViewClientListener);
|
mWebViewClient = new SsoWebViewClient(activity, mHandler, mSsoWebViewClientListener);
|
||||||
|
|
||||||
} catch (ClassCastException e) {
|
} catch (ClassCastException e) {
|
||||||
|
|
|
@ -179,8 +179,9 @@ public class SslUntrustedCertDialog extends DialogFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
Log_OC.d(TAG, "onDestroyView");
|
Log_OC.d(TAG, "onDestroyView");
|
||||||
if (getDialog() != null && getRetainInstance())
|
if (getDialog() != null && getRetainInstance()) {
|
||||||
getDialog().setDismissMessage(null);
|
getDialog().setDismissMessage(null);
|
||||||
|
}
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,7 @@ public class SslValidatorDialog extends Dialog {
|
||||||
*/
|
*/
|
||||||
public static SslValidatorDialog newInstance(Context context, RemoteOperationResult result, OnSslValidatorListener listener) {
|
public static SslValidatorDialog newInstance(Context context, RemoteOperationResult result, OnSslValidatorListener listener) {
|
||||||
if (result != null && result.isSslRecoverableException()) {
|
if (result != null && result.isSslRecoverableException()) {
|
||||||
SslValidatorDialog dialog = new SslValidatorDialog(context, listener);
|
return new SslValidatorDialog(context, listener);
|
||||||
return dialog;
|
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -109,22 +108,19 @@ public class SslValidatorDialog extends Dialog {
|
||||||
try {
|
try {
|
||||||
saveServerCert();
|
saveServerCert();
|
||||||
dismiss();
|
dismiss();
|
||||||
if (mListener != null)
|
if (mListener != null) {
|
||||||
mListener.onSavedCertificate();
|
mListener.onSavedCertificate();
|
||||||
else
|
} else {
|
||||||
Log_OC.d(TAG, "Nobody there to notify the certificate was saved");
|
Log_OC.d(TAG, "Nobody there to notify the certificate was saved");
|
||||||
|
}
|
||||||
|
|
||||||
} catch (GeneralSecurityException e) {
|
} catch (GeneralSecurityException | IOException e) {
|
||||||
dismiss();
|
dismiss();
|
||||||
if (mListener != null)
|
if (mListener != null) {
|
||||||
mListener.onFailedSavingCertificate();
|
mListener.onFailedSavingCertificate();
|
||||||
|
}
|
||||||
Log_OC.e(TAG, "Server certificate could not be saved in the known servers trust store ", e);
|
Log_OC.e(TAG, "Server certificate could not be saved in the known servers trust store ", e);
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
dismiss();
|
|
||||||
if (mListener != null)
|
|
||||||
mListener.onFailedSavingCertificate();
|
|
||||||
Log_OC.e(TAG, "Server certificate could not be saved in the known servers trust store ", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -145,7 +141,6 @@ public class SslValidatorDialog extends Dialog {
|
||||||
if (detailsScroll.getVisibility() == View.VISIBLE) {
|
if (detailsScroll.getVisibility() == View.VISIBLE) {
|
||||||
detailsScroll.setVisibility(View.GONE);
|
detailsScroll.setVisibility(View.GONE);
|
||||||
((Button) v).setText(R.string.ssl_validator_btn_details_see);
|
((Button) v).setText(R.string.ssl_validator_btn_details_see);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
detailsScroll.setVisibility(View.VISIBLE);
|
detailsScroll.setVisibility(View.VISIBLE);
|
||||||
((Button) v).setText(R.string.ssl_validator_btn_details_hide);
|
((Button) v).setText(R.string.ssl_validator_btn_details_hide);
|
||||||
|
@ -198,8 +193,8 @@ public class SslValidatorDialog extends Dialog {
|
||||||
showSignature(cert);
|
showSignature(cert);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// this should not happen
|
// this should not happen, TODO
|
||||||
// TODO
|
Log_OC.d("certNull", "This should not happen");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ import android.util.Log;
|
||||||
|
|
||||||
public class ExceptionHandler implements java.lang.Thread.UncaughtExceptionHandler {
|
public class ExceptionHandler implements java.lang.Thread.UncaughtExceptionHandler {
|
||||||
private final Activity mContext;
|
private final Activity mContext;
|
||||||
private final String LINE_SEPARATOR = "\n";
|
|
||||||
|
|
||||||
private static final String TAG = ExceptionHandler.class.getSimpleName();
|
private static final String TAG = ExceptionHandler.class.getSimpleName();
|
||||||
|
|
||||||
|
@ -41,36 +40,34 @@ public class ExceptionHandler implements java.lang.Thread.UncaughtExceptionHandl
|
||||||
Log.e(TAG, "ExceptionHandler caught UncaughtException", exception);
|
Log.e(TAG, "ExceptionHandler caught UncaughtException", exception);
|
||||||
StringWriter stackTrace = new StringWriter();
|
StringWriter stackTrace = new StringWriter();
|
||||||
exception.printStackTrace(new PrintWriter(stackTrace));
|
exception.printStackTrace(new PrintWriter(stackTrace));
|
||||||
StringBuilder errorReport = new StringBuilder();
|
final StringBuilder errorReport = new StringBuilder(192);
|
||||||
errorReport.append("************ CAUSE OF ERROR ************\n\n");
|
final String LINE_SEPARATOR = "\n";
|
||||||
errorReport.append(stackTrace.toString());
|
errorReport.append("************ CAUSE OF ERROR ************\n\n")
|
||||||
|
.append(stackTrace.toString())
|
||||||
errorReport.append("\n************ DEVICE INFORMATION ***********\n");
|
.append("\n************ DEVICE INFORMATION ***********\nBrand: ")
|
||||||
errorReport.append("Brand: ");
|
.append(Build.BRAND)
|
||||||
errorReport.append(Build.BRAND);
|
.append(LINE_SEPARATOR)
|
||||||
errorReport.append(LINE_SEPARATOR);
|
.append("Device: ")
|
||||||
errorReport.append("Device: ");
|
.append(Build.DEVICE)
|
||||||
errorReport.append(Build.DEVICE);
|
.append(LINE_SEPARATOR)
|
||||||
errorReport.append(LINE_SEPARATOR);
|
.append("Model: ")
|
||||||
errorReport.append("Model: ");
|
.append(Build.MODEL)
|
||||||
errorReport.append(Build.MODEL);
|
.append(LINE_SEPARATOR)
|
||||||
errorReport.append(LINE_SEPARATOR);
|
.append("Id: ")
|
||||||
errorReport.append("Id: ");
|
.append(Build.ID)
|
||||||
errorReport.append(Build.ID);
|
.append(LINE_SEPARATOR)
|
||||||
errorReport.append(LINE_SEPARATOR);
|
.append("Product: ")
|
||||||
errorReport.append("Product: ");
|
.append(Build.PRODUCT)
|
||||||
errorReport.append(Build.PRODUCT);
|
.append(LINE_SEPARATOR)
|
||||||
errorReport.append(LINE_SEPARATOR);
|
.append("\n************ FIRMWARE ************\nSDK: ")
|
||||||
errorReport.append("\n************ FIRMWARE ************\n");
|
.append(Build.VERSION.SDK_INT)
|
||||||
errorReport.append("SDK: ");
|
.append(LINE_SEPARATOR)
|
||||||
errorReport.append(Build.VERSION.SDK_INT);
|
.append("Release: ")
|
||||||
errorReport.append(LINE_SEPARATOR);
|
.append(Build.VERSION.RELEASE)
|
||||||
errorReport.append("Release: ");
|
.append(LINE_SEPARATOR)
|
||||||
errorReport.append(Build.VERSION.RELEASE);
|
.append("Incremental: ")
|
||||||
errorReport.append(LINE_SEPARATOR);
|
.append(Build.VERSION.INCREMENTAL)
|
||||||
errorReport.append("Incremental: ");
|
.append(LINE_SEPARATOR);
|
||||||
errorReport.append(Build.VERSION.INCREMENTAL);
|
|
||||||
errorReport.append(LINE_SEPARATOR);
|
|
||||||
|
|
||||||
Log.e(TAG, "An exception was thrown and handled by ExceptionHandler:", exception);
|
Log.e(TAG, "An exception was thrown and handled by ExceptionHandler:", exception);
|
||||||
|
|
||||||
|
|
|
@ -64,9 +64,6 @@ public class EditShareFragment extends Fragment {
|
||||||
/** File bound to mShare, received as a parameter in construction time */
|
/** File bound to mShare, received as a parameter in construction time */
|
||||||
private OCFile mFile;
|
private OCFile mFile;
|
||||||
|
|
||||||
/** OC account holding the shared file, received as a parameter in construction time */
|
|
||||||
private Account mAccount;
|
|
||||||
|
|
||||||
/** Listener for changes on privilege checkboxes */
|
/** Listener for changes on privilege checkboxes */
|
||||||
private CompoundButton.OnCheckedChangeListener mOnPrivilegeChangeListener;
|
private CompoundButton.OnCheckedChangeListener mOnPrivilegeChangeListener;
|
||||||
|
|
||||||
|
@ -106,7 +103,8 @@ public class EditShareFragment extends Fragment {
|
||||||
if (getArguments() != null) {
|
if (getArguments() != null) {
|
||||||
mShare = getArguments().getParcelable(ARG_SHARE);
|
mShare = getArguments().getParcelable(ARG_SHARE);
|
||||||
mFile = getArguments().getParcelable(ARG_FILE);
|
mFile = getArguments().getParcelable(ARG_FILE);
|
||||||
mAccount = getArguments().getParcelable(ARG_ACCOUNT);
|
/* OC account holding the shared file, received as a parameter in construction time */
|
||||||
|
Account mAccount = getArguments().getParcelable(ARG_ACCOUNT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ public class ExtendedListFragment extends Fragment
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGridEnabled(){
|
public boolean isGridEnabled(){
|
||||||
return (mCurrentListView == mGridView);
|
return mCurrentListView.equals(mGridView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -283,7 +283,7 @@ public class ExtendedListFragment extends Fragment
|
||||||
Log_OC.v(TAG, "Setting selection to position: " + firstPosition + "; top: "
|
Log_OC.v(TAG, "Setting selection to position: " + firstPosition + "; top: "
|
||||||
+ top + "; index: " + index);
|
+ top + "; index: " + index);
|
||||||
|
|
||||||
if (mCurrentListView == mListView) {
|
if (mCurrentListView.equals(mListView)) {
|
||||||
if (mHeightCell*index <= mListView.getHeight()) {
|
if (mHeightCell*index <= mListView.getHeight()) {
|
||||||
mListView.setSelectionFromTop(firstPosition, top);
|
mListView.setSelectionFromTop(firstPosition, top);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -195,7 +195,9 @@ public class LocalFileListFragment extends ExtendedListFragment {
|
||||||
} else {
|
} else {
|
||||||
directory = Environment.getExternalStorageDirectory();
|
directory = Environment.getExternalStorageDirectory();
|
||||||
// TODO be careful with the state of the storage; could not be available
|
// TODO be careful with the state of the storage; could not be available
|
||||||
if (directory == null) return; // no files to show
|
if (directory == null) {
|
||||||
|
return; // no files to show
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class OCFileListFragment extends ExtendedListFragment {
|
||||||
|
|
||||||
private static final String GRID_IS_PREFERED_PREFERENCE = "gridIsPrefered";
|
private static final String GRID_IS_PREFERED_PREFERENCE = "gridIsPrefered";
|
||||||
|
|
||||||
private static String DIALOG_CREATE_FOLDER = "DIALOG_CREATE_FOLDER";
|
private static final String DIALOG_CREATE_FOLDER = "DIALOG_CREATE_FOLDER";
|
||||||
|
|
||||||
private FileFragment.ContainerActivity mContainerActivity;
|
private FileFragment.ContainerActivity mContainerActivity;
|
||||||
|
|
||||||
|
@ -586,7 +586,7 @@ public class OCFileListFragment extends ExtendedListFragment {
|
||||||
} // exit is granted because storageManager.getFileByPath("/") never returns null
|
} // exit is granted because storageManager.getFileByPath("/") never returns null
|
||||||
mFile = parentDir;
|
mFile = parentDir;
|
||||||
|
|
||||||
listDirectory(mFile, MainApp.getOnlyOnDevice());
|
listDirectory(mFile, MainApp.isOnlyOnDevice());
|
||||||
|
|
||||||
onRefresh(false);
|
onRefresh(false);
|
||||||
|
|
||||||
|
@ -604,7 +604,7 @@ public class OCFileListFragment extends ExtendedListFragment {
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
if (file.isFolder()) {
|
if (file.isFolder()) {
|
||||||
// update state and view of this fragment
|
// update state and view of this fragment
|
||||||
listDirectory(file, MainApp.getOnlyOnDevice());
|
listDirectory(file, MainApp.isOnlyOnDevice());
|
||||||
// then, notify parent activity to let it update its state and view
|
// then, notify parent activity to let it update its state and view
|
||||||
mContainerActivity.onBrowsedDownTo(file);
|
mContainerActivity.onBrowsedDownTo(file);
|
||||||
// save index and top position
|
// save index and top position
|
||||||
|
@ -645,7 +645,9 @@ public class OCFileListFragment extends ExtendedListFragment {
|
||||||
*/
|
*/
|
||||||
public boolean onFileActionChosen(int menuId) {
|
public boolean onFileActionChosen(int menuId) {
|
||||||
final ArrayList<OCFile> checkedFiles = mAdapter.getCheckedItems(getListView());
|
final ArrayList<OCFile> checkedFiles = mAdapter.getCheckedItems(getListView());
|
||||||
if (checkedFiles.size() <= 0) return false;
|
if (checkedFiles.size() <= 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (checkedFiles.size() == 1) {
|
if (checkedFiles.size() == 1) {
|
||||||
/// action only possible on a single file
|
/// action only possible on a single file
|
||||||
|
@ -745,7 +747,7 @@ public class OCFileListFragment extends ExtendedListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshDirectory(){
|
public void refreshDirectory(){
|
||||||
listDirectory(getCurrentFile(), MainApp.getOnlyOnDevice());
|
listDirectory(getCurrentFile(), MainApp.isOnlyOnDevice());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -765,7 +767,9 @@ public class OCFileListFragment extends ExtendedListFragment {
|
||||||
directory = mFile;
|
directory = mFile;
|
||||||
} else {
|
} else {
|
||||||
directory = storageManager.getFileByPath("/");
|
directory = storageManager.getFileByPath("/");
|
||||||
if (directory == null) return; // no files, wait for sync
|
if (directory == null) {
|
||||||
|
return; // no files, wait for sync
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ import com.owncloud.android.ui.adapter.ExpandableUploadListAdapter;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class UploadListFragment extends ExpandableListFragment {
|
public class UploadListFragment extends ExpandableListFragment {
|
||||||
static private String TAG = UploadListFragment.class.getSimpleName();
|
private static final String TAG = UploadListFragment.class.getSimpleName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference to the Activity which this fragment is attached to. For
|
* Reference to the Activity which this fragment is attached to. For
|
||||||
|
|
|
@ -279,26 +279,22 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene
|
||||||
|
|
||||||
|
|
||||||
public void listenForTransferProgress() {
|
public void listenForTransferProgress() {
|
||||||
if (mProgressListener != null && !mListening) {
|
if (mProgressListener != null && !mListening && mContainerActivity.getFileDownloaderBinder() != null) {
|
||||||
if (mContainerActivity.getFileDownloaderBinder() != null) {
|
mContainerActivity.getFileDownloaderBinder().addDatatransferProgressListener(
|
||||||
mContainerActivity.getFileDownloaderBinder().addDatatransferProgressListener(
|
mProgressListener, mAccount, getFile()
|
||||||
mProgressListener, mAccount, getFile()
|
);
|
||||||
);
|
mListening = true;
|
||||||
mListening = true;
|
setButtonsForTransferring();
|
||||||
setButtonsForTransferring();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void leaveTransferProgress() {
|
public void leaveTransferProgress() {
|
||||||
if (mProgressListener != null) {
|
if (mProgressListener != null && mContainerActivity.getFileDownloaderBinder() != null) {
|
||||||
if (mContainerActivity.getFileDownloaderBinder() != null) {
|
mContainerActivity.getFileDownloaderBinder().removeDatatransferProgressListener(
|
||||||
mContainerActivity.getFileDownloaderBinder().removeDatatransferProgressListener(
|
mProgressListener, mAccount, getFile()
|
||||||
mProgressListener, mAccount, getFile()
|
);
|
||||||
);
|
mListening = false;
|
||||||
mListening = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
/**
|
/**
|
||||||
* Holds a swiping galley where image files contained in an ownCloud directory are shown
|
* Holds a swiping galley where image files contained in an ownCloud directory are shown
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
||||||
public class PreviewImageActivity extends FileActivity implements
|
public class PreviewImageActivity extends FileActivity implements
|
||||||
FileFragment.ContainerActivity,
|
FileFragment.ContainerActivity,
|
||||||
ViewPager.OnPageChangeListener, OnRemoteOperationListener {
|
ViewPager.OnPageChangeListener, OnRemoteOperationListener {
|
||||||
|
@ -154,7 +155,7 @@ public class PreviewImageActivity extends FileActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(),
|
mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(),
|
||||||
parentFolder, getAccount(), getStorageManager(), MainApp.getOnlyOnDevice());
|
parentFolder, getAccount(), getStorageManager(), MainApp.isOnlyOnDevice());
|
||||||
|
|
||||||
mViewPager = (ExtendedViewPager) findViewById(R.id.fragmentPager);
|
mViewPager = (ExtendedViewPager) findViewById(R.id.fragmentPager);
|
||||||
int position = mHasSavedPosition ? mSavedPosition :
|
int position = mHasSavedPosition ? mSavedPosition :
|
||||||
|
@ -393,10 +394,9 @@ public class PreviewImageActivity extends FileActivity implements
|
||||||
OCFile currentFile = mPreviewImagePagerAdapter.getFileAt(position);
|
OCFile currentFile = mPreviewImagePagerAdapter.getFileAt(position);
|
||||||
getSupportActionBar().setTitle(currentFile.getFileName());
|
getSupportActionBar().setTitle(currentFile.getFileName());
|
||||||
setDrawerIndicatorEnabled(false);
|
setDrawerIndicatorEnabled(false);
|
||||||
if (!currentFile.isDown()) {
|
if (!currentFile.isDown()
|
||||||
if (!mPreviewImagePagerAdapter.pendingErrorAt(position)) {
|
&& !mPreviewImagePagerAdapter.pendingErrorAt(position)) {
|
||||||
requestForDownload(currentFile);
|
requestForDownload(currentFile);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call to reset image zoom to initial state
|
// Call to reset image zoom to initial state
|
||||||
|
@ -522,8 +522,9 @@ public class PreviewImageActivity extends FileActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update file according to DB file, if it is possible
|
// Update file according to DB file, if it is possible
|
||||||
if (file.getFileId() > FileDataStorageManager.ROOT_PARENT_ID)
|
if (file.getFileId() > FileDataStorageManager.ROOT_PARENT_ID) {
|
||||||
file = getStorageManager().getFileById(file.getFileId());
|
file = getStorageManager().getFileById(file.getFileId());
|
||||||
|
}
|
||||||
|
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
/// Refresh the activity according to the Account and OCFile set
|
/// Refresh the activity according to the Account and OCFile set
|
||||||
|
|
|
@ -413,7 +413,9 @@ public class PreviewImageFragment extends FileFragment {
|
||||||
@Override
|
@Override
|
||||||
protected LoadImage doInBackground(OCFile... params) {
|
protected LoadImage doInBackground(OCFile... params) {
|
||||||
Bitmap result = null;
|
Bitmap result = null;
|
||||||
if (params.length != 1) return null;
|
if (params.length != 1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
OCFile ocFile = params[0];
|
OCFile ocFile = params[0];
|
||||||
String storagePath = ocFile.getStoragePath();
|
String storagePath = ocFile.getStoragePath();
|
||||||
try {
|
try {
|
||||||
|
@ -423,12 +425,16 @@ public class PreviewImageFragment extends FileFragment {
|
||||||
int minWidth = screenSize.x;
|
int minWidth = screenSize.x;
|
||||||
int minHeight = screenSize.y;
|
int minHeight = screenSize.y;
|
||||||
for (int i = 0; i < maxDownScale && result == null; i++) {
|
for (int i = 0; i < maxDownScale && result == null; i++) {
|
||||||
if (isCancelled()) return null;
|
if (isCancelled()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
result = BitmapUtils.decodeSampledBitmapFromFile(storagePath, minWidth,
|
result = BitmapUtils.decodeSampledBitmapFromFile(storagePath, minWidth,
|
||||||
minHeight);
|
minHeight);
|
||||||
|
|
||||||
if (isCancelled()) return new LoadImage(result, ocFile);
|
if (isCancelled()) {
|
||||||
|
return new LoadImage(result, ocFile);
|
||||||
|
}
|
||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
mErrorMessageId = R.string.preview_image_error_unknown_format;
|
mErrorMessageId = R.string.preview_image_error_unknown_format;
|
||||||
|
|
|
@ -543,7 +543,7 @@ public class PreviewMediaFragment extends FileFragment implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
if (event.getAction() == MotionEvent.ACTION_DOWN && v == mVideoPreview) {
|
if (event.getAction() == MotionEvent.ACTION_DOWN && v.equals(mVideoPreview)) {
|
||||||
// added a margin on the left to avoid interfering with gesture to open navigation drawer
|
// added a margin on the left to avoid interfering with gesture to open navigation drawer
|
||||||
if (event.getX() / Resources.getSystem().getDisplayMetrics().density > 24.0) {
|
if (event.getX() / Resources.getSystem().getDisplayMetrics().density > 24.0) {
|
||||||
startFullScreenVideo();
|
startFullScreenVideo();
|
||||||
|
@ -614,21 +614,18 @@ public class PreviewMediaFragment extends FileFragment implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceConnected(ComponentName component, IBinder service) {
|
public void onServiceConnected(ComponentName component, IBinder service) {
|
||||||
if (getActivity() != null) {
|
if (getActivity() != null
|
||||||
if (component.equals(
|
&& component.equals(new ComponentName(getActivity(), MediaService.class))) {
|
||||||
new ComponentName(getActivity(), MediaService.class))) {
|
Log_OC.d(TAG, "Media service connected");
|
||||||
Log_OC.d(TAG, "Media service connected");
|
mMediaServiceBinder = (MediaServiceBinder) service;
|
||||||
mMediaServiceBinder = (MediaServiceBinder) service;
|
if (mMediaServiceBinder != null) {
|
||||||
if (mMediaServiceBinder != null) {
|
prepareMediaController();
|
||||||
prepareMediaController();
|
playAudio(); // do not wait for the touch of nobody to play audio
|
||||||
playAudio(); // do not wait for the touch of nobody to play audio
|
|
||||||
|
|
||||||
Log_OC.d(TAG, "Successfully bound to MediaService, MediaController ready");
|
Log_OC.d(TAG, "Successfully bound to MediaService, MediaController ready");
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else {
|
Log_OC.e(TAG, "Unexpected response from MediaService while binding");
|
||||||
Log_OC.e(TAG, "Unexpected response from MediaService while binding");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,7 @@ public class PreviewTextFragment extends FileFragment {
|
||||||
* Reads the file to preview and shows its contents. Too critical to be anonymous.
|
* Reads the file to preview and shows its contents. Too critical to be anonymous.
|
||||||
*/
|
*/
|
||||||
private class TextLoadAsyncTask extends AsyncTask<Object, Void, StringWriter> {
|
private class TextLoadAsyncTask extends AsyncTask<Object, Void, StringWriter> {
|
||||||
private final String DIALOG_WAIT_TAG = "DIALOG_WAIT";
|
private static final String DIALOG_WAIT_TAG = "DIALOG_WAIT";
|
||||||
private final WeakReference<TextView> mTextViewReference;
|
private final WeakReference<TextView> mTextViewReference;
|
||||||
|
|
||||||
private TextLoadAsyncTask(WeakReference<TextView> textView) {
|
private TextLoadAsyncTask(WeakReference<TextView> textView) {
|
||||||
|
@ -185,11 +185,15 @@ public class PreviewTextFragment extends FileFragment {
|
||||||
sc = new Scanner(inputStream);
|
sc = new Scanner(inputStream);
|
||||||
while (sc.hasNextLine()) {
|
while (sc.hasNextLine()) {
|
||||||
bufferedWriter.append(sc.nextLine());
|
bufferedWriter.append(sc.nextLine());
|
||||||
if (sc.hasNextLine()) bufferedWriter.append("\n");
|
if (sc.hasNextLine()) {
|
||||||
|
bufferedWriter.append("\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bufferedWriter.close();
|
bufferedWriter.close();
|
||||||
IOException exc = sc.ioException();
|
IOException exc = sc.ioException();
|
||||||
if (exc != null) throw exc;
|
if (exc != null) {
|
||||||
|
throw exc;
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log_OC.e(TAG, e.getMessage(), e);
|
Log_OC.e(TAG, e.getMessage(), e);
|
||||||
finish();
|
finish();
|
||||||
|
|
|
@ -171,7 +171,7 @@ public class BitmapUtils {
|
||||||
|
|
||||||
// Rotate the bitmap
|
// Rotate the bitmap
|
||||||
resultBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
|
resultBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
|
||||||
if (resultBitmap != bitmap) {
|
if (!resultBitmap.equals(bitmap)) {
|
||||||
bitmap.recycle();
|
bitmap.recycle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,6 +192,7 @@ public class BitmapUtils {
|
||||||
* adapted from https://svn.codehaus.org/griffon/builders/gfxbuilder/tags/GFXBUILDER_0.2/
|
* adapted from https://svn.codehaus.org/griffon/builders/gfxbuilder/tags/GFXBUILDER_0.2/
|
||||||
* gfxbuilder-core/src/main/com/camick/awt/HSLColor.java
|
* gfxbuilder-core/src/main/com/camick/awt/HSLColor.java
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("PMD.MethodNamingConventions")
|
||||||
public static int[] HSLtoRGB(float h, float s, float l, float alpha)
|
public static int[] HSLtoRGB(float h, float s, float l, float alpha)
|
||||||
{
|
{
|
||||||
if (s <0.0f || s > 100.0f)
|
if (s <0.0f || s > 100.0f)
|
||||||
|
@ -221,10 +222,11 @@ public class BitmapUtils {
|
||||||
|
|
||||||
float q = 0;
|
float q = 0;
|
||||||
|
|
||||||
if (l < 0.5)
|
if (l < 0.5) {
|
||||||
q = l * (1 + s);
|
q = l * (1 + s);
|
||||||
else
|
} else {
|
||||||
q = (l + s) - (s * l);
|
q = (l + s) - (s * l);
|
||||||
|
}
|
||||||
|
|
||||||
float p = 2 * l - q;
|
float p = 2 * l - q;
|
||||||
|
|
||||||
|
@ -232,27 +234,28 @@ public class BitmapUtils {
|
||||||
int g = Math.round(Math.max(0, HueToRGB(p, q, h) * 256));
|
int g = Math.round(Math.max(0, HueToRGB(p, q, h) * 256));
|
||||||
int b = Math.round(Math.max(0, HueToRGB(p, q, h - (1.0f / 3.0f)) * 256));
|
int b = Math.round(Math.max(0, HueToRGB(p, q, h - (1.0f / 3.0f)) * 256));
|
||||||
|
|
||||||
int[] array = {r, g, b};
|
return new int[]{r, g, b};
|
||||||
return array;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("PMD.MethodNamingConventions")
|
||||||
private static float HueToRGB(float p, float q, float h){
|
private static float HueToRGB(float p, float q, float h){
|
||||||
if (h < 0) h += 1;
|
if (h < 0) {
|
||||||
|
h += 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (h > 1 ) h -= 1;
|
if (h > 1 ) {
|
||||||
|
h -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (6 * h < 1)
|
if (6 * h < 1) {
|
||||||
{
|
|
||||||
return p + ((q - p) * 6 * h);
|
return p + ((q - p) * 6 * h);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (2 * h < 1 )
|
if (2 * h < 1 ) {
|
||||||
{
|
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (3 * h < 2)
|
if (3 * h < 2) {
|
||||||
{
|
|
||||||
return p + ( (q - p) * 6 * ((2.0f / 3.0f) - h) );
|
return p + ( (q - p) * 6 * ((2.0f / 3.0f) - h) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class DisplayUtils {
|
||||||
suffixIndex++;
|
suffixIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new BigDecimal(result).setScale(
|
return new BigDecimal(String.valueOf(result)).setScale(
|
||||||
sizeScales[suffixIndex], BigDecimal.ROUND_HALF_UP) + " " + sizeSuffixes[suffixIndex];
|
sizeScales[suffixIndex], BigDecimal.ROUND_HALF_UP) + " " + sizeSuffixes[suffixIndex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,8 +127,9 @@ public class DisplayUtils {
|
||||||
if (mimeType2HumanReadable.containsKey(mimetype)) {
|
if (mimeType2HumanReadable.containsKey(mimetype)) {
|
||||||
return mimeType2HumanReadable.get(mimetype);
|
return mimeType2HumanReadable.get(mimetype);
|
||||||
}
|
}
|
||||||
if (mimetype.split("/").length >= 2)
|
if (mimetype.split("/").length >= 2) {
|
||||||
return mimetype.split("/")[1].toUpperCase() + " file";
|
return mimetype.split("/")[1].toUpperCase() + " file";
|
||||||
|
}
|
||||||
return MIME_TYPE_UNKNOWN;
|
return MIME_TYPE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +168,7 @@ public class DisplayUtils {
|
||||||
if (urlNoDots.contains("//")) {
|
if (urlNoDots.contains("//")) {
|
||||||
hostStart = url.indexOf("//") + "//".length();
|
hostStart = url.indexOf("//") + "//".length();
|
||||||
} else if (url.contains("@")) {
|
} else if (url.contains("@")) {
|
||||||
hostStart = url.indexOf("@") + "@".length();
|
hostStart = url.indexOf('@') + "@".length();
|
||||||
}
|
}
|
||||||
|
|
||||||
int hostEnd = url.substring(hostStart).indexOf("/");
|
int hostEnd = url.substring(hostStart).indexOf("/");
|
||||||
|
@ -197,7 +198,7 @@ public class DisplayUtils {
|
||||||
try {
|
try {
|
||||||
return new OwnCloudAccount(savedAccount, context).getDisplayName()
|
return new OwnCloudAccount(savedAccount, context).getDisplayName()
|
||||||
+ " @ "
|
+ " @ "
|
||||||
+ convertIdn(accountName.substring(accountName.lastIndexOf("@") + 1), false);
|
+ convertIdn(accountName.substring(accountName.lastIndexOf('@') + 1), false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log_OC.w(TAG, "Couldn't get display name for account, using old style");
|
Log_OC.w(TAG, "Couldn't get display name for account, using old style");
|
||||||
return fallbackString;
|
return fallbackString;
|
||||||
|
@ -382,8 +383,9 @@ public class DisplayUtils {
|
||||||
public static void setAvatar(Account account, AvatarGenerationListener listener, float avatarRadius, Resources resources,
|
public static void setAvatar(Account account, AvatarGenerationListener listener, float avatarRadius, Resources resources,
|
||||||
FileDataStorageManager storageManager, Object callContext) {
|
FileDataStorageManager storageManager, Object callContext) {
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (callContext instanceof View)
|
if (callContext instanceof View) {
|
||||||
((View)callContext).setContentDescription(account.name);
|
((View) callContext).setContentDescription(account.name);
|
||||||
|
}
|
||||||
|
|
||||||
// Thumbnail in Cache?
|
// Thumbnail in Cache?
|
||||||
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache("a_" + account.name);
|
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache("a_" + account.name);
|
||||||
|
|
|
@ -313,7 +313,8 @@ public class ErrorMessageAdapter {
|
||||||
code == ResultCode.TIMEOUT ||
|
code == ResultCode.TIMEOUT ||
|
||||||
code == ResultCode.HOST_NOT_AVAILABLE) {
|
code == ResultCode.HOST_NOT_AVAILABLE) {
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,7 +292,7 @@ public class FileStorageUtils {
|
||||||
List<File> files = new ArrayList<File>(Arrays.asList(filesArray));
|
List<File> files = new ArrayList<File>(Arrays.asList(filesArray));
|
||||||
|
|
||||||
Collections.sort(files, new Comparator<File>() {
|
Collections.sort(files, new Comparator<File>() {
|
||||||
@SuppressFBWarnings(value = "Bx", justification = "Would require stepping up API level")
|
@SuppressFBWarnings(value = "Bx")
|
||||||
public int compare(File o1, File o2) {
|
public int compare(File o1, File o2) {
|
||||||
Long obj1 = o1.lastModified();
|
Long obj1 = o1.lastModified();
|
||||||
return multiplier * obj1.compareTo(o2.lastModified());
|
return multiplier * obj1.compareTo(o2.lastModified());
|
||||||
|
@ -310,7 +310,7 @@ public class FileStorageUtils {
|
||||||
final int multiplier = mSortAscending ? 1 : -1;
|
final int multiplier = mSortAscending ? 1 : -1;
|
||||||
|
|
||||||
Collections.sort(files, new Comparator<OCFile>() {
|
Collections.sort(files, new Comparator<OCFile>() {
|
||||||
@SuppressFBWarnings(value = "Bx", justification = "Would require stepping up API level")
|
@SuppressFBWarnings(value = "Bx")
|
||||||
public int compare(OCFile o1, OCFile o2) {
|
public int compare(OCFile o1, OCFile o2) {
|
||||||
if (o1.isFolder() && o2.isFolder()) {
|
if (o1.isFolder() && o2.isFolder()) {
|
||||||
Long obj1 = o1.getFileLength();
|
Long obj1 = o1.getFileLength();
|
||||||
|
@ -339,7 +339,7 @@ public class FileStorageUtils {
|
||||||
List<File> files = new ArrayList<File>(Arrays.asList(filesArray));
|
List<File> files = new ArrayList<File>(Arrays.asList(filesArray));
|
||||||
|
|
||||||
Collections.sort(files, new Comparator<File>() {
|
Collections.sort(files, new Comparator<File>() {
|
||||||
@SuppressFBWarnings(value = "Bx", justification = "Would require stepping up API level")
|
@SuppressFBWarnings(value = "Bx")
|
||||||
public int compare(File o1, File o2) {
|
public int compare(File o1, File o2) {
|
||||||
if (o1.isDirectory() && o2.isDirectory()) {
|
if (o1.isDirectory() && o2.isDirectory()) {
|
||||||
Long obj1 = getFolderSize(o1);
|
Long obj1 = getFolderSize(o1);
|
||||||
|
@ -363,7 +363,7 @@ public class FileStorageUtils {
|
||||||
* Sorts list by Name
|
* Sorts list by Name
|
||||||
* @param files files to sort
|
* @param files files to sort
|
||||||
*/
|
*/
|
||||||
@SuppressFBWarnings(value = "Bx", justification = "Would require stepping up API level")
|
@SuppressFBWarnings(value = "Bx")
|
||||||
public static Vector<OCFile> sortOCFilesByName(Vector<OCFile> files){
|
public static Vector<OCFile> sortOCFilesByName(Vector<OCFile> files){
|
||||||
final int multiplier = mSortAscending ? 1 : -1;
|
final int multiplier = mSortAscending ? 1 : -1;
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ import java.util.Map;
|
||||||
* </li>
|
* </li>
|
||||||
* </ol>
|
* </ol>
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
||||||
public class MimeTypeUtil {
|
public class MimeTypeUtil {
|
||||||
/** Mapping: icon for mime type */
|
/** Mapping: icon for mime type */
|
||||||
private static final Map<String, Integer> MIMETYPE_TO_ICON_MAPPING = new HashMap<>();
|
private static final Map<String, Integer> MIMETYPE_TO_ICON_MAPPING = new HashMap<>();
|
||||||
|
@ -291,7 +292,7 @@ public class MimeTypeUtil {
|
||||||
* @return the file extension
|
* @return the file extension
|
||||||
*/
|
*/
|
||||||
private static String getExtension(String filename) {
|
private static String getExtension(String filename) {
|
||||||
return filename.substring(filename.lastIndexOf(".") + 1).toLowerCase();
|
return filename.substring(filename.lastIndexOf('.') + 1).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -29,17 +29,16 @@ import android.os.FileObserver;
|
||||||
|
|
||||||
public class RecursiveFileObserver extends FileObserver {
|
public class RecursiveFileObserver extends FileObserver {
|
||||||
|
|
||||||
public static int CHANGES_ONLY = CLOSE_WRITE | MOVE_SELF | MOVED_FROM;
|
private final List<SingleFileObserver> mObservers = new ArrayList<>();
|
||||||
|
private boolean watching = false;
|
||||||
List<SingleFileObserver> mObservers;
|
private String mPath;
|
||||||
String mPath;
|
private int mMask;
|
||||||
int mMask;
|
|
||||||
|
|
||||||
public RecursiveFileObserver(String path) {
|
public RecursiveFileObserver(String path) {
|
||||||
this(path, ALL_EVENTS);
|
this(path, ALL_EVENTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecursiveFileObserver(String path, int mask) {
|
RecursiveFileObserver(String path, int mask) {
|
||||||
super(path, mask);
|
super(path, mask);
|
||||||
mPath = path;
|
mPath = path;
|
||||||
mMask = mask;
|
mMask = mask;
|
||||||
|
@ -47,9 +46,11 @@ public class RecursiveFileObserver extends FileObserver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startWatching() {
|
public void startWatching() {
|
||||||
if (mObservers != null) return;
|
if (watching) {
|
||||||
mObservers = new ArrayList<SingleFileObserver>();
|
return;
|
||||||
Stack<String> stack = new Stack<String>();
|
}
|
||||||
|
watching = true;
|
||||||
|
final Stack<String> stack = new Stack<String>();
|
||||||
stack.push(mPath);
|
stack.push(mPath);
|
||||||
|
|
||||||
while (!stack.empty()) {
|
while (!stack.empty()) {
|
||||||
|
@ -57,27 +58,32 @@ public class RecursiveFileObserver extends FileObserver {
|
||||||
mObservers.add(new SingleFileObserver(parent, mMask));
|
mObservers.add(new SingleFileObserver(parent, mMask));
|
||||||
File path = new File(parent);
|
File path = new File(parent);
|
||||||
File[] files = path.listFiles();
|
File[] files = path.listFiles();
|
||||||
if (files == null) continue;
|
if (files == null) {
|
||||||
for (int i = 0; i < files.length; ++i) {
|
continue;
|
||||||
if (files[i].isDirectory() && !files[i].getName().equals(".")
|
}
|
||||||
&& !files[i].getName().equals("..")) {
|
for (final File file : files) {
|
||||||
stack.push(files[i].getPath());
|
if (file.isDirectory() && !file.getName().equals(".")
|
||||||
|
&& !file.getName().equals("..")) {
|
||||||
|
stack.push(file.getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < mObservers.size(); i++)
|
for (int i = 0; i < mObservers.size(); i++) {
|
||||||
mObservers.get(i).startWatching();
|
mObservers.get(i).startWatching();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopWatching() {
|
public void stopWatching() {
|
||||||
if (mObservers == null) return;
|
if (!watching) {
|
||||||
|
return;
|
||||||
for (int i = 0; i < mObservers.size(); ++i)
|
}
|
||||||
mObservers.get(i).stopWatching();
|
|
||||||
|
|
||||||
|
for (int i = 0; i < mObservers.size(); ++i) {
|
||||||
|
mObservers.get(i).stopWatching();
|
||||||
|
}
|
||||||
mObservers.clear();
|
mObservers.clear();
|
||||||
mObservers = null;
|
watching = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -88,7 +94,7 @@ public class RecursiveFileObserver extends FileObserver {
|
||||||
private class SingleFileObserver extends FileObserver {
|
private class SingleFileObserver extends FileObserver {
|
||||||
private String mPath;
|
private String mPath;
|
||||||
|
|
||||||
public SingleFileObserver(String path, int mask) {
|
SingleFileObserver(String path, int mask) {
|
||||||
super(path, mask);
|
super(path, mask);
|
||||||
mPath = path;
|
mPath = path;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,8 +70,9 @@ public class UriUtils {
|
||||||
return cursor.getString(column_index);
|
return cursor.getString(column_index);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (cursor != null)
|
if (cursor != null) {
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -179,8 +180,9 @@ public class UriUtils {
|
||||||
else if ("content".equalsIgnoreCase(uri.getScheme())) {
|
else if ("content".equalsIgnoreCase(uri.getScheme())) {
|
||||||
|
|
||||||
// Return the remote address
|
// Return the remote address
|
||||||
if (UriUtils.isGooglePhotosUri(uri))
|
if (UriUtils.isGooglePhotosUri(uri)) {
|
||||||
return uri.getLastPathSegment();
|
return uri.getLastPathSegment();
|
||||||
|
}
|
||||||
|
|
||||||
return UriUtils.getDataColumn(context, uri, null, null);
|
return UriUtils.getDataColumn(context, uri, null, null);
|
||||||
}
|
}
|
||||||
|
@ -216,7 +218,7 @@ public class UriUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add best possible extension
|
// Add best possible extension
|
||||||
int index = displayName.lastIndexOf(".");
|
int index = displayName.lastIndexOf('.');
|
||||||
if (index == -1 || MimeTypeMap.getSingleton().
|
if (index == -1 || MimeTypeMap.getSingleton().
|
||||||
getMimeTypeFromExtension(displayName.substring(index + 1)) == null) {
|
getMimeTypeFromExtension(displayName.substring(index + 1)) == null) {
|
||||||
String mimeType = context.getContentResolver().getType(uri);
|
String mimeType = context.getContentResolver().getType(uri);
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import com.owncloud.android.R;
|
import com.owncloud.android.R;
|
||||||
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
|
@ -45,6 +46,7 @@ public class ActionEditText extends EditText {
|
||||||
|
|
||||||
private String badgeClickCallback;
|
private String badgeClickCallback;
|
||||||
private Rect btn_rect;
|
private Rect btn_rect;
|
||||||
|
private static final String TAG = ActionEditText.class.getSimpleName();
|
||||||
|
|
||||||
public ActionEditText(Context context, AttributeSet attrs) {
|
public ActionEditText(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
@ -77,10 +79,11 @@ public class ActionEditText extends EditText {
|
||||||
mButtonRect.right = getWidth() - 10;
|
mButtonRect.right = getWidth() - 10;
|
||||||
btn_rect = mButtonRect;
|
btn_rect = mButtonRect;
|
||||||
|
|
||||||
if (s.equals(optionOneString))
|
if (s.equals(optionOneString)) {
|
||||||
p.setColor(optionOneColor);
|
p.setColor(optionOneColor);
|
||||||
else
|
} else {
|
||||||
p.setColor(optionTwoColor);
|
p.setColor(optionTwoColor);
|
||||||
|
}
|
||||||
canvas.drawRect(mButtonRect, p);
|
canvas.drawRect(mButtonRect, p);
|
||||||
p.setColor(Color.GRAY);
|
p.setColor(Color.GRAY);
|
||||||
|
|
||||||
|
@ -95,36 +98,29 @@ public class ActionEditText extends EditText {
|
||||||
int touchX = (int) event.getX();
|
int touchX = (int) event.getX();
|
||||||
int touchY = (int) event.getY();
|
int touchY = (int) event.getY();
|
||||||
boolean r = super.onTouchEvent(event);
|
boolean r = super.onTouchEvent(event);
|
||||||
if (event.getAction() == MotionEvent.ACTION_UP) {
|
if (event.getAction() == MotionEvent.ACTION_UP && btn_rect.contains(touchX, touchY)) {
|
||||||
if (btn_rect.contains(touchX, touchY)) {
|
if (s.equals(optionTwoString)) {
|
||||||
if (s.equals(optionTwoString))
|
s = optionOneString;
|
||||||
s = optionOneString;
|
} else {
|
||||||
else
|
s = optionTwoString;
|
||||||
s = optionTwoString;
|
}
|
||||||
if (badgeClickCallback != null) {
|
if (badgeClickCallback != null) {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
Class[] paramtypes = new Class[2];
|
Class[] paramtypes = new Class[2];
|
||||||
paramtypes[0] = android.view.View.class;
|
paramtypes[0] = android.view.View.class;
|
||||||
paramtypes[1] = String.class;
|
paramtypes[1] = String.class;
|
||||||
Method method;
|
Method method;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
method = getContext().getClass().getMethod(
|
method = getContext().getClass().getMethod(
|
||||||
badgeClickCallback, paramtypes);
|
badgeClickCallback, paramtypes);
|
||||||
method.invoke(getContext(), this, s);
|
method.invoke(getContext(), this, s);
|
||||||
|
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException | IllegalArgumentException | InvocationTargetException | IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
Log_OC.d(TAG, e.getMessage(), e);
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
invalidate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -57,8 +57,9 @@ public class DocumentsStorageProvider extends DocumentsProvider {
|
||||||
|
|
||||||
final RootCursor result = new RootCursor(projection);
|
final RootCursor result = new RootCursor(projection);
|
||||||
|
|
||||||
for (Account account : AccountUtils.getAccounts(getContext()))
|
for (Account account : AccountUtils.getAccounts(getContext())) {
|
||||||
result.addRoot(account, getContext());
|
result.addRoot(account, getContext());
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -70,8 +71,9 @@ public class DocumentsStorageProvider extends DocumentsProvider {
|
||||||
|
|
||||||
final FileCursor result = new FileCursor(projection);
|
final FileCursor result = new FileCursor(projection);
|
||||||
OCFile file = mCurrentStorageManager.getFileById(docId);
|
OCFile file = mCurrentStorageManager.getFileById(docId);
|
||||||
if (file != null)
|
if (file != null) {
|
||||||
result.addFile(file);
|
result.addFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -167,10 +169,11 @@ public class DocumentsStorageProvider extends DocumentsProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCurrentStorageManagerIfNeeded(String rootId) {
|
private void updateCurrentStorageManagerIfNeeded(String rootId) {
|
||||||
for (FileDataStorageManager data : mRootIdToStorageManager.values())
|
for (FileDataStorageManager data : mRootIdToStorageManager.values()) {
|
||||||
if (data.getAccount().name.equals(rootId)) {
|
if (data.getAccount().name.equals(rootId)) {
|
||||||
mCurrentStorageManager = data;
|
mCurrentStorageManager = data;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initiateStorageMap() {
|
private void initiateStorageMap() {
|
||||||
|
|
|
@ -42,7 +42,9 @@ public class FileCursor extends MatrixCursor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFile(OCFile file) {
|
public void addFile(OCFile file) {
|
||||||
if (file == null) return;
|
if (file == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final int iconRes = MimeTypeUtil.getFileTypeIconId(file.getMimetype(), file.getFileName());
|
final int iconRes = MimeTypeUtil.getFileTypeIconId(file.getMimetype(), file.getFileName());
|
||||||
final String mimeType = file.isFolder() ? Document.MIME_TYPE_DIR : file.getMimetype();
|
final String mimeType = file.isFolder() ? Document.MIME_TYPE_DIR : file.getMimetype();
|
||||||
|
|
|
@ -60,8 +60,9 @@ public class AlphanumComparator implements Comparator<OCFile>
|
||||||
while (marker < slength)
|
while (marker < slength)
|
||||||
{
|
{
|
||||||
c = s.charAt(marker);
|
c = s.charAt(marker);
|
||||||
if (!isDigit(c))
|
if (!isDigit(c)) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
chunk.append(c);
|
chunk.append(c);
|
||||||
marker++;
|
marker++;
|
||||||
}
|
}
|
||||||
|
@ -70,8 +71,9 @@ public class AlphanumComparator implements Comparator<OCFile>
|
||||||
while (marker < slength)
|
while (marker < slength)
|
||||||
{
|
{
|
||||||
c = s.charAt(marker);
|
c = s.charAt(marker);
|
||||||
if (isDigit(c))
|
if (isDigit(c)) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
chunk.append(c);
|
chunk.append(c);
|
||||||
marker++;
|
marker++;
|
||||||
}
|
}
|
||||||
|
@ -131,8 +133,9 @@ public class AlphanumComparator implements Comparator<OCFile>
|
||||||
result = thisChunk.compareTo(thatChunk);
|
result = thisChunk.compareTo(thatChunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != 0)
|
if (result != 0) {
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return s1Length - s2Length;
|
return s1Length - s2Length;
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class GridViewWithHeaderAndFooter extends GridView {
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
ListAdapter adapter = getAdapter();
|
ListAdapter adapter = getAdapter();
|
||||||
if (adapter != null && adapter instanceof HeaderViewGridAdapter) {
|
if (adapter instanceof HeaderViewGridAdapter) {
|
||||||
((HeaderViewGridAdapter) adapter).setNumColumns(getNumColumnsCompatible());
|
((HeaderViewGridAdapter) adapter).setNumColumns(getNumColumnsCompatible());
|
||||||
invalidateRowHeight();
|
invalidateRowHeight();
|
||||||
((HeaderViewGridAdapter) adapter).setRowHeight(getRowHeight());
|
((HeaderViewGridAdapter) adapter).setRowHeight(getRowHeight());
|
||||||
|
@ -291,9 +291,7 @@ public class GridViewWithHeaderAndFooter extends GridView {
|
||||||
Field numColumns = getClass().getSuperclass().getDeclaredField("mColumnWidth");
|
Field numColumns = getClass().getSuperclass().getDeclaredField("mColumnWidth");
|
||||||
numColumns.setAccessible(true);
|
numColumns.setAccessible(true);
|
||||||
return numColumns.getInt(this);
|
return numColumns.getInt(this);
|
||||||
} catch (NoSuchFieldException e) {
|
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -407,7 +405,7 @@ public class GridViewWithHeaderAndFooter extends GridView {
|
||||||
super.setNumColumns(numColumns);
|
super.setNumColumns(numColumns);
|
||||||
mNumColumns = numColumns;
|
mNumColumns = numColumns;
|
||||||
ListAdapter adapter = getAdapter();
|
ListAdapter adapter = getAdapter();
|
||||||
if (adapter != null && adapter instanceof HeaderViewGridAdapter) {
|
if (adapter instanceof HeaderViewGridAdapter) {
|
||||||
((HeaderViewGridAdapter) adapter).setNumColumns(numColumns);
|
((HeaderViewGridAdapter) adapter).setNumColumns(numColumns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -545,8 +543,7 @@ public class GridViewWithHeaderAndFooter extends GridView {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getAdapterAndPlaceHolderCount() {
|
private int getAdapterAndPlaceHolderCount() {
|
||||||
final int adapterCount = (int) (Math.ceil(1f * mAdapter.getCount() / mNumColumns) * mNumColumns);
|
return (int) (Math.ceil(1f * mAdapter.getCount() / mNumColumns) * mNumColumns);
|
||||||
return adapterCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -659,8 +656,7 @@ public class GridViewWithHeaderAndFooter extends GridView {
|
||||||
adapterCount = getAdapterAndPlaceHolderCount();
|
adapterCount = getAdapterAndPlaceHolderCount();
|
||||||
if (adjPosition < adapterCount) {
|
if (adjPosition < adapterCount) {
|
||||||
if (adjPosition < mAdapter.getCount()) {
|
if (adjPosition < mAdapter.getCount()) {
|
||||||
View view = mAdapter.getView(adjPosition, convertView, parent);
|
return mAdapter.getView(adjPosition, convertView, parent);
|
||||||
return view;
|
|
||||||
} else {
|
} else {
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = new View(parent.getContext());
|
convertView = new View(parent.getContext());
|
||||||
|
@ -698,17 +694,14 @@ public class GridViewWithHeaderAndFooter extends GridView {
|
||||||
final int numHeadersAndPlaceholders = getHeadersCount() * mNumColumns;
|
final int numHeadersAndPlaceholders = getHeadersCount() * mNumColumns;
|
||||||
final int adapterViewTypeStart = mAdapter == null ? 0 : mAdapter.getViewTypeCount() - 1;
|
final int adapterViewTypeStart = mAdapter == null ? 0 : mAdapter.getViewTypeCount() - 1;
|
||||||
int type = AdapterView.ITEM_VIEW_TYPE_HEADER_OR_FOOTER;
|
int type = AdapterView.ITEM_VIEW_TYPE_HEADER_OR_FOOTER;
|
||||||
if (mCachePlaceHoldView) {
|
if (mCachePlaceHoldView
|
||||||
|
&& position < numHeadersAndPlaceholders) {
|
||||||
// Header
|
// Header
|
||||||
if (position < numHeadersAndPlaceholders) {
|
if (position == 0 && mCacheFirstHeaderView) {
|
||||||
if (position == 0) {
|
type = adapterViewTypeStart + mHeaderViewInfos.size() + mFooterViewInfos.size() + 1 + 1;
|
||||||
if (mCacheFirstHeaderView) {
|
}
|
||||||
type = adapterViewTypeStart + mHeaderViewInfos.size() + mFooterViewInfos.size() + 1 + 1;
|
if (position % mNumColumns != 0) {
|
||||||
}
|
type = adapterViewTypeStart + (position / mNumColumns + 1);
|
||||||
}
|
|
||||||
if (position % mNumColumns != 0) {
|
|
||||||
type = adapterViewTypeStart + (position / mNumColumns + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -386,7 +386,7 @@ public class TouchImageViewCustom extends ImageViewCustom {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scaleType != mScaleType) {
|
if (!scaleType.equals(mScaleType)) {
|
||||||
setScaleType(scaleType);
|
setScaleType(scaleType);
|
||||||
}
|
}
|
||||||
resetZoom();
|
resetZoom();
|
||||||
|
@ -489,10 +489,12 @@ public class TouchImageViewCustom extends ImageViewCustom {
|
||||||
maxTrans = 0;
|
maxTrans = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trans < minTrans)
|
if (trans < minTrans) {
|
||||||
return -trans + minTrans;
|
return -trans + minTrans;
|
||||||
if (trans > maxTrans)
|
}
|
||||||
|
if (trans > maxTrans) {
|
||||||
return -trans + maxTrans;
|
return -trans + maxTrans;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -832,8 +834,9 @@ public class TouchImageViewCustom extends ImageViewCustom {
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case MotionEvent.ACTION_DOWN:
|
case MotionEvent.ACTION_DOWN:
|
||||||
last.set(curr);
|
last.set(curr);
|
||||||
if (fling != null)
|
if (fling != null) {
|
||||||
fling.cancelFling();
|
fling.cancelFling();
|
||||||
|
}
|
||||||
setState(State.DRAG);
|
setState(State.DRAG);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue