Better handle of back event on setup screens
This commit is contained in:
parent
301309184f
commit
c5ba61ed50
1 changed files with 27 additions and 12 deletions
|
@ -28,6 +28,7 @@ import android.preference.PreferenceManager;
|
|||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
@ -103,6 +104,11 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
|||
finish();
|
||||
}
|
||||
} else if (id == R.id.setup_back) {
|
||||
handleBackEvent();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleBackEvent() {
|
||||
if (currentFragment == SetupFragments.MENU) {
|
||||
WelcomeFragment fragment = new WelcomeFragment();
|
||||
changeFragment(fragment);
|
||||
|
@ -114,7 +120,8 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
|||
MenuFragment fragment = new MenuFragment();
|
||||
changeFragment(fragment);
|
||||
currentFragment = SetupFragments.MENU;
|
||||
}
|
||||
} else if (currentFragment == SetupFragments.WELCOME) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,4 +213,12 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
|||
next.setEnabled(true);
|
||||
Toast.makeText(this, getString(R.string.setup_account_validated), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
handleBackEvent();
|
||||
return true;
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue