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
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
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
<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>
<string name="common_loading">Loading …</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 …</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…</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…</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>
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);
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
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
\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
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
/// 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
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
}\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
} \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
}\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
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
\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
* \r
* @param view Refresh 'button'\r
*/\r
- public void onRefreshClick() {\r
+ public void onRefreshClick(View view) {\r
checkOcServer();\r
}\r
\r
// 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);
// 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);
// 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);
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;
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 {
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);
+ }
}
}