import android.text.Editable;\r
import android.text.InputType;\r
import android.text.TextWatcher;\r
+ import android.util.Log;\r
import android.view.KeyEvent;\r
import android.view.MotionEvent;\r
import android.view.View;\r
import com.owncloud.android.lib.network.OwnCloudClientFactory;\r
import com.owncloud.android.lib.network.OwnCloudClient;\r
import com.owncloud.android.operations.OAuth2GetAccessToken;\r
+
import com.owncloud.android.lib.operations.common.OnRemoteOperationListener;\r
-import com.owncloud.android.operations.OwnCloudServerCheckOperation;\r
+import com.owncloud.android.lib.operations.remote.OwnCloudServerCheckOperation;\r
import com.owncloud.android.lib.operations.common.RemoteOperation;\r
import com.owncloud.android.lib.operations.common.RemoteOperationResult;\r
import com.owncloud.android.lib.operations.common.RemoteOperationResult.ResultCode;\r
import com.owncloud.android.lib.operations.remote.ExistenceCheckRemoteOperation;\r
import com.owncloud.android.lib.operations.remote.GetUserNameRemoteOperation;\r
+
import com.owncloud.android.ui.dialog.SamlWebViewDialog;\r
import com.owncloud.android.ui.dialog.SslValidatorDialog;\r
import com.owncloud.android.ui.dialog.SslValidatorDialog.OnSslValidatorListener;\r
private static final String KEY_AUTH_STATUS_TEXT = "AUTH_STATUS_TEXT";\r
private static final String KEY_AUTH_STATUS_ICON = "AUTH_STATUS_ICON";\r
private static final String KEY_REFRESH_BUTTON_ENABLED = "KEY_REFRESH_BUTTON_ENABLED";\r
+ private static final String KEY_IS_SHARED_SUPPORTED = "KEY_IS_SHARE_SUPPORTED";\r
\r
private static final String AUTH_ON = "on";\r
private static final String AUTH_OFF = "off";\r
\r
private String mHostBaseUrl;\r
private OwnCloudVersion mDiscoveredVersion;\r
+ private boolean mIsSharedSupported;\r
\r
private String mAuthMessageText;\r
private int mAuthMessageVisibility, mServerStatusText, mServerStatusIcon;\r
mServerIsChecked = false;\r
mIsSslConn = false;\r
mAuthStatusText = mAuthStatusIcon = 0;\r
+ mIsSharedSupported = false;\r
\r
/// retrieve extras from intent\r
mAccount = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT);\r
mHostUrlInput.setText(mHostBaseUrl);\r
String userName = mAccount.name.substring(0, mAccount.name.lastIndexOf('@'));\r
mUsernameInput.setText(userName);\r
+ mIsSharedSupported = Boolean.getBoolean(mAccountMgr.getUserData(mAccount, OwnCloudAccount.Constants.KEY_SUPPORTS_SHARE_API));\r
+ \r
}\r
initAuthorizationMethod(); // checks intent and setup.xml to determine mCurrentAuthorizationMethod\r
mJustCreated = true;\r
\r
/// server data\r
String ocVersion = savedInstanceState.getString(KEY_OC_VERSION);\r
+ mIsSharedSupported = savedInstanceState.getBoolean(KEY_IS_SHARED_SUPPORTED, false);\r
if (ocVersion != null) {\r
mDiscoveredVersion = new OwnCloudVersion(ocVersion);\r
}\r
outState.putString(KEY_OC_VERSION, mDiscoveredVersion.toString());\r
}\r
outState.putString(KEY_HOST_URL_TEXT, mHostBaseUrl);\r
+ outState.putBoolean(KEY_IS_SHARED_SUPPORTED, mIsSharedSupported);\r
\r
/// account data, if updating\r
if (mAccount != null) {\r
\r
mServerIsValid = false;\r
mServerIsChecked = false;\r
+ mIsSharedSupported = false;\r
mOkButton.setEnabled(false);\r
mDiscoveredVersion = null;\r
hideRefreshButton();\r
\r
if (success)\r
finish();\r
+ } else {\r
+ updateAuthStatusIconAndText(result);\r
+ showAuthStatus();\r
+ Log_OC.e(TAG, "Access to user name failed: " + result.getLogMessage());\r
}\r
\r
}\r
\r
/// allow or not the user try to access the server\r
mOkButton.setEnabled(mServerIsValid);\r
+ \r
+ /// retrieve if is supported the Share API\r
+ mIsSharedSupported = operation.isSharedSupported();\r
\r
} // else nothing ; only the last check operation is considered; \r
// multiple can be triggered if the user amends a URL before a previous check can be triggered\r
/// add user data to the new account; TODO probably can be done in the last parameter addAccountExplicitly, or in KEY_USERDATA\r
mAccountMgr.setUserData(mAccount, OwnCloudAccount.Constants.KEY_OC_VERSION, mDiscoveredVersion.toString());\r
mAccountMgr.setUserData(mAccount, OwnCloudAccount.Constants.KEY_OC_BASE_URL, mHostBaseUrl);\r
+ mAccountMgr.setUserData(mAccount, OwnCloudAccount.Constants.KEY_SUPPORTS_SHARE_API, Boolean.toString(mIsSharedSupported));\r
if (isSaml) {\r
mAccountMgr.setUserData(mAccount, OwnCloudAccount.Constants.KEY_SUPPORTS_SAML_WEB_SSO, "TRUE"); \r
} else if (isOAuth) {\r
}\r
\r
\r
- public void onSamlDialogSuccess(String sessionCookie){\r
+ public void onSamlDialogSuccess(String sessionCookie) {\r
mAuthToken = sessionCookie;\r
\r
if (sessionCookie != null && sessionCookie.length() > 0) {\r
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(remotePath);
result = operation.execute(client);
if (result.isSuccess()){
- OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile)result.getData().get(0));
+ OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
// check if remote and local folder are different
mRemoteFolderChanged = !(remoteFolder.getEtag().equalsIgnoreCase(mLocalFolder.getEtag()));
Log_OC.d(TAG, "Synchronizing " + mAccount.name + remotePath);
if (result.isSuccess()) {
- ArrayList<RemoteFile> remotes = new ArrayList<RemoteFile>();
- for(Object obj: result.getData()) {
- remotes.add((RemoteFile) obj);
- }
- synchronizeData(remotes, client);
+ synchronizeData(result.getData(), client);
if (mConflictsFound > 0 || mFailsInFavouritesFound > 0) {
result = new RemoteOperationResult(ResultCode.SYNC_CONFLICT); // should be different result, but will do the job
}
* retrieved.
* @return 'True' when any change was made in the local data, 'false' otherwise.
*/
- private void synchronizeData(ArrayList<RemoteFile> folderAndFiles, OwnCloudClient client) {
+ private void synchronizeData(ArrayList<Object> folderAndFiles, OwnCloudClient client) {
// get 'fresh data' from the database
mLocalFolder = mStorageManager.getFileByPath(mLocalFolder.getRemotePath());
// parse data from remote folder
- OCFile remoteFolder = fillOCFile(folderAndFiles.get(0));
+ OCFile remoteFolder = fillOCFile((RemoteFile)folderAndFiles.get(0));
remoteFolder.setParentId(mLocalFolder.getParentId());
remoteFolder.setFileId(mLocalFolder.getFileId());
OCFile remoteFile = null, localFile = null;
for (int i=1; i<folderAndFiles.size(); i++) {
/// new OCFile instance with the data from the server
- remoteFile = fillOCFile(folderAndFiles.get(i));
+ remoteFile = fillOCFile((RemoteFile)folderAndFiles.get(i));
remoteFile.setParentId(mLocalFolder.getFileId());
/// retrieve local data for the read file