Merge branch 'develop' into modify_password
authorDavid A. Velasco <dvelasco@solidgear.es>
Tue, 2 Jul 2013 11:08:27 +0000 (13:08 +0200)
committerDavid A. Velasco <dvelasco@solidgear.es>
Tue, 2 Jul 2013 11:08:27 +0000 (13:08 +0200)
res/layout-land/account_setup.xml
res/layout/account_setup.xml
res/menu/account_picker_long_click.xml
res/values/strings.xml
src/com/owncloud/android/authentication/AccountAuthenticator.java
src/com/owncloud/android/authentication/AuthenticatorActivity.java
src/com/owncloud/android/files/services/FileDownloader.java
src/com/owncloud/android/files/services/FileUploader.java
src/com/owncloud/android/syncadapter/FileSyncAdapter.java
src/com/owncloud/android/ui/activity/AccountSelectActivity.java

index dea86cd..d3622be 100644 (file)
                            android:orientation="vertical"\r
                            android:padding="8dp" >\r
                \r
-                               <EditText\r
-                                       android:id="@+id/hostUrlInput"\r
+                           <FrameLayout \r
                                        android:layout_width="match_parent"\r
                                        android:layout_height="wrap_content"\r
-                                       android:ems="10"\r
-                                       android:hint="@string/auth_host_url"\r
-                                       android:inputType="textUri"\r
-                                       android:drawablePadding="5dp"\r
-                                       >\r
-                                       <requestFocus />\r
-                               </EditText>\r
+                               >\r
+                                       <EditText\r
+                                               android:id="@+id/hostUrlInput"\r
+                                               android:layout_width="match_parent"\r
+                                               android:layout_height="wrap_content"\r
+                                               android:hint="@string/auth_host_url"\r
+                                               android:inputType="textUri"\r
+                                               android:drawablePadding="5dp"\r
+                                               android:paddingRight="55dp"\r
+                                               >\r
+                                               <requestFocus />\r
+                                       </EditText>\r
+                                       <ImageButton\r
+                                           android:id="@+id/refeshButton"\r
+                                           android:layout_width="48dp"\r
+                                           android:layout_height="48dp"\r
+                                           android:layout_gravity="center_vertical|right"\r
+                                           android:layout_marginRight="5dp"\r
+                                           android:padding="0dp"\r
+                                           android:scaleType="fitCenter"\r
+                                           android:src="@drawable/ic_action_refresh_black"\r
+                               android:onClick="onRefreshClick"\r
+                                           android:visibility="gone"\r
+                                               android:background="@android:color/transparent"\r
+                                           />\r
+                               </FrameLayout>\r
                \r
                                <TextView\r
                                        android:id="@+id/server_status_text"\r
index a218fa9..1c7921d 100644 (file)
             android:layout_marginTop="10dp"\r
             android:src="@drawable/logo" />\r
 \r
-               <EditText\r
-                       android:id="@+id/hostUrlInput"\r
+           <FrameLayout \r
                        android:layout_width="match_parent"\r
                        android:layout_height="wrap_content"\r
-                       android:ems="10"\r
-                       android:hint="@string/auth_host_url"\r
-                       android:inputType="textUri"\r
-                       android:drawablePadding="5dp"\r
-                       >\r
-                       <requestFocus />\r
-               </EditText>\r
-\r
-        <TextView\r
+               >\r
+                       <EditText\r
+                               android:id="@+id/hostUrlInput"\r
+                               android:layout_width="match_parent"\r
+                               android:layout_height="wrap_content"\r
+                               android:hint="@string/auth_host_url"\r
+                               android:inputType="textUri"\r
+                               android:drawablePadding="5dp"\r
+                               android:paddingRight="55dp"\r
+                               >\r
+                               <requestFocus />\r
+                       </EditText>\r
+                       <ImageButton\r
+                           android:id="@+id/refeshButton"\r
+                           android:layout_width="48dp"\r
+                           android:layout_height="48dp"\r
+                           android:layout_gravity="center_vertical|right"\r
+                           android:layout_marginRight="5dp"\r
+                           android:padding="0dp"\r
+                           android:scaleType="fitCenter"\r
+                           android:src="@drawable/ic_action_refresh_black"\r
+               android:onClick="onRefreshClick"\r
+                               android:visibility="gone"\r
+                               android:background="@android:color/transparent"\r
+                           />\r
+               </FrameLayout>\r
+\r
+               <TextView\r
             android:id="@+id/server_status_text"\r
             android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
index a6ef11e..b7e2dd3 100644 (file)
@@ -18,7 +18,6 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 -->
 <menu xmlns:android="http://schemas.android.com/apk/res/android" >
+    <item android:id="@+id/change_password" android:title="@string/change_password"></item>
     <item android:id="@+id/delete_account" android:title="@string/delete_account"></item>
-    
-
 </menu>
\ No newline at end of file
index 4ea3157..7e4ec93 100644 (file)
@@ -51,7 +51,7 @@
     <string name="auth_host_url">Server address</string>
     <string name="auth_username">Username</string>
     <string name="auth_password">Password</string>
-    <string name="auth_register">I am new to %1$s</string>
+    <string name="auth_register">New to %1$s?</string>
     <string name="new_session_uri_error">Incorrect address given</string>
     <string name="new_session_session_name_error">Incorrect session name</string>
     <string name="sync_string_files">Files</string>
@@ -95,6 +95,7 @@
     <string name="common_loading">Loading &#8230;</string>
     <string name="common_error_unknown">Unknown error</string>
     <string name="about_title">About</string>
+    <string name="change_password">Change password</string>
     <string name="delete_account">Delete account</string>
     <string name="create_account">Create account</string>
     <string name="upload_chooser_title">Upload from &#8230;</string>
     <string name="sync_string_contacts">Contacts</string>
     <string name="sync_fail_ticker">Synchronization failed</string>
     <string name="sync_fail_content">Synchronization of %1$s could not be completed</string>
-    <string name="sync_fail_content_unauthorized">Invalid credentials for %1$s</string>
+    <string name="sync_fail_content_unauthorized">Invalid password for %1$s</string>
        <string name="sync_conflicts_in_favourites_ticker">Conflicts found</string>
        <string name="sync_conflicts_in_favourites_content">%1$d kept-in-sync files could not be sync\'ed</string>
     <string name="sync_fail_in_favourites_ticker">Kept-in-sync files failed</string>
         <item>60</item>
     </string-array>
 
-    <string name="auth_trying_to_login">Trying to login...</string>
+    <string name="auth_trying_to_login">Trying to login&#8230;</string>
     <string name="auth_no_net_conn_title">No network connection</string>
     <string name="auth_no_net_conn_message">No network connection has been detected, check your Internet connection and try again.</string>
     <string name="auth_connect_anyway">Connect anyway</string>
     <string name="auth_nossl_plain_ok_title">Secure connection unavailable.</string>
     <string name="auth_nossl_plain_ok_message">The Application cannot establish a secure connection to the server. A non secure connection is available. You may continue or cancel.</string>
     <string name="auth_connection_established">Connection established</string>
-    <string name="auth_testing_connection">Testing connection...</string>
+    <string name="auth_testing_connection">Testing connection&#8230;</string>
     <string name="auth_not_configured_title">Malformed server configuration</string>
     <string name="auth_not_configured_message">It seems that your server instance is not correctly configured. Contact your administrator for more details.</string>
     <string name="auth_unknown_error_title">Unknown error occurred!</string>
     <string name="auth_bad_oc_version_title">Unrecognized server version</string>
     <string name="auth_wrong_connection_title">Couldn\'t establish connection</string>
     <string name="auth_secure_connection">Secure connection established</string>
-    <string name="auth_unauthorized">Invalid credentials</string>
+    <string name="auth_unauthorized">Wrong username or password</string>
        <string name="auth_oauth_error">Unsuccessful authorization</string>
        <string name="auth_oauth_error_access_denied">Access denied by authorization server</string>
     <string name="auth_not_found">Wrong path given</string>
     <string name="auth_internal">Internal server error, code %1$d</string>
     <string name="auth_wtf_reenter_URL">Unexpected state; please, enter the server URL again</string>
     <string name="auth_expired_oauth_token_toast">Your authorization expired.\nPlease, authorize again</string>
-    <string name="auth_expired_basic_auth_toast">Your saved credentials are invalid.\nPlease, enter the current credentials</string>
+    <string name="auth_expired_basic_auth_toast">Please, enter the current password</string>
     
     <string name="crashlog_message">Application terminated unexpectedly. Would you like to submit a crash report?</string>
     <string name="crashlog_send_report">Send report</string>
index aa12993..30eda59 100644 (file)
@@ -190,6 +190,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
         intent.putExtra(KEY_AUTH_TOKEN_TYPE, authTokenType);
         intent.putExtra(KEY_LOGIN_OPTIONS, options);
         intent.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, account);
+        intent.putExtra(AuthenticatorActivity.EXTRA_ENFORCED_UPDATE, true);
         intent.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_TOKEN);
         
 
index 6eae48f..dabe98e 100644 (file)
@@ -60,6 +60,7 @@ import android.view.inputmethod.EditorInfo;
 import android.widget.CheckBox;\r
 import android.widget.EditText;\r
 import android.widget.Button;\r
+import android.widget.ImageButton;\r
 import android.widget.TextView;\r
 import android.widget.Toast;\r
 import android.widget.TextView.OnEditorActionListener;\r
@@ -83,6 +84,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     public static final String EXTRA_USER_NAME = "USER_NAME";\r
     public static final String EXTRA_HOST_NAME = "HOST_NAME";\r
     public static final String EXTRA_ACTION = "ACTION";\r
+    public static final String EXTRA_ENFORCED_UPDATE = "ENFORCE_UPDATE";\r
 \r
     private static final String KEY_HOST_URL_TEXT = "HOST_URL_TEXT";\r
     private static final String KEY_OC_VERSION = "OC_VERSION";\r
@@ -109,7 +111,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
 \r
     public static final byte ACTION_CREATE = 0;\r
     public static final byte ACTION_UPDATE_TOKEN = 1;\r
-    \r
+\r
     private String mHostBaseUrl;\r
     private OwnCloudVersion mDiscoveredVersion;\r
 \r
@@ -131,6 +133,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     private Account mAccount;\r
 \r
     private EditText mHostUrlInput;\r
+    private ImageButton mRefreshButton;\r
     private EditText mUsernameInput;\r
     private EditText mPasswordInput;\r
     private CheckBox mOAuth2Check;\r
@@ -157,6 +160,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         /// set view and get references to view elements\r
         setContentView(R.layout.account_setup);\r
         mHostUrlInput = (EditText) findViewById(R.id.hostUrlInput);\r
+        mRefreshButton = (ImageButton) findViewById(R.id.refeshButton);\r
         mUsernameInput = (EditText) findViewById(R.id.account_username);\r
         mPasswordInput = (EditText) findViewById(R.id.account_password);\r
         mOAuthAuthEndpointText = (TextView)findViewById(R.id.oAuthEntryPoint_1);\r
@@ -177,6 +181,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         mAction = getIntent().getByteExtra(EXTRA_ACTION, ACTION_CREATE); \r
         mAccount = null;\r
         mHostBaseUrl = "";\r
+        boolean refreshButtonEnabled = false;\r
 \r
         if (savedInstanceState == null) {\r
             /// connection state and info\r
@@ -204,7 +209,11 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             }\r
             mOAuth2Check.setChecked(oAuthRequired);\r
             changeViewByOAuth2Check(oAuthRequired);\r
-\r
+            mJustCreated = true;\r
+            \r
+            if (mAction == ACTION_UPDATE_TOKEN) {\r
+                checkOcServer(); \r
+            }\r
 \r
         } else {\r
             /// connection state and info\r
@@ -235,43 +244,35 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             }            \r
             \r
             // refresh button enabled\r
-            mRefreshButtonEnabled = savedInstanceState.getBoolean(KEY_REFRESH_BUTTON_ENABLED);\r
+            refreshButtonEnabled = savedInstanceState.getBoolean(KEY_REFRESH_BUTTON_ENABLED);\r
+            \r
 \r
         }\r
 \r
         showServerStatus();\r
         showAuthStatus();\r
-        if (mServerIsChecked && !mServerIsValid && mRefreshButtonEnabled) showRefreshButton();\r
-        mOkButton.setEnabled(mServerIsValid); // state not automatically recovered in configuration changes\r
-\r
-        if (!OAUTH_MODE_OPTIONAL.equals(getString(R.string.oauth2_mode))) {\r
-            mOAuth2Check.setVisibility(View.GONE);\r
-        }\r
 \r
         if (mAction == ACTION_UPDATE_TOKEN) {\r
             /// lock things that should not change\r
             mHostUrlInput.setEnabled(false);\r
+            mHostUrlInput.setFocusable(false);\r
             mUsernameInput.setEnabled(false);\r
+            mUsernameInput.setFocusable(false);\r
+            mOAuth2Check.setVisibility(View.GONE);\r
+        }\r
+        \r
+        //if (mServerIsChecked && !mServerIsValid && mRefreshButtonEnabled) showRefreshButton();\r
+        if (mServerIsChecked && !mServerIsValid && refreshButtonEnabled) showRefreshButton();\r
+        mOkButton.setEnabled(mServerIsValid); // state not automatically recovered in configuration changes\r
+\r
+        if (!OAUTH_MODE_OPTIONAL.equals(getString(R.string.oauth2_mode))) {\r
             mOAuth2Check.setVisibility(View.GONE);\r
-            if (!mServerIsValid && mOcServerChkOperation == null) {\r
-                checkOcServer(); \r
-            }\r
         }\r
 \r
         mPasswordInput.setText("");     // clean password to avoid social hacking (disadvantage: password in removed if the device is turned aside)\r
-        mJustCreated = true;\r
 \r
         /// bind view elements to listeners\r
         mHostUrlInput.setOnFocusChangeListener(this);\r
-        mHostUrlInput.setOnTouchListener(new RightDrawableOnTouchListener() {\r
-            @Override\r
-            public boolean onDrawableTouch(final MotionEvent event) {\r
-                if (event.getAction() == MotionEvent.ACTION_UP) {\r
-                    AuthenticatorActivity.this.onRefreshClick();\r
-                }\r
-                return true;\r
-            }\r
-        });\r
         mHostUrlInput.addTextChangedListener(new TextWatcher() {\r
 \r
             @Override\r
@@ -337,7 +338,8 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         }\r
         \r
         // refresh button enabled\r
-        outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, mRefreshButtonEnabled);\r
+        //outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, mRefreshButtonEnabled);\r
+        outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, (mRefreshButton.getVisibility() == View.VISIBLE));\r
 \r
     }\r
 \r
@@ -368,7 +370,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         super.onResume();\r
         // the state of mOAuth2Check is automatically recovered between configuration changes, but not before onCreate() finishes; so keep the next lines here\r
         changeViewByOAuth2Check(mOAuth2Check.isChecked());  \r
-        if (mAction == ACTION_UPDATE_TOKEN && mJustCreated) {\r
+        if (mAction == ACTION_UPDATE_TOKEN && mJustCreated && getIntent().getBooleanExtra(EXTRA_ENFORCED_UPDATE, false)) {\r
             if (mOAuth2Check.isChecked())\r
                 Toast.makeText(this, R.string.auth_expired_oauth_token_toast, Toast.LENGTH_LONG).show();\r
             else\r
@@ -1193,13 +1195,15 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
 \r
 \r
     private void showRefreshButton() {\r
-        mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_refresh_black, 0);\r
-        mRefreshButtonEnabled = true;\r
+        /*mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_refresh_black, 0);\r
+        mRefreshButtonEnabled = true;*/\r
+        mRefreshButton.setVisibility(View.VISIBLE);\r
     }\r
 \r
     private void hideRefreshButton() {\r
-        mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);\r
-        mRefreshButtonEnabled = false;\r
+        /*mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);\r
+        mRefreshButtonEnabled = false;*/\r
+        mRefreshButton.setVisibility(View.GONE);\r
     }\r
 \r
     /**\r
@@ -1209,7 +1213,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
      * \r
      * @param view      Refresh 'button'\r
      */\r
-    public void onRefreshClick() {\r
+    public void onRefreshClick(View view) {\r
         checkOcServer();\r
     }\r
     \r
index 1ec5591..02a8a45 100644 (file)
@@ -468,6 +468,7 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
                 // let the user update credentials with one click
                 Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
                 updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, download.getAccount());
+                updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ENFORCED_UPDATE, true);
                 updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_TOKEN);
                 updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                 updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
index 2f66e30..e9f445a 100644 (file)
@@ -795,6 +795,7 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
                 // let the user update credentials with one click
                 Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
                 updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, upload.getAccount());
+                updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ENFORCED_UPDATE, true);
                 updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_TOKEN);
                 updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                 updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
index ec8750c..f0d7b16 100644 (file)
@@ -303,6 +303,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
             // let the user update credentials with one click
             Intent updateAccountCredentials = new Intent(getContext(), AuthenticatorActivity.class);
             updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, getAccount());
+            updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ENFORCED_UPDATE, true);
             updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_TOKEN);
             updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
             updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
index 7428f50..1a1cd51 100644 (file)
@@ -48,6 +48,7 @@ import com.actionbarsherlock.view.Menu;
 import com.actionbarsherlock.view.MenuInflater;
 import com.actionbarsherlock.view.MenuItem;
 import com.owncloud.android.authentication.AccountAuthenticator;
+import com.owncloud.android.authentication.AuthenticatorActivity;
 import com.owncloud.android.authentication.AccountUtils;
 import com.owncloud.android.Log_OC;
 
@@ -142,11 +143,17 @@ public class AccountSelectActivity extends SherlockListActivity implements
         return false;
     }
 
+    /**
+     * Called when the user clicked on an item into the context menu created at 
+     * {@link #onCreateContextMenu(ContextMenu, View, ContextMenuInfo)} for every
+     * ownCloud {@link Account} , containing 'secondary actions' for them.
+     * 
+     * {@inheritDoc}}
+     */
     @SuppressWarnings("unchecked")
     @Override
     public boolean onContextItemSelected(android.view.MenuItem item) {
-        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
-                .getMenuInfo();
+        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
         int index = info.position;
         HashMap<String, String> map = null;
         try {
@@ -158,11 +165,18 @@ public class AccountSelectActivity extends SherlockListActivity implements
         
         String accountName = map.get("NAME");
         AccountManager am = (AccountManager) getSystemService(ACCOUNT_SERVICE);
-        Account accounts[] = am
-                .getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE);
+        Account accounts[] = am.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE);
         for (Account a : accounts) {
             if (a.name.equals(accountName)) {
-                am.removeAccount(a, this, mHandler);
+                if (item.getItemId() == R.id.change_password) {
+                    Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
+                    updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, a);
+                    updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_TOKEN);
+                    startActivity(updateAccountCredentials);
+                    
+                } else if (item.getItemId() == R.id.delete_account) {
+                    am.removeAccount(a, this, mHandler);
+                }
             }
         }