public void showStatusBar() { if (isTablet()) { return; } if (statusFragment != null && !statusFragment.isVisible()) { // Hack to ensure statusFragment is visible after coming back to // dialer from chat statusFragment.getView().setVisibility(View.VISIBLE); } findViewById(R.id.status).setVisibility(View.VISIBLE); findViewById(R.id.fragmentContainer) .setPadding(0, LinphoneUtils.pixelsToDpi(getResources(), 40), 0, 0); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_status); if (savedInstanceState == null) { // Create a fragment StatusFragment fragment = new StatusFragment(); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.add(android.R.id.content, fragment, fragment.getClass().getSimpleName()); fragmentTransaction.commit(); } }
public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (currentFragment == FragmentsAvailable.DIALER || currentFragment == FragmentsAvailable.CONTACTS || currentFragment == FragmentsAvailable.HISTORY || currentFragment == FragmentsAvailable.CHATLIST || currentFragment == FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT || currentFragment == FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS) { boolean isBackgroundModeActive = LinphonePreferences.instance().isBackgroundModeEnabled(); if (!isBackgroundModeActive) { stopService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class)); finish(); } else if (LinphoneUtils.onKeyBackGoHome(this, keyCode, event)) { return true; } } else { if (isTablet()) { if (currentFragment == FragmentsAvailable.SETTINGS) { updateAnimationsState(); } } } } else if (keyCode == KeyEvent.KEYCODE_MENU && statusFragment != null) { if (event.getRepeatCount() < 1) { statusFragment.openOrCloseStatusBar(true); } } return super.onKeyDown(keyCode, event); }
@Override public Fragment getItem(int position) { switch (position) { case 0: return TaskFragment.getInstance(); case 1: return RewardFragment.getInstance(); case 2: return StatusFragment.getInstance(); } return null; }
private void changeFragment( Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) { if (statusFragment != null) { statusFragment.closeStatusBar(); } FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); if (!withoutAnimation && !isAnimationDisabled && currentFragment.shouldAnimate()) { if (newFragmentType.isRightOf(currentFragment)) { transaction.setCustomAnimations( R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left, R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right); } else { transaction.setCustomAnimations( R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right, R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left); } } if (newFragmentType != FragmentsAvailable.DIALER || newFragmentType != FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT || newFragmentType != FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS || newFragmentType != FragmentsAvailable.CONTACTS || newFragmentType != FragmentsAvailable.CHATLIST || newFragmentType != FragmentsAvailable.HISTORY) { transaction.addToBackStack(newFragmentType.toString()); } transaction.replace(R.id.fragmentContainer, newFragment, newFragmentType.toString()); transaction.commitAllowingStateLoss(); getSupportFragmentManager().executePendingTransactions(); currentFragment = newFragmentType; }
private void changeFragmentForTablets( Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) { // if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) { // if (newFragmentType == FragmentsAvailable.DIALER) { // showStatusBar(); // } else { // hideStatusBar(); // } // } if (statusFragment != null) { statusFragment.closeStatusBar(); } LinearLayout ll = (LinearLayout) findViewById(R.id.fragmentContainer2); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); if (newFragmentType.shouldAddItselfToTheRightOf(currentFragment)) { ll.setVisibility(View.VISIBLE); transaction.addToBackStack(newFragmentType.toString()); transaction.replace(R.id.fragmentContainer2, newFragment); } else { if (newFragmentType == FragmentsAvailable.DIALER || newFragmentType == FragmentsAvailable.ABOUT || newFragmentType == FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT || newFragmentType == FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS || newFragmentType == FragmentsAvailable.SETTINGS || newFragmentType == FragmentsAvailable.ACCOUNT_SETTINGS) { ll.setVisibility(View.GONE); } else { ll.setVisibility(View.INVISIBLE); } if (!withoutAnimation && !isAnimationDisabled && currentFragment.shouldAnimate()) { if (newFragmentType.isRightOf(currentFragment)) { transaction.setCustomAnimations( R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left, R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right); } else { transaction.setCustomAnimations( R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right, R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left); } } transaction.replace(R.id.fragmentContainer, newFragment); } transaction.commitAllowingStateLoss(); getSupportFragmentManager().executePendingTransactions(); currentFragment = newFragmentType; if (newFragmentType == FragmentsAvailable.DIALER || newFragmentType == FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT || newFragmentType == FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS || newFragmentType == FragmentsAvailable.SETTINGS || newFragmentType == FragmentsAvailable.CONTACTS || newFragmentType == FragmentsAvailable.CHATLIST || newFragmentType == FragmentsAvailable.HISTORY) { try { getSupportFragmentManager() .popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); } catch (java.lang.IllegalStateException e) { } } fragmentsHistory.add(currentFragment); }