Trigger synchronization when current account is changed; remove redundant accounts...
authorDavid A. Velasco <dvelasco@solidgear.es>
Mon, 16 Jul 2012 09:34:37 +0000 (11:34 +0200)
committerDavid A. Velasco <dvelasco@solidgear.es>
Mon, 16 Jul 2012 09:34:37 +0000 (11:34 +0200)
AndroidManifest.xml
res/xml/preferences.xml
src/eu/alefzero/owncloud/ui/activity/AccountSelectActivity.java
src/eu/alefzero/owncloud/ui/activity/Preferences.java

index 5a3060e..a6539f4 100644 (file)
@@ -18,7 +18,7 @@
  -->\r
 <manifest package="eu.alefzero.owncloud"\r
     android:versionCode="1"\r
  -->\r
 <manifest package="eu.alefzero.owncloud"\r
     android:versionCode="1"\r
-    android:versionName="0.1.158B" xmlns:android="http://schemas.android.com/apk/res/android">\r
+    android:versionName="0.1.159B" xmlns:android="http://schemas.android.com/apk/res/android">\r
 \r
     <uses-permission android:name="android.permission.GET_ACCOUNTS" />\r
     <uses-permission android:name="android.permission.USE_CREDENTIALS" />\r
 \r
     <uses-permission android:name="android.permission.GET_ACCOUNTS" />\r
     <uses-permission android:name="android.permission.USE_CREDENTIALS" />\r
index 7a32caf..5b2d63e 100644 (file)
@@ -2,11 +2,11 @@
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
        <PreferenceCategory android:title="@string/prefs_category_general">
     
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
        <PreferenceCategory android:title="@string/prefs_category_general">
     
-    <ListPreference
+    <!-- ListPreference
         android:key="select_oc_account"
         android:title="@string/prefs_select_oc_account"
         android:summary="@string/prefs_summary_select_oc_account" 
         android:key="select_oc_account"
         android:title="@string/prefs_select_oc_account"
         android:summary="@string/prefs_summary_select_oc_account" 
-        />
+        / -->
     <Preference android:title="Manage accounts" android:key="manage_account" />
     <CheckBoxPreference android:title="ownCloud App PIN" android:key="set_pincode" 
                         android:summary="Protect your ownCloud client"/>
     <Preference android:title="Manage accounts" android:key="manage_account" />
     <CheckBoxPreference android:title="ownCloud App PIN" android:key="set_pincode" 
                         android:summary="Protect your ownCloud client"/>
index 482780e..5281b9d 100644 (file)
@@ -9,6 +9,7 @@ import android.accounts.Account;
 import android.accounts.AccountManager;
 import android.accounts.AccountManagerCallback;
 import android.accounts.AccountManagerFuture;
 import android.accounts.AccountManager;
 import android.accounts.AccountManagerCallback;
 import android.accounts.AccountManagerFuture;
+import android.content.ContentResolver;
 import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
 import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
@@ -75,6 +76,12 @@ public class AccountSelectActivity extends SherlockListActivity implements
         String accountName = ((TextView) v.findViewById(android.R.id.text1))
                 .getText().toString();
         AccountUtils.setCurrentOwnCloudAccount(this, accountName);
         String accountName = ((TextView) v.findViewById(android.R.id.text1))
                 .getText().toString();
         AccountUtils.setCurrentOwnCloudAccount(this, accountName);
+
+        // trigger synchronization when current account is changed
+        Bundle bundle = new Bundle();
+        bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
+        ContentResolver.requestSync(AccountUtils.getCurrentOwnCloudAccount(this), "org.owncloud", bundle);
+        
         Intent i = new Intent(this, FileDisplayActivity.class);
         i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
         startActivity(i);
         Intent i = new Intent(this, FileDisplayActivity.class);
         i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
         startActivity(i);
index e71dbdf..c217395 100644 (file)
@@ -31,15 +31,10 @@ import android.preference.PreferenceManager;
 import android.preference.Preference.OnPreferenceChangeListener;\r
 import android.preference.Preference.OnPreferenceClickListener;\r
 import android.util.Log;\r
 import android.preference.Preference.OnPreferenceChangeListener;\r
 import android.preference.Preference.OnPreferenceClickListener;\r
 import android.util.Log;\r
-import android.view.ContextMenu;\r
-import android.view.ContextMenu.ContextMenuInfo;\r
-import android.view.View;\r
-import android.widget.AdapterView.AdapterContextMenuInfo;\r
 \r
 import com.actionbarsherlock.app.ActionBar;\r
 import com.actionbarsherlock.app.SherlockPreferenceActivity;\r
 import com.actionbarsherlock.view.Menu;\r
 \r
 import com.actionbarsherlock.app.ActionBar;\r
 import com.actionbarsherlock.app.SherlockPreferenceActivity;\r
 import com.actionbarsherlock.view.Menu;\r
-import com.actionbarsherlock.view.MenuInflater;\r
 import com.actionbarsherlock.view.MenuItem;\r
 \r
 import eu.alefzero.owncloud.AccountUtils;\r
 import com.actionbarsherlock.view.MenuItem;\r
 \r
 import eu.alefzero.owncloud.AccountUtils;\r
@@ -47,7 +42,6 @@ import eu.alefzero.owncloud.OwnCloudSession;
 import eu.alefzero.owncloud.R;\r
 import eu.alefzero.owncloud.authenticator.AccountAuthenticator;\r
 import eu.alefzero.owncloud.db.DbHandler;\r
 import eu.alefzero.owncloud.R;\r
 import eu.alefzero.owncloud.authenticator.AccountAuthenticator;\r
 import eu.alefzero.owncloud.db.DbHandler;\r
-import eu.alefzero.owncloud.syncadapter.FileSyncAdapter;\r
 \r
 /**\r
  * An Activity that allows the user to change the application's settings.\r
 \r
 /**\r
  * An Activity that allows the user to change the application's settings.\r
@@ -62,8 +56,8 @@ public class Preferences extends SherlockPreferenceActivity implements
     private final int mEditSession = 48;\r
     private DbHandler mDbHandler;\r
     private Vector<OwnCloudSession> mSessions;\r
     private final int mEditSession = 48;\r
     private DbHandler mDbHandler;\r
     private Vector<OwnCloudSession> mSessions;\r
-    private Account[] mAccounts;\r
-    private ListPreference mAccountList;\r
+    //private Account[] mAccounts;\r
+    //private ListPreference mAccountList;\r
     private ListPreference mTrackingUpdateInterval;\r
     private CheckBoxPreference mDeviceTracking;\r
     private CheckBoxPreference pCode;\r
     private ListPreference mTrackingUpdateInterval;\r
     private CheckBoxPreference mDeviceTracking;\r
     private CheckBoxPreference pCode;\r
@@ -75,7 +69,7 @@ public class Preferences extends SherlockPreferenceActivity implements
         mDbHandler = new DbHandler(getBaseContext());\r
         mSessions = new Vector<OwnCloudSession>();\r
         addPreferencesFromResource(R.xml.preferences);\r
         mDbHandler = new DbHandler(getBaseContext());\r
         mSessions = new Vector<OwnCloudSession>();\r
         addPreferencesFromResource(R.xml.preferences);\r
-        populateAccountList();\r
+        //populateAccountList();\r
         ActionBar actionBar = getSherlock().getActionBar();\r
         actionBar.setDisplayHomeAsUpEnabled(true);\r
         Preference p = findPreference("manage_account");\r
         ActionBar actionBar = getSherlock().getActionBar();\r
         actionBar.setDisplayHomeAsUpEnabled(true);\r
         Preference p = findPreference("manage_account");\r
@@ -129,7 +123,7 @@ public class Preferences extends SherlockPreferenceActivity implements
 \r
     /**\r
      * Populates the account selector\r
 \r
     /**\r
      * Populates the account selector\r
-     */\r
+     *-/\r
     private void populateAccountList() {\r
         AccountManager accMan = AccountManager.get(this);\r
         mAccounts = accMan.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE);\r
     private void populateAccountList() {\r
         AccountManager accMan = AccountManager.get(this);\r
         mAccounts = accMan.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE);\r
@@ -151,7 +145,7 @@ public class Preferences extends SherlockPreferenceActivity implements
 \r
         mAccountList.setEntries(accNames);\r
         mAccountList.setEntryValues(accNames);\r
 \r
         mAccountList.setEntries(accNames);\r
         mAccountList.setEntryValues(accNames);\r
-    }\r
+    }*/\r
 \r
     \r
     \r
 \r
     \r
     \r
@@ -216,12 +210,12 @@ public class Preferences extends SherlockPreferenceActivity implements
      */\r
     public boolean onPreferenceChange(Preference preference, Object newValue) {\r
         // Update current account summary\r
      */\r
     public boolean onPreferenceChange(Preference preference, Object newValue) {\r
         // Update current account summary\r
-        if (preference.equals(mAccountList)) {\r
+        /*if (preference.equals(mAccountList)) {\r
             mAccountList.setSummary(newValue.toString());\r
         }\r
 \r
         // Update tracking interval summary\r
             mAccountList.setSummary(newValue.toString());\r
         }\r
 \r
         // Update tracking interval summary\r
-        else if (preference.equals(mTrackingUpdateInterval)) {\r
+        else*/ if (preference.equals(mTrackingUpdateInterval)) {\r
             String trackingSummary = getResources().getString(\r
                     R.string.prefs_trackmydevice_interval_summary);\r
             trackingSummary = String.format(trackingSummary,\r
             String trackingSummary = getResources().getString(\r
                     R.string.prefs_trackmydevice_interval_summary);\r
             trackingSummary = String.format(trackingSummary,\r