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.Fragment;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
@ -103,18 +104,24 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
} else if (id == R.id.setup_back) {
|
} else if (id == R.id.setup_back) {
|
||||||
if (currentFragment == SetupFragments.MENU) {
|
handleBackEvent();
|
||||||
WelcomeFragment fragment = new WelcomeFragment();
|
}
|
||||||
changeFragment(fragment);
|
}
|
||||||
currentFragment = SetupFragments.WELCOME;
|
|
||||||
|
|
||||||
next.setVisibility(View.VISIBLE);
|
private void handleBackEvent() {
|
||||||
back.setVisibility(View.GONE);
|
if (currentFragment == SetupFragments.MENU) {
|
||||||
} else if (currentFragment == SetupFragments.GENERIC_LOGIN || currentFragment == SetupFragments.LINPHONE_LOGIN || currentFragment == SetupFragments.WIZARD) {
|
WelcomeFragment fragment = new WelcomeFragment();
|
||||||
MenuFragment fragment = new MenuFragment();
|
changeFragment(fragment);
|
||||||
changeFragment(fragment);
|
currentFragment = SetupFragments.WELCOME;
|
||||||
currentFragment = SetupFragments.MENU;
|
|
||||||
}
|
next.setVisibility(View.VISIBLE);
|
||||||
|
back.setVisibility(View.GONE);
|
||||||
|
} else if (currentFragment == SetupFragments.GENERIC_LOGIN || currentFragment == SetupFragments.LINPHONE_LOGIN || currentFragment == SetupFragments.WIZARD) {
|
||||||
|
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);
|
next.setEnabled(true);
|
||||||
Toast.makeText(this, getString(R.string.setup_account_validated), Toast.LENGTH_LONG).show();
|
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