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