activity should now finish when paused and authentication was successful

This commit is contained in:
daniel oeh 2012-07-18 13:24:47 +02:00
parent 8957642cee
commit 1bc557ce4b
1 changed files with 17 additions and 0 deletions

View File

@ -26,12 +26,15 @@ public class FlattrAuthActivity extends SherlockActivity {
private Button butAuthenticate; private Button butAuthenticate;
private Button butReturn; private Button butReturn;
private boolean authSuccessful;
private static FlattrAuthActivity singleton; private static FlattrAuthActivity singleton;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
singleton = this; singleton = this;
authSuccessful = false;
Log.d(TAG, "Activity created"); Log.d(TAG, "Activity created");
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.flattr_auth); setContentView(R.layout.flattr_auth);
@ -75,6 +78,7 @@ public class FlattrAuthActivity extends SherlockActivity {
} }
public void handleAuthenticationSuccess() { public void handleAuthenticationSuccess() {
authSuccessful = true;
txtvExplanation.setText(R.string.flattr_auth_success); txtvExplanation.setText(R.string.flattr_auth_success);
butAuthenticate.setEnabled(false); butAuthenticate.setEnabled(false);
butReturn.setVisibility(View.VISIBLE); butReturn.setVisibility(View.VISIBLE);
@ -85,11 +89,24 @@ public class FlattrAuthActivity extends SherlockActivity {
return true; return true;
} }
@Override
protected void onPause() {
super.onPause();
if (authSuccessful) {
finish();
}
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case android.R.id.home: case android.R.id.home:
startActivity(new Intent(this, PreferenceActivity.class)); startActivity(new Intent(this, PreferenceActivity.class));
if (authSuccessful) {
finish();
}
break; break;
default: default:
return false; return false;