along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<manifest package="com.owncloud.android"
- android:versionCode="104000"
- android:versionName="1.4.0" xmlns:android="http://schemas.android.com/apk/res/android">
+ android:versionCode="104001"
+ android:versionName="1.4.1" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
android:disableDependentsState="true"
android:title="@string/instant_upload_on_wifi"
android:key="instant_upload_on_wifi"/>
- <CheckBoxPreference android:key="log_to_file"
+ <!-- DISABLED FOR RELEASE UNTIL FIXED
+ CheckBoxPreference android:key="log_to_file"
android:title="@string/prefs_log_title"
android:summary="@string/prefs_log_summary"/>
<Preference android:key="log_history"
android:title="@string/prefs_log_title_history"
- android:summary="@string/prefs_log_summary_history"/>
+ android:summary="@string/prefs_log_summary_history"/ -->
<Preference android:id="@+id/about_app"
android:title="@string/about_title"
android:key="about_app" />
+++ /dev/null
-/* ownCloud Android client application\r
- * Copyright (C) 2012 Bartek Przybylski\r
- * Copyright (C) 2012-2013 ownCloud Inc.\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License version 2,\r
- * as published by the Free Software Foundation.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- *\r
- */\r
-\r
-package com.owncloud.android;\r
-\r
-import com.owncloud.android.authentication.AccountAuthenticator;\r
-import com.owncloud.android.utils.OwnCloudVersion;\r
-\r
-import android.accounts.Account;\r
-import android.accounts.AccountManager;\r
-import android.content.Context;\r
-import android.content.SharedPreferences;\r
-import android.preference.PreferenceManager;\r
-\r
-public class AccountUtils {\r
- public static final String WEBDAV_PATH_1_2 = "/webdav/owncloud.php";\r
- public static final String WEBDAV_PATH_2_0 = "/files/webdav.php";\r
- public static final String WEBDAV_PATH_4_0 = "/remote.php/webdav";\r
- private static final String ODAV_PATH = "/remote.php/odav";\r
- public static final String CARDDAV_PATH_2_0 = "/apps/contacts/carddav.php";\r
- public static final String CARDDAV_PATH_4_0 = "/remote/carddav.php";\r
- public static final String STATUS_PATH = "/status.php";\r
-\r
- /**\r
- * Can be used to get the currently selected ownCloud {@link Account} in the\r
- * application preferences.\r
- * \r
- * @param context The current application {@link Context}\r
- * @return The ownCloud {@link Account} currently saved in preferences, or the first \r
- * {@link Account} available, if valid (still registered in the system as ownCloud \r
- * account). If none is available and valid, returns null.\r
- */\r
- public static Account getCurrentOwnCloudAccount(Context context) {\r
- Account[] ocAccounts = AccountManager.get(context).getAccountsByType(\r
- AccountAuthenticator.ACCOUNT_TYPE);\r
- Account defaultAccount = null;\r
-\r
- SharedPreferences appPreferences = PreferenceManager\r
- .getDefaultSharedPreferences(context);\r
- String accountName = appPreferences\r
- .getString("select_oc_account", null);\r
-\r
- // account validation: the saved account MUST be in the list of ownCloud Accounts known by the AccountManager\r
- if (accountName != null) {\r
- for (Account account : ocAccounts) {\r
- if (account.name.equals(accountName)) {\r
- defaultAccount = account;\r
- break;\r
- }\r
- }\r
- }\r
- \r
- if (defaultAccount == null && ocAccounts.length != 0) {\r
- // take first account as fallback\r
- defaultAccount = ocAccounts[0];\r
- }\r
-\r
- return defaultAccount;\r
- }\r
-\r
- \r
-\r
- /**\r
- * Checks, whether or not there are any ownCloud accounts setup.\r
- * \r
- * @return true, if there is at least one account.\r
- */\r
- public static boolean accountsAreSetup(Context context) {\r
- AccountManager accMan = AccountManager.get(context);\r
- Account[] accounts = accMan\r
- .getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE);\r
- return accounts.length > 0;\r
- }\r
- \r
- \r
- public static boolean setCurrentOwnCloudAccount(Context context, String accountName) {\r
- boolean result = false;\r
- if (accountName != null) {\r
- Account[] ocAccounts = AccountManager.get(context).getAccountsByType(\r
- AccountAuthenticator.ACCOUNT_TYPE);\r
- boolean found = false;\r
- for (Account account : ocAccounts) {\r
- found = (account.name.equals(accountName));\r
- if (found) {\r
- SharedPreferences.Editor appPrefs = PreferenceManager\r
- .getDefaultSharedPreferences(context).edit();\r
- appPrefs.putString("select_oc_account", accountName);\r
- \r
- appPrefs.commit();\r
- result = true;\r
- break;\r
- }\r
- }\r
- }\r
- return result;\r
- }\r
-\r
- /**\r
- * \r
- * @param version version of owncloud\r
- * @return webdav path for given OC version, null if OC version unknown\r
- */\r
- public static String getWebdavPath(OwnCloudVersion version, boolean supportsOAuth) {\r
- if (version != null) {\r
- if (supportsOAuth) {\r
- return ODAV_PATH;\r
- }\r
- if (version.compareTo(OwnCloudVersion.owncloud_v4) >= 0)\r
- return WEBDAV_PATH_4_0;\r
- if (version.compareTo(OwnCloudVersion.owncloud_v3) >= 0\r
- || version.compareTo(OwnCloudVersion.owncloud_v2) >= 0)\r
- return WEBDAV_PATH_2_0;\r
- if (version.compareTo(OwnCloudVersion.owncloud_v1) >= 0)\r
- return WEBDAV_PATH_1_2;\r
- }\r
- return null;\r
- }\r
- \r
- /**\r
- * Constructs full url to host and webdav resource basing on host version\r
- * @param context\r
- * @param account\r
- * @return url or null on failure\r
- */\r
- public static String constructFullURLForAccount(Context context, Account account) {\r
- try {\r
- AccountManager ama = AccountManager.get(context);\r
- String baseurl = ama.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL);\r
- String strver = ama.getUserData(account, AccountAuthenticator.KEY_OC_VERSION);\r
- boolean supportsOAuth = (ama.getUserData(account, AccountAuthenticator.KEY_SUPPORTS_OAUTH2) != null);\r
- OwnCloudVersion ver = new OwnCloudVersion(strver);\r
- String webdavpath = getWebdavPath(ver, supportsOAuth);\r
-\r
- if (webdavpath == null) return null;\r
- return baseurl + webdavpath;\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- return null;\r
- }\r
- }\r
-\r
-}\r
--- /dev/null
+/* ownCloud Android client application\r
+ * Copyright (C) 2012 Bartek Przybylski\r
+ * Copyright (C) 2012-2013 ownCloud Inc.\r
+ *\r
+ * This program is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License version 2,\r
+ * as published by the Free Software Foundation.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+ *\r
+ */\r
+\r
+package com.owncloud.android.authentication;\r
+\r
+import com.owncloud.android.utils.OwnCloudVersion;\r
+\r
+import android.accounts.Account;\r
+import android.accounts.AccountManager;\r
+import android.accounts.AccountsException;\r
+import android.content.Context;\r
+import android.content.SharedPreferences;\r
+import android.preference.PreferenceManager;\r
+\r
+public class AccountUtils {\r
+ public static final String WEBDAV_PATH_1_2 = "/webdav/owncloud.php";\r
+ public static final String WEBDAV_PATH_2_0 = "/files/webdav.php";\r
+ public static final String WEBDAV_PATH_4_0 = "/remote.php/webdav";\r
+ private static final String ODAV_PATH = "/remote.php/odav";\r
+ public static final String CARDDAV_PATH_2_0 = "/apps/contacts/carddav.php";\r
+ public static final String CARDDAV_PATH_4_0 = "/remote/carddav.php";\r
+ public static final String STATUS_PATH = "/status.php";\r
+\r
+ /**\r
+ * Can be used to get the currently selected ownCloud {@link Account} in the\r
+ * application preferences.\r
+ * \r
+ * @param context The current application {@link Context}\r
+ * @return The ownCloud {@link Account} currently saved in preferences, or the first \r
+ * {@link Account} available, if valid (still registered in the system as ownCloud \r
+ * account). If none is available and valid, returns null.\r
+ */\r
+ public static Account getCurrentOwnCloudAccount(Context context) {\r
+ Account[] ocAccounts = AccountManager.get(context).getAccountsByType(\r
+ AccountAuthenticator.ACCOUNT_TYPE);\r
+ Account defaultAccount = null;\r
+\r
+ SharedPreferences appPreferences = PreferenceManager\r
+ .getDefaultSharedPreferences(context);\r
+ String accountName = appPreferences\r
+ .getString("select_oc_account", null);\r
+\r
+ // account validation: the saved account MUST be in the list of ownCloud Accounts known by the AccountManager\r
+ if (accountName != null) {\r
+ for (Account account : ocAccounts) {\r
+ if (account.name.equals(accountName)) {\r
+ defaultAccount = account;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ \r
+ if (defaultAccount == null && ocAccounts.length != 0) {\r
+ // take first account as fallback\r
+ defaultAccount = ocAccounts[0];\r
+ }\r
+\r
+ return defaultAccount;\r
+ }\r
+\r
+ \r
+\r
+ /**\r
+ * Checks, whether or not there are any ownCloud accounts setup.\r
+ * \r
+ * @return true, if there is at least one account.\r
+ */\r
+ public static boolean accountsAreSetup(Context context) {\r
+ AccountManager accMan = AccountManager.get(context);\r
+ Account[] accounts = accMan\r
+ .getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE);\r
+ return accounts.length > 0;\r
+ }\r
+ \r
+ \r
+ public static boolean setCurrentOwnCloudAccount(Context context, String accountName) {\r
+ boolean result = false;\r
+ if (accountName != null) {\r
+ Account[] ocAccounts = AccountManager.get(context).getAccountsByType(\r
+ AccountAuthenticator.ACCOUNT_TYPE);\r
+ boolean found = false;\r
+ for (Account account : ocAccounts) {\r
+ found = (account.name.equals(accountName));\r
+ if (found) {\r
+ SharedPreferences.Editor appPrefs = PreferenceManager\r
+ .getDefaultSharedPreferences(context).edit();\r
+ appPrefs.putString("select_oc_account", accountName);\r
+ \r
+ appPrefs.commit();\r
+ result = true;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+\r
+ /**\r
+ * \r
+ * @param version version of owncloud\r
+ * @return webdav path for given OC version, null if OC version unknown\r
+ */\r
+ public static String getWebdavPath(OwnCloudVersion version, boolean supportsOAuth) {\r
+ if (version != null) {\r
+ if (supportsOAuth) {\r
+ return ODAV_PATH;\r
+ }\r
+ if (version.compareTo(OwnCloudVersion.owncloud_v4) >= 0)\r
+ return WEBDAV_PATH_4_0;\r
+ if (version.compareTo(OwnCloudVersion.owncloud_v3) >= 0\r
+ || version.compareTo(OwnCloudVersion.owncloud_v2) >= 0)\r
+ return WEBDAV_PATH_2_0;\r
+ if (version.compareTo(OwnCloudVersion.owncloud_v1) >= 0)\r
+ return WEBDAV_PATH_1_2;\r
+ }\r
+ return null;\r
+ }\r
+ \r
+ /**\r
+ * Constructs full url to host and webdav resource basing on host version\r
+ * @param context\r
+ * @param account\r
+ * @return url or null on failure\r
+ * @throws AccountNotFoundException When 'account' is unknown for the AccountManager\r
+ */\r
+ public static String constructFullURLForAccount(Context context, Account account) throws AccountNotFoundException {\r
+ AccountManager ama = AccountManager.get(context);\r
+ String baseurl = ama.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL);\r
+ String strver = ama.getUserData(account, AccountAuthenticator.KEY_OC_VERSION);\r
+ boolean supportsOAuth = (ama.getUserData(account, AccountAuthenticator.KEY_SUPPORTS_OAUTH2) != null);\r
+ OwnCloudVersion ver = new OwnCloudVersion(strver);\r
+ String webdavpath = getWebdavPath(ver, supportsOAuth);\r
+\r
+ if (baseurl == null || webdavpath == null) \r
+ throw new AccountNotFoundException(account, "Account not found", null);\r
+ \r
+ return baseurl + webdavpath;\r
+ }\r
+ \r
+ \r
+ public static class AccountNotFoundException extends AccountsException {\r
+ \r
+ /** Generated - should be refreshed every time the class changes!! */\r
+ private static final long serialVersionUID = -9013287181793186830L;\r
+ \r
+ private Account mFailedAccount; \r
+ \r
+ public AccountNotFoundException(Account failedAccount, String message, Throwable cause) {\r
+ super(message, cause);\r
+ mFailedAccount = failedAccount;\r
+ }\r
+ \r
+ public Account getFailedAccount() {\r
+ return mFailedAccount;\r
+ }\r
+ }\r
+\r
+}\r
\r
package com.owncloud.android.authentication;\r
\r
-import com.owncloud.android.AccountUtils;\r
import com.owncloud.android.Log_OC;\r
import com.owncloud.android.ui.dialog.SslValidatorDialog;\r
import com.owncloud.android.ui.dialog.SslValidatorDialog.OnSslValidatorListener;\r
* Called from SslValidatorDialog when a new server certificate was correctly saved.\r
*/\r
public void onSavedCertificate() {\r
- mOperationThread = mOcServerChkOperation.retry(this, mHandler); \r
+ checkOcServer();\r
}\r
\r
/**\r
import java.io.File;
-import com.owncloud.android.AccountUtils;
import com.owncloud.android.authentication.AccountAuthenticator;
+import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.db.DbHandler;
import com.owncloud.android.files.services.FileUploader;
import org.apache.http.conn.ssl.BrowserCompatHostnameVerifier;
import org.apache.http.conn.ssl.X509HostnameVerifier;
-import com.owncloud.android.AccountUtils;
import com.owncloud.android.authentication.AccountAuthenticator;
+import com.owncloud.android.authentication.AccountUtils;
+import com.owncloud.android.authentication.AccountUtils.AccountNotFoundException;
import com.owncloud.android.Log_OC;
import eu.alefzero.webdav.WebdavClient;
* @throws AuthenticatorException If the authenticator failed to get the authorization token for the account.
* @throws OperationCanceledException If the authenticator operation was cancelled while getting the authorization token for the account.
* @throws IOException If there was some I/O error while getting the authorization token for the account.
+ * @throws AccountNotFoundException If 'account' is unknown for the AccountManager
*/
- public static WebdavClient createOwnCloudClient (Account account, Context appContext) throws OperationCanceledException, AuthenticatorException, IOException {
+ public static WebdavClient createOwnCloudClient (Account account, Context appContext) throws OperationCanceledException, AuthenticatorException, IOException, AccountNotFoundException {
//Log_OC.d(TAG, "Creating WebdavClient associated to " + account.name);
Uri uri = Uri.parse(AccountUtils.constructFullURLForAccount(appContext, account));
}
- public static WebdavClient createOwnCloudClient (Account account, Context appContext, Activity currentActivity) throws OperationCanceledException, AuthenticatorException, IOException {
+ public static WebdavClient createOwnCloudClient (Account account, Context appContext, Activity currentActivity) throws OperationCanceledException, AuthenticatorException, IOException, AccountNotFoundException {
Uri uri = Uri.parse(AccountUtils.constructFullURLForAccount(appContext, account));
WebdavClient client = createOwnCloudClient(uri, appContext);
AccountManager am = AccountManager.get(appContext);
import org.json.JSONException;
import org.json.JSONObject;
-import com.owncloud.android.AccountUtils;
import com.owncloud.android.Log_OC;
+import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.utils.OwnCloudVersion;
import eu.alefzero.webdav.WebdavClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.jackrabbit.webdav.DavException;
+import android.accounts.Account;
+import android.accounts.AccountsException;
+
import com.owncloud.android.Log_OC;
+import com.owncloud.android.authentication.AccountUtils.AccountNotFoundException;
import com.owncloud.android.network.CertificateCombinedException;
/**
public class RemoteOperationResult implements Serializable {
/** Generated - should be refreshed every time the class changes!! */
- private static final long serialVersionUID = -7805531062432602444L;
+ private static final long serialVersionUID = 6106167714625712390L;
+
private static final String TAG = "RemoteOperationResult";
LOCAL_STORAGE_NOT_MOVED,
LOCAL_STORAGE_NOT_COPIED,
OAUTH2_ERROR_ACCESS_DENIED,
- QUOTA_EXCEEDED
+ QUOTA_EXCEEDED,
+ ACCOUNT_NOT_FOUND,
+ ACCOUNT_EXCEPTION
}
private boolean mSuccess = false;
} else if (e instanceof UnknownHostException) {
mCode = ResultCode.HOST_NOT_AVAILABLE;
+ } else if (e instanceof AccountNotFoundException) {
+ mCode = ResultCode.ACCOUNT_NOT_FOUND;
+
+ } else if (e instanceof AccountsException) {
+ mCode = ResultCode.ACCOUNT_EXCEPTION;
+
} else if (e instanceof SSLException || e instanceof RuntimeException) {
CertificateCombinedException se = getCertificateCombinedException(e);
if (se != null) {
} else if (mException instanceof IOException) {
return "Unrecovered transport exception";
+ } else if (mException instanceof AccountNotFoundException) {
+ Account failedAccount = ((AccountNotFoundException)mException).getFailedAccount();
+ return mException.getMessage() + " (" + (failedAccount != null ? failedAccount.name : "NULL") + ")";
+
+ } else if (mException instanceof AccountsException) {
+ return "Exception while using account";
+
} else {
return "Unexpected exception";
}
import android.accounts.AccountManager;
import android.content.Context;
-import com.owncloud.android.AccountUtils;
import com.owncloud.android.authentication.AccountAuthenticator;
+import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.Log_OC;
import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.utils.OwnCloudVersion;
import org.apache.http.conn.ConnectionKeepAliveStrategy;\r
import org.apache.http.protocol.HttpContext;\r
\r
-import com.owncloud.android.AccountUtils;\r
+import com.owncloud.android.authentication.AccountUtils;\r
+import com.owncloud.android.authentication.AccountUtils.AccountNotFoundException;\r
import com.owncloud.android.datamodel.DataStorageManager;\r
import com.owncloud.android.network.OwnCloudClientUtils;\r
\r
return null;\r
}\r
\r
- protected void initClientForCurrentAccount() throws OperationCanceledException, AuthenticatorException, IOException {\r
- if (AccountUtils.constructFullURLForAccount(getContext(), account) == null) {\r
- throw new UnknownHostException();\r
- }\r
+ protected void initClientForCurrentAccount() throws OperationCanceledException, AuthenticatorException, IOException, AccountNotFoundException {\r
+ AccountUtils.constructFullURLForAccount(getContext(), account);\r
mClient = OwnCloudClientUtils.createOwnCloudClient(account, getContext());\r
}\r
\r
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.ByteArrayEntity;
-import com.owncloud.android.AccountUtils;
import com.owncloud.android.authentication.AccountAuthenticator;
+import com.owncloud.android.authentication.AccountUtils;
import android.accounts.Account;
import android.accounts.AccountManager;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
-import com.owncloud.android.AccountUtils;
import com.owncloud.android.authentication.AccountAuthenticator;
+import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.Log_OC;
import com.owncloud.android.R;
import android.webkit.MimeTypeMap;
import com.actionbarsherlock.app.SherlockFragmentActivity;
-import com.owncloud.android.AccountUtils;
import com.owncloud.android.Log_OC;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountAuthenticator;
+import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.OCFile;
import eu.alefzero.webdav.WebdavUtils;
@Override
public void onFileStateChanged() {
refeshListOfFilesFragment();
+ updateNavigationElementsInActionBar(getSecondFragment().getFile());
}
import android.widget.TextView;
import android.widget.Toast;
-import com.owncloud.android.AccountUtils;
import com.owncloud.android.Log_OC;
import com.owncloud.android.R;
+import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.db.DbHandler;
import com.owncloud.android.files.InstantUploadBroadcastReceiver;
import com.owncloud.android.files.services.FileUploader;
}
}
+ /* DISABLED FOR RELEASE UNTIL FIXED
pLogging = (CheckBoxPreference) findPreference("log_to_file");
if (pLogging != null) {
pLogging.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
}
});
}
+ */
+
}
}
+++ /dev/null
-/* ownCloud Android client application
- * Copyright (C) 2011 Bartek Przybylski
- * Copyright (C) 2012-2013 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.ui.adapter;
-
-import java.io.File;
-
-import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
-
-import com.owncloud.android.AccountUtils;
-import com.owncloud.android.R;
-import eu.alefzero.webdav.WebdavUtils;
-import android.accounts.Account;
-import android.accounts.AccountManager;
-import android.content.Context;
-import android.content.Intent;
-import android.database.Cursor;
-import android.database.DataSetObserver;
-import android.net.Uri;
-import android.text.TextUtils;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.ListAdapter;
-import android.widget.TextView;
-
-public class FileListActionListAdapter implements ListAdapter {
-
- private Context mContext;
- private Account mAccount;
- private String mFilename, mFileType, mFilePath, mFileStoragePath;
-
- private final int ITEM_DOWNLOAD = 0;
-
- // private final int ITEM_SHARE = 1;
-
- public FileListActionListAdapter(Cursor c, Context co, Account account) {
- mContext = co;
- mFilename = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_NAME));
- mFileType = c.getString(c
- .getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE));
- mFilePath = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_PATH));
- mFileStoragePath = c.getString(c
- .getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH));
- // mItemId = c.getString(c.getColumnIndex(ProviderTableMeta._ID));
- mAccount = account;
- }
-
- public boolean areAllItemsEnabled() {
- return true;
- }
-
- public boolean isEnabled(int position) {
- return true;
- }
-
- public int getCount() {
- return 1;
- }
-
- public Object getItem(int position) {
- if (position == 0) {
- Intent intent = new Intent(Intent.ACTION_VIEW);
- if (TextUtils.isEmpty(mFileStoragePath)) {
- intent.putExtra("toDownload", true);
- AccountManager accm = (AccountManager) mContext
- .getSystemService(Context.ACCOUNT_SERVICE);
- String ocurl = accm.getUserData(mAccount,
- AccountUtils.constructFullURLForAccount(mContext, mAccount));
- ocurl += WebdavUtils.encodePath(mFilePath + mFilename);
- intent.setData(Uri.parse(ocurl));
- } else {
- intent.putExtra("toDownload", false);
- intent.setDataAndType(Uri.fromFile(new File(mFileStoragePath)),
- mFileType);
- }
- return intent;
- }
- return null;
- }
-
- public long getItemId(int position) {
- return 0;
- }
-
- public int getItemViewType(int position) {
- return 0;
- }
-
- public View getView(int position, View convertView, ViewGroup parent) {
- View v = convertView;
- if (v == null) {
- LayoutInflater vi = (LayoutInflater) mContext
- .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- v = vi.inflate(R.layout.file_display_action_list_element, null);
- }
-
- TextView tv;
- ImageView iv;
- switch (position) {
- case ITEM_DOWNLOAD:
- tv = (TextView) v.findViewById(R.id.textView1);
- if (mFileStoragePath == null) {
- tv.setText("Download");
- } else {
- setActionName(tv);
- }
- iv = (ImageView) v.findViewById(R.id.imageView1);
- iv.setImageResource(R.drawable.download);
- break;
- }
-
- return v;
- }
-
- public int getViewTypeCount() {
- return 2;
- }
-
- public boolean hasStableIds() {
- return false;
- }
-
- public boolean isEmpty() {
- return false;
- }
-
- public void registerDataSetObserver(DataSetObserver observer) { }
-
- public void unregisterDataSetObserver(DataSetObserver observer) { }
-
- private void setActionName(TextView tv) {
- if (mFileType.matches("image/.*")) {
- tv.setText("View");
- } else if (mFileType.matches("audio/.*")
- || mFileType.matches("video/.*")) {
- tv.setText("Play");
- } else {
- tv.setText("Open");
- }
- }
-
-}
import android.widget.ListView;
import android.widget.TextView;
-import com.owncloud.android.AccountUtils;
import com.owncloud.android.DisplayUtils;
import com.owncloud.android.R;
+import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.DataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
*/\r
package com.owncloud.android.ui.adapter;\r
\r
-import com.owncloud.android.AccountUtils;\r
+import com.owncloud.android.authentication.AccountUtils;\r
import com.owncloud.android.ui.activity.FileDisplayActivity;\r
import com.owncloud.android.ui.activity.Preferences;\r
\r
package com.owncloud.android.ui.dialog;
import java.io.IOException;
+import java.security.GeneralSecurityException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
else
Log_OC.d(TAG, "Nobody there to notify the certificate was saved");
- } catch (Exception e) {
+ } catch (GeneralSecurityException e) {
+ dismiss();
+ if (mListener != null)
+ mListener.onFailedSavingCertificate();
+ 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();
import java.util.ArrayList;
import java.util.List;
-import com.owncloud.android.AccountUtils;
import com.owncloud.android.Log_OC;
import com.owncloud.android.R;
+import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.DataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.FileHandler;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.Window;
+import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.DataStorageManager;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.fragment.FileFragment;
-import com.owncloud.android.AccountUtils;
import com.owncloud.android.Log_OC;
import com.owncloud.android.R;
import android.widget.MediaController;
import android.widget.VideoView;
-import com.owncloud.android.AccountUtils;
import com.owncloud.android.Log_OC;
import com.owncloud.android.R;
+import com.owncloud.android.authentication.AccountUtils;
+import com.owncloud.android.authentication.AccountUtils.AccountNotFoundException;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.media.MediaService;
mVideoPlayer.setVideoPath(mFile.getStoragePath());
} else if (mAccount != null) {
- // not working now
- String url = AccountUtils.constructFullURLForAccount(this, mAccount) + mFile.getRemotePath();
- mVideoPlayer.setVideoURI(Uri.parse(url));
+ // not working yet
+ String url;
+ try {
+ url = AccountUtils.constructFullURLForAccount(this, mAccount) + mFile.getRemotePath();
+ mVideoPlayer.setVideoURI(Uri.parse(url));
+ } catch (AccountNotFoundException e) {
+ onError(null, MediaService.OC_MEDIA_ERROR, R.string.media_err_no_account);
+ }
} else {
onError(null, MediaService.OC_MEDIA_ERROR, R.string.media_err_no_account);
import android.test.AndroidTestCase;
-import com.owncloud.android.AccountUtils;
+import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.utils.OwnCloudVersion;
public class AccountUtilsTest extends AndroidTestCase {