From: David A. Velasco Date: Tue, 2 Jul 2013 11:08:27 +0000 (+0200) Subject: Merge branch 'develop' into modify_password X-Git-Tag: oc-android-1.4.3~10^2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/e8239f434aeb23f598080033ec5f15e0b1971f31?hp=856038af0d2b8c5e19bee706a53f5010467a55a5 Merge branch 'develop' into modify_password --- diff --git a/res/layout-land/account_setup.xml b/res/layout-land/account_setup.xml index dea86cd9..d3622be5 100644 --- a/res/layout-land/account_setup.xml +++ b/res/layout-land/account_setup.xml @@ -55,17 +55,35 @@ android:orientation="vertical" android:padding="8dp" > - - - + > + + + + + - - - - - + + + + + + + . --> + - - \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 4ea31574..7e4ec936 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -51,7 +51,7 @@ Server address Username Password - I am new to %1$s + New to %1$s? Incorrect address given Incorrect session name Files @@ -95,6 +95,7 @@ Loading … Unknown error About + Change password Delete account Create account Upload from … @@ -118,7 +119,7 @@ Contacts Synchronization failed Synchronization of %1$s could not be completed - Invalid credentials for %1$s + Invalid password for %1$s Conflicts found %1$d kept-in-sync files could not be sync\'ed Kept-in-sync files failed @@ -177,14 +178,14 @@ 60 - Trying to login... + Trying to login… No network connection No network connection has been detected, check your Internet connection and try again. Connect anyway Secure connection unavailable. The Application cannot establish a secure connection to the server. A non secure connection is available. You may continue or cancel. Connection established - Testing connection... + Testing connection… Malformed server configuration It seems that your server instance is not correctly configured. Contact your administrator for more details. Unknown error occurred! @@ -200,14 +201,14 @@ Unrecognized server version Couldn\'t establish connection Secure connection established - Invalid credentials + Wrong username or password Unsuccessful authorization Access denied by authorization server Wrong path given Internal server error, code %1$d Unexpected state; please, enter the server URL again Your authorization expired.\nPlease, authorize again - Your saved credentials are invalid.\nPlease, enter the current credentials + Please, enter the current password Application terminated unexpectedly. Would you like to submit a crash report? Send report diff --git a/src/com/owncloud/android/authentication/AccountAuthenticator.java b/src/com/owncloud/android/authentication/AccountAuthenticator.java index aa129938..30eda593 100644 --- a/src/com/owncloud/android/authentication/AccountAuthenticator.java +++ b/src/com/owncloud/android/authentication/AccountAuthenticator.java @@ -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); diff --git a/src/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/com/owncloud/android/authentication/AuthenticatorActivity.java index 6eae48f0..dabe98e8 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -60,6 +60,7 @@ import android.view.inputmethod.EditorInfo; import android.widget.CheckBox; import android.widget.EditText; import android.widget.Button; +import android.widget.ImageButton; import android.widget.TextView; import android.widget.Toast; import android.widget.TextView.OnEditorActionListener; @@ -83,6 +84,7 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList public static final String EXTRA_USER_NAME = "USER_NAME"; public static final String EXTRA_HOST_NAME = "HOST_NAME"; public static final String EXTRA_ACTION = "ACTION"; + public static final String EXTRA_ENFORCED_UPDATE = "ENFORCE_UPDATE"; private static final String KEY_HOST_URL_TEXT = "HOST_URL_TEXT"; private static final String KEY_OC_VERSION = "OC_VERSION"; @@ -109,7 +111,7 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList public static final byte ACTION_CREATE = 0; public static final byte ACTION_UPDATE_TOKEN = 1; - + private String mHostBaseUrl; private OwnCloudVersion mDiscoveredVersion; @@ -131,6 +133,7 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList private Account mAccount; private EditText mHostUrlInput; + private ImageButton mRefreshButton; private EditText mUsernameInput; private EditText mPasswordInput; private CheckBox mOAuth2Check; @@ -157,6 +160,7 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList /// set view and get references to view elements setContentView(R.layout.account_setup); mHostUrlInput = (EditText) findViewById(R.id.hostUrlInput); + mRefreshButton = (ImageButton) findViewById(R.id.refeshButton); mUsernameInput = (EditText) findViewById(R.id.account_username); mPasswordInput = (EditText) findViewById(R.id.account_password); mOAuthAuthEndpointText = (TextView)findViewById(R.id.oAuthEntryPoint_1); @@ -177,6 +181,7 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList mAction = getIntent().getByteExtra(EXTRA_ACTION, ACTION_CREATE); mAccount = null; mHostBaseUrl = ""; + boolean refreshButtonEnabled = false; if (savedInstanceState == null) { /// connection state and info @@ -204,7 +209,11 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList } mOAuth2Check.setChecked(oAuthRequired); changeViewByOAuth2Check(oAuthRequired); - + mJustCreated = true; + + if (mAction == ACTION_UPDATE_TOKEN) { + checkOcServer(); + } } else { /// connection state and info @@ -235,43 +244,35 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList } // refresh button enabled - mRefreshButtonEnabled = savedInstanceState.getBoolean(KEY_REFRESH_BUTTON_ENABLED); + refreshButtonEnabled = savedInstanceState.getBoolean(KEY_REFRESH_BUTTON_ENABLED); + } showServerStatus(); showAuthStatus(); - if (mServerIsChecked && !mServerIsValid && mRefreshButtonEnabled) showRefreshButton(); - mOkButton.setEnabled(mServerIsValid); // state not automatically recovered in configuration changes - - if (!OAUTH_MODE_OPTIONAL.equals(getString(R.string.oauth2_mode))) { - mOAuth2Check.setVisibility(View.GONE); - } if (mAction == ACTION_UPDATE_TOKEN) { /// lock things that should not change mHostUrlInput.setEnabled(false); + mHostUrlInput.setFocusable(false); mUsernameInput.setEnabled(false); + mUsernameInput.setFocusable(false); + mOAuth2Check.setVisibility(View.GONE); + } + + //if (mServerIsChecked && !mServerIsValid && mRefreshButtonEnabled) showRefreshButton(); + if (mServerIsChecked && !mServerIsValid && refreshButtonEnabled) showRefreshButton(); + mOkButton.setEnabled(mServerIsValid); // state not automatically recovered in configuration changes + + if (!OAUTH_MODE_OPTIONAL.equals(getString(R.string.oauth2_mode))) { mOAuth2Check.setVisibility(View.GONE); - if (!mServerIsValid && mOcServerChkOperation == null) { - checkOcServer(); - } } mPasswordInput.setText(""); // clean password to avoid social hacking (disadvantage: password in removed if the device is turned aside) - mJustCreated = true; /// bind view elements to listeners mHostUrlInput.setOnFocusChangeListener(this); - mHostUrlInput.setOnTouchListener(new RightDrawableOnTouchListener() { - @Override - public boolean onDrawableTouch(final MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_UP) { - AuthenticatorActivity.this.onRefreshClick(); - } - return true; - } - }); mHostUrlInput.addTextChangedListener(new TextWatcher() { @Override @@ -337,7 +338,8 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList } // refresh button enabled - outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, mRefreshButtonEnabled); + //outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, mRefreshButtonEnabled); + outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, (mRefreshButton.getVisibility() == View.VISIBLE)); } @@ -368,7 +370,7 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList super.onResume(); // the state of mOAuth2Check is automatically recovered between configuration changes, but not before onCreate() finishes; so keep the next lines here changeViewByOAuth2Check(mOAuth2Check.isChecked()); - if (mAction == ACTION_UPDATE_TOKEN && mJustCreated) { + if (mAction == ACTION_UPDATE_TOKEN && mJustCreated && getIntent().getBooleanExtra(EXTRA_ENFORCED_UPDATE, false)) { if (mOAuth2Check.isChecked()) Toast.makeText(this, R.string.auth_expired_oauth_token_toast, Toast.LENGTH_LONG).show(); else @@ -1193,13 +1195,15 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList private void showRefreshButton() { - mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_refresh_black, 0); - mRefreshButtonEnabled = true; + /*mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_refresh_black, 0); + mRefreshButtonEnabled = true;*/ + mRefreshButton.setVisibility(View.VISIBLE); } private void hideRefreshButton() { - mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); - mRefreshButtonEnabled = false; + /*mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); + mRefreshButtonEnabled = false;*/ + mRefreshButton.setVisibility(View.GONE); } /** @@ -1209,7 +1213,7 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList * * @param view Refresh 'button' */ - public void onRefreshClick() { + public void onRefreshClick(View view) { checkOcServer(); } diff --git a/src/com/owncloud/android/files/services/FileDownloader.java b/src/com/owncloud/android/files/services/FileDownloader.java index 1ec5591c..02a8a452 100644 --- a/src/com/owncloud/android/files/services/FileDownloader.java +++ b/src/com/owncloud/android/files/services/FileDownloader.java @@ -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); diff --git a/src/com/owncloud/android/files/services/FileUploader.java b/src/com/owncloud/android/files/services/FileUploader.java index 2f66e305..e9f445a0 100644 --- a/src/com/owncloud/android/files/services/FileUploader.java +++ b/src/com/owncloud/android/files/services/FileUploader.java @@ -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); diff --git a/src/com/owncloud/android/syncadapter/FileSyncAdapter.java b/src/com/owncloud/android/syncadapter/FileSyncAdapter.java index ec8750c0..f0d7b161 100644 --- a/src/com/owncloud/android/syncadapter/FileSyncAdapter.java +++ b/src/com/owncloud/android/syncadapter/FileSyncAdapter.java @@ -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); diff --git a/src/com/owncloud/android/ui/activity/AccountSelectActivity.java b/src/com/owncloud/android/ui/activity/AccountSelectActivity.java index 7428f506..1a1cd51b 100644 --- a/src/com/owncloud/android/ui/activity/AccountSelectActivity.java +++ b/src/com/owncloud/android/ui/activity/AccountSelectActivity.java @@ -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 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); + } } }