Commit 060ecabd authored by Grigory Fedorov's avatar Grigory Fedorov

AccountEditor: light refactoring.

parent be204938
...@@ -67,7 +67,6 @@ public class AccountEditor extends ManagedActivity implements ...@@ -67,7 +67,6 @@ public class AccountEditor extends ManagedActivity implements
getFragmentManager().beginTransaction() getFragmentManager().beginTransaction()
.add(R.id.preferences_activity_container, new AccountEditorFragment()).commit(); .add(R.id.preferences_activity_container, new AccountEditorFragment()).commit();
} else { } else {
token = savedInstanceState.getString(SAVED_TOKEN); token = savedInstanceState.getString(SAVED_TOKEN);
} }
...@@ -92,12 +91,12 @@ public class AccountEditor extends ManagedActivity implements ...@@ -92,12 +91,12 @@ public class AccountEditor extends ManagedActivity implements
token = INVALIDATED_TOKEN; token = INVALIDATED_TOKEN;
} else { } else {
String value = OAuthActivity.getToken(data); String value = OAuthActivity.getToken(data);
if (value == null) if (value == null) {
Application.getInstance().onError( Application.getInstance().onError(R.string.AUTHENTICATION_FAILED);
R.string.AUTHENTICATION_FAILED); } else {
else
token = value; token = value;
} }
}
((AccountEditorFragment) getFragmentManager().findFragmentById( ((AccountEditorFragment) getFragmentManager().findFragmentById(
R.id.preferences_activity_container)).onOAuthChange(); R.id.preferences_activity_container)).onOAuthChange();
...@@ -109,9 +108,8 @@ public class AccountEditor extends ManagedActivity implements ...@@ -109,9 +108,8 @@ public class AccountEditor extends ManagedActivity implements
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
if (getString(R.string.account_oauth_key).equals(preference.getKey())) { if (getString(R.string.account_oauth_key).equals(preference.getKey())) {
startActivityForResult(OAuthActivity.createIntent(this, accountItem startActivityForResult(OAuthActivity.createIntent(this,
.getConnectionSettings().getProtocol()), accountItem.getConnectionSettings().getProtocol()), OAUTH_WML_REQUEST_CODE);
OAUTH_WML_REQUEST_CODE);
return true; return true;
} }
return false; return false;
...@@ -120,8 +118,7 @@ public class AccountEditor extends ManagedActivity implements ...@@ -120,8 +118,7 @@ public class AccountEditor extends ManagedActivity implements
@Override @Override
protected Dialog onCreateDialog(int id) { protected Dialog onCreateDialog(int id) {
if (id == ORBOT_DIALOG_ID) { if (id == ORBOT_DIALOG_ID) {
return new OrbotInstallerDialogBuilder(this, ORBOT_DIALOG_ID) return new OrbotInstallerDialogBuilder(this, ORBOT_DIALOG_ID).create();
.create();
} }
return super.onCreateDialog(id); return super.onCreateDialog(id);
} }
...@@ -131,8 +128,7 @@ public class AccountEditor extends ManagedActivity implements ...@@ -131,8 +128,7 @@ public class AccountEditor extends ManagedActivity implements
} }
public static Intent createIntent(Context context, String account) { public static Intent createIntent(Context context, String account) {
return new AccountIntentBuilder(context, AccountEditor.class) return new AccountIntentBuilder(context, AccountEditor.class).setAccount(account).build();
.setAccount(account).build();
} }
@Override @Override
...@@ -152,9 +148,8 @@ public class AccountEditor extends ManagedActivity implements ...@@ -152,9 +148,8 @@ public class AccountEditor extends ManagedActivity implements
@Override @Override
public void onOAuthClick() { public void onOAuthClick() {
startActivityForResult(OAuthActivity.createIntent(this, accountItem startActivityForResult(OAuthActivity.createIntent(this,
.getConnectionSettings().getProtocol()), accountItem.getConnectionSettings().getProtocol()), OAUTH_WML_REQUEST_CODE);
OAUTH_WML_REQUEST_CODE);
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment