<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry kind="lib" path="lib/commons-codec-1.4.jar"/>
- <classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
- <classpathentry kind="lib" path="lib/commons-httpclient-3.0.1.jar"/>
- <classpathentry kind="lib" path="lib/commons-io-2.0.1.jar"/>
- <classpathentry kind="lib" path="lib/commons-httpclient-contrib-3.0.jar"/>
- <classpathentry kind="lib" path="lib/httpclient-4.1.2.jar"/>
- <classpathentry kind="lib" path="lib/httpcore-4.1.2.jar"/>
- <classpathentry kind="lib" path="lib/httpmime-4.1.2.jar"/>
- <classpathentry kind="lib" path="lib/httpclient-cache-4.1.2.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/commons-codec-1.4.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/commons-logging-1.1.1.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/commons-httpclient-3.0.1.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/commons-io-2.0.1.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/commons-httpclient-contrib-3.0.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/httpclient-4.1.2.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/httpcore-4.1.2.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/httpmime-4.1.2.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/httpclient-cache-4.1.2.jar"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
android:resource="@xml/syncadapter_files"/>\r
</service>\r
<provider android:name=".cp" android:enabled="true" android:syncable="true" android:exported="false" android:authorities="org.owncloud" android:label="@string/sync_string_files"></provider>\r
- <activity android:name=".ui.activity.AuthenticatorActivity"></activity>\r
+ <activity android:name=".ui.activity.AuthenticatorActivity" android:theme="@style/Theme.ownCloud"></activity>\r
<service android:name=".FileDownloader">\r
</service>\r
<activity android:name=".ui.activity.FileDetailActivity"></activity>\r
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="fill_parent"\r
+ android:background="#F7F7F7"\r
+ android:orientation="vertical" >\r
+\r
+ <LinearLayout\r
+ android:id="@+id/linearLayout1"\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="fill_parent"\r
+ android:orientation="horizontal" >\r
+\r
+ <LinearLayout\r
+ android:id="@+id/file_list_container"\r
+ android:layout_width="0dp"\r
+ android:layout_height="wrap_content" \r
+ android:layout_weight="1">\r
+ </LinearLayout>\r
+\r
+ <fragment\r
+ android:id="@+id/fileDetail"\r
+ android:layout_width="0dp"\r
+ android:layout_height="fill_parent"\r
+ android:layout_weight="2"\r
+ class="eu.alefzero.owncloud.ui.fragment.FileDetail" >\r
+\r
+ <!-- Preview: layout=@layout/file_details -->\r
+ </fragment>\r
+ </LinearLayout>\r
+\r
+</LinearLayout>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
- android:layout_width="fill_parent"\r
- android:layout_height="fill_parent"\r
- android:background="#F7F7F7"\r
- android:orientation="vertical" \r
- android:id="@+id/file_list_container">\r
-\r
-</LinearLayout>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
- android:layout_width="fill_parent"\r
- android:layout_height="fill_parent" >\r
-\r
- <ImageView\r
- android:id="@+id/gridImage"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_alignParentTop="true"\r
- android:layout_centerHorizontal="true"\r
- android:src="@drawable/action_item_btn" />
-\r\r\r
- <TextView\r
- android:id="@+id/gridText"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_below="@+id/gridImage"\r
- android:layout_centerHorizontal="true"\r
- android:text="Medium Text"\r
- android:textAppearance="?android:attr/textAppearanceMedium"\r
- android:textColor="@color/setup_text_hint" />\r
-\r
-</RelativeLayout>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
- android:layout_width="fill_parent"\r
- android:layout_height="fill_parent"\r
- android:orientation="vertical" >\r
- \r
- <GridView\r
- android:id="@+id/homeScreenGrid"\r
- android:layout_width="fill_parent"\r
- android:layout_height="fill_parent"\r
- android:layout_gravity="center_horizontal"\r
- android:columnWidth="90dp"\r
- android:gravity="center"\r
- android:horizontalSpacing="10dp"\r
- android:numColumns="2"\r
- android:stretchMode="columnWidth"\r
- android:verticalSpacing="10dp" >\r
- </GridView>\r
-\r
- \r
-\r
-</LinearLayout>
\ No newline at end of file
android:layout_width="fill_parent"\r
android:layout_height="fill_parent"\r
android:background="#F7F7F7"\r
- android:orientation="vertical" >\r
-\r
- <LinearLayout\r
- android:id="@+id/linearLayout1"\r
- android:layout_width="fill_parent"\r
- android:layout_height="fill_parent"\r
- android:orientation="horizontal" >\r
-\r
- <LinearLayout\r
- android:id="@+id/file_list_container"\r
- android:layout_width="0dp"\r
- android:layout_height="wrap_content" \r
- android:layout_weight="1">\r
- </LinearLayout>\r
-\r
- <fragment\r
- android:id="@+id/fileDetail"\r
- android:layout_width="0dp"\r
- android:layout_height="fill_parent"\r
- android:layout_weight="2"\r
- class="eu.alefzero.owncloud.ui.fragment.FileDetail" >\r
-\r
- <!-- Preview: layout=@layout/file_details -->\r
- </fragment>\r
- </LinearLayout>\r
+ android:orientation="vertical" \r
+ android:id="@+id/file_list_container">\r
\r
</LinearLayout>
\ No newline at end of file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
android:layout_width="fill_parent"\r
android:layout_height="fill_parent" >\r
- \r
- <ImageView \r
+\r
+ <ImageView\r
android:id="@+id/gridImage"\r
android:layout_width="wrap_content"\r
android:layout_height="wrap_content"\r
android:layout_alignParentTop="true"\r
- android:layout_centerVertical="true"\r
- android:src="@drawable/action_item_btn"\r
- />\r
- \r
+ android:layout_centerHorizontal="true"\r
+ android:src="@drawable/action_item_btn" />
+\r\r\r
<TextView\r
android:id="@+id/gridText"\r
android:layout_width="wrap_content"\r
android:layout_height="wrap_content"\r
- android:layout_toRightOf="@+id/gridImage"\r
- android:layout_centerVertical="true"\r
+ android:layout_below="@+id/gridImage"\r
+ android:layout_centerHorizontal="true"\r
android:text="Medium Text"\r
android:textAppearance="?android:attr/textAppearanceMedium"\r
android:textColor="@color/setup_text_hint" />\r
- \r
\r
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>\r
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
- android:layout_width="match_parent"\r
- android:layout_height="match_parent"\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="fill_parent"\r
android:orientation="vertical" >\r
+ \r
+ <GridView\r
+ android:id="@+id/homeScreenGrid"\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="fill_parent"\r
+ android:layout_gravity="center_horizontal"\r
+ android:columnWidth="90dp"\r
+ android:gravity="center"\r
+ android:horizontalSpacing="20dp"\r
+ android:verticalSpacing="20dp"\r
+ android:layout_marginTop="20dp"\r
+ android:numColumns="2"\r
+ android:stretchMode="columnWidth" >\r
+ </GridView>\r
\r
- <LinearLayout\r
- android:id="@+id/linearLayout1"\r
- android:layout_width="match_parent"\r
- android:layout_height="match_parent"\r
- android:orientation="horizontal" >\r
-\r
- <fragment\r
- android:id="@+id/landingPage"\r
- android:layout_width="fill_parent"\r
- android:layout_height="wrap_content"\r
- class="eu.alefzero.owncloud.ui.fragment.LandingPageFragment" >\r
-\r
- <!-- Preview: layout=@layout/landing_page_fragment -->\r
- </fragment>\r
- </LinearLayout>\r
+ \r
\r
</LinearLayout>
\ No newline at end of file
<string name="prefs_general">General</string>
<string name="prefs_sessions">Stored sessions</string>
<string name="prefs_add_session">Add new session</string>
+ <string name="prefs_create_img_thumbnails">Create image thumbnails</string>
+ <string name="prefs_select_oc_account">Select an account</string>
+ <string name="prefs_summary_select_oc_account">Choose, which of your accounts the app should use.</string>
<string name="new_session_id">Session Name</string>
<string name="new_session_url">URL</string>
<string name="new_session_username">Username</string>
<?xml version="1.0" encoding="utf-8"?>
- <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
- <CheckBoxPreference android:title="Create images thumbnails" android:key="create_thumbnails"></CheckBoxPreference>
- </PreferenceScreen>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <CheckBoxPreference
+ android:key="create_thumbnails"
+ android:title="@string/prefs_create_img_thumbnails"
+ />
+
+ <ListPreference
+ android:key="select_oc_account"
+ android:title="@string/prefs_select_oc_account"
+ android:summary="@string/prefs_summary_select_oc_account"
+ />
+
+</PreferenceScreen>
\ No newline at end of file
import eu.alefzero.owncloud.ui.activity.AuthenticatorActivity;\r
\r
\r
+import android.accounts.Account;\r
+import android.accounts.AccountManager;\r
import android.content.Context;\r
+import android.content.SharedPreferences;\r
import android.os.Handler;\r
+import android.preference.PreferenceManager;\r
import android.util.Log;\r
\r
public class AuthUtils {\r
};\r
return performOnBackgroundThread(r);\r
}\r
+ \r
+ /**\r
+ * Can be used to get the currently selected ownCloud account in the preferences\r
+ * \r
+ * @param context The current appContext\r
+ * @return The current account or null, if there is none yet.\r
+ */\r
+ public static Account getCurrentOwnCloudAccount(Context context){\r
+ Account[] ocAccounts = AccountManager.get(context).getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE);\r
+ Account defaultAccount = null;\r
+ \r
+ SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(context);\r
+ String accountName = appPreferences.getString("select_oc_account", null);\r
+ \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
+ return defaultAccount;\r
+ }\r
}\r
import android.content.ContentResolver;\r
import android.content.DialogInterface;\r
import android.content.Intent;\r
+import android.content.SharedPreferences;\r
import android.graphics.Color;\r
import android.os.Bundle;\r
import android.os.Handler;\r
+import android.preference.PreferenceManager;\r
import android.text.InputType;\r
import android.util.Log;\r
import android.view.View;\r
try {\r
url = new URL(message);\r
} catch (MalformedURLException e) {\r
- // should never happend\r
+ // should never happen\r
Log.e(getClass().getName(), "Malformed URL: " + message);\r
return;\r
}\r
\r
String username = username_text.getText().toString().trim();\r
- Account account = new Account(username + "@" + url.getHost(), AccountAuthenticator.ACCOUNT_TYPE);\r
+ String accountName = username + "@" + url.getHost();\r
+ Account account = new Account(accountName, AccountAuthenticator.ACCOUNT_TYPE);\r
AccountManager accManager = AccountManager.get(this);\r
accManager.addAccountExplicitly(account, password_text.getText().toString(), null);\r
+ \r
+ // Add this account as default in the preferences, if there is none already\r
+ SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(this);\r
+ String defaultAccountName = appPreferences.getString("select_oc_account", null);\r
+ if(defaultAccountName == null){\r
+ SharedPreferences.Editor editor = appPreferences.edit();\r
+ editor.putString("select_oc_account", accountName);\r
+ editor.commit();\r
+ }\r
\r
final Intent intent = new Intent();\r
intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, AccountAuthenticator.ACCOUNT_TYPE);\r
intent.putExtra(AccountManager.KEY_AUTHTOKEN, AccountAuthenticator.ACCOUNT_TYPE);\r
accManager.setUserData(account, AccountAuthenticator.KEY_OC_URL, url.toString());\r
\r
- // TODO prepare this URL during a central service\r
+ // TODO prepare this URL using a central service\r
intent.putExtra(AccountManager.KEY_USERDATA, username);\r
accManager.setUserData(account, AccountAuthenticator.KEY_CONTACT_URL,\r
url.toString().replace(AuthUtils.WEBDAV_PATH_2_0, AuthUtils.CARDDAV_PATH_2_0)\r
import android.app.AlertDialog;\r
import android.app.Dialog;\r
import android.content.DialogInterface;\r
-import android.content.Intent;\r
import android.content.DialogInterface.OnCancelListener;\r
-import android.content.res.Configuration;\r
+import android.content.Intent;\r
import android.os.Bundle;\r
import android.support.v4.app.ActionBar;\r
-import android.support.v4.app.FragmentTransaction;\r
import android.support.v4.app.ActionBar.OnNavigationListener;\r
import android.support.v4.view.Menu;\r
import android.support.v4.view.MenuItem;\r
import eu.alefzero.owncloud.R;\r
import eu.alefzero.owncloud.R.id;\r
import eu.alefzero.owncloud.authenticator.AccountAuthenticator;\r
-import eu.alefzero.owncloud.ui.fragment.FileDetail;\r
import eu.alefzero.owncloud.ui.fragment.FileList;\r
\r
/**\r
action_bar.setNavigationMode(android.support.v4.app.ActionBar.NAVIGATION_MODE_LIST);\r
action_bar.setDisplayShowTitleEnabled(false);\r
action_bar.setListNavigationCallbacks(mDirectories, this);\r
-\r
- FragmentTransaction ft = getSupportFragmentManager().beginTransaction();\r
- ft.add(R.id.file_list_container, new FileList());\r
- if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {\r
- ft.add(R.id.fileDetail, new FileDetail());\r
- }\r
- ft.commit();\r
}\r
\r
@Override\r
\r
import eu.alefzero.owncloud.OwnCloudSession;\r
import eu.alefzero.owncloud.R;\r
+import eu.alefzero.owncloud.authenticator.AccountAuthenticator;\r
import eu.alefzero.owncloud.db.DbHandler;\r
\r
+import android.accounts.Account;\r
+import android.accounts.AccountManager;\r
import android.app.Activity;\r
import android.content.Intent;\r
import android.os.Bundle;\r
+import android.preference.ListPreference;\r
import android.preference.Preference;\r
import android.preference.PreferenceActivity;\r
import android.preference.PreferenceScreen;\r
*\r
*/\r
public class Preferences extends PreferenceActivity {\r
- private String TAG = "OwnCloudPreferences";\r
+ private static final String TAG = "OwnCloudPreferences";\r
private final int mNewSession = 47;\r
private final int mEditSession = 48;\r
private DbHandler mDbHandler;\r
private Vector<OwnCloudSession> mSessions;\r
+ private Account[] mAccounts;\r
private int mSelectedMenuItem;\r
\r
@Override\r
mSessions = new Vector<OwnCloudSession>();\r
addPreferencesFromResource(R.xml.preferences);\r
registerForContextMenu(getListView());\r
+ populateAccountList();\r
//populateSessionList();\r
}\r
\r
try {\r
uri = new URI(mSessions.get(i).getUrl());\r
} catch (URISyntaxException e) {\r
- e.printStackTrace(); // should never happend\r
+ e.printStackTrace(); // should never happen\r
continue;\r
}\r
preference.setSummary(uri.getScheme() + "://" + uri.getHost()+uri.getPath());\r
ps.addPreference(preference);\r
}\r
}\r
+ \r
+ /**\r
+ * Populates the account selector\r
+ */\r
+ private void populateAccountList(){\r
+ AccountManager accMan = AccountManager.get(this);\r
+ mAccounts = accMan.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE);\r
+ ListPreference accountList = (ListPreference) findPreference("select_oc_account");\r
+ \r
+ // Transform accounts into array of string for preferences to use\r
+ String[] accNames = new String[mAccounts.length];\r
+ for(int i = 0; i < mAccounts.length; i++){\r
+ Account account = mAccounts[i];\r
+ accNames[i] = account.name;\r
+ }\r
+ \r
+ accountList.setEntries(accNames);\r
+ accountList.setEntryValues(accNames);\r
+ }\r
\r
@Override\r
public boolean onCreateOptionsMenu(Menu menu) {\r
import android.widget.ImageView;\r
import android.widget.TextView;\r
import eu.alefzero.owncloud.R;\r
+import eu.alefzero.owncloud.authenticator.AuthUtils;\r
import eu.alefzero.owncloud.ui.activity.FileDisplayActivity;\r
import eu.alefzero.owncloud.ui.activity.Preferences;\r
\r
*/\r
public Object getItem(int position) {\r
Intent intent = new Intent();\r
+ \r
switch (position) {\r
case 0:\r
- intent.setClass(mContext, FileDisplayActivity.class);\r
+ /* \r
+ * The FileDisplayActivity requires the ownCloud account as an parcableExtra.\r
+ * We will put in the one that is selected in the preferences\r
+ */\r
+ intent.setClass(mContext, FileDisplayActivity.class); \r
+ intent.putExtra("ACCOUNT", AuthUtils.getCurrentOwnCloudAccount(mContext));\r
break;\r
case 5:\r
intent.setClass(mContext, Preferences.class);\r
}\r
return convertView;\r
}\r
-\r
}\r
null);\r
c.moveToFirst();\r
\r
- // retrive details from DB\r
+ // Retrieve details from DB\r
String filename = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_NAME));\r
String mimetype = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE));\r
String path = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH));\r