MagicCallActivity.java 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Nextcloud Talk application
  3. *
  4. * @author Mario Danic
  5. * Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. package com.nextcloud.talk.activities;
  21. import android.os.Bundle;
  22. import android.support.v7.app.AppCompatActivity;
  23. import android.view.View;
  24. import android.view.ViewGroup;
  25. import android.view.Window;
  26. import android.view.WindowManager;
  27. import com.bluelinelabs.conductor.Conductor;
  28. import com.bluelinelabs.conductor.Router;
  29. import com.bluelinelabs.conductor.RouterTransaction;
  30. import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler;
  31. import com.nextcloud.talk.R;
  32. import com.nextcloud.talk.application.NextcloudTalkApplication;
  33. import com.nextcloud.talk.controllers.CallController;
  34. import com.nextcloud.talk.controllers.CallNotificationController;
  35. import com.nextcloud.talk.utils.bundle.BundleKeys;
  36. import autodagger.AutoInjector;
  37. import butterknife.BindView;
  38. import butterknife.ButterKnife;
  39. @AutoInjector(NextcloudTalkApplication.class)
  40. public class MagicCallActivity extends AppCompatActivity {
  41. private static final String TAG = "MagicCallActivity";
  42. @BindView(R.id.controller_container)
  43. ViewGroup container;
  44. private Router router;
  45. private static int getSystemUiVisibility() {
  46. int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
  47. flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
  48. return flags;
  49. }
  50. @Override
  51. protected void onCreate(Bundle savedInstanceState) {
  52. super.onCreate(savedInstanceState);
  53. NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject (this);
  54. requestWindowFeature(Window.FEATURE_NO_TITLE);
  55. getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN |
  56. WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
  57. WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
  58. WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
  59. getWindow().getDecorView().setSystemUiVisibility(getSystemUiVisibility());
  60. setContentView(R.layout.activity_magic_call);
  61. ButterKnife.bind(this);
  62. router = Conductor.attachRouter(this, container, savedInstanceState);
  63. router.setPopsLastView(true);
  64. if (!router.hasRootController()) {
  65. if (getIntent().getBooleanExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, false)) {
  66. router.setRoot(RouterTransaction.with(new CallNotificationController(getIntent().getExtras()))
  67. .pushChangeHandler(new HorizontalChangeHandler())
  68. .popChangeHandler(new HorizontalChangeHandler()));
  69. } else {
  70. router.setRoot(RouterTransaction.with(new CallController(getIntent().getExtras()))
  71. .pushChangeHandler(new HorizontalChangeHandler())
  72. .popChangeHandler(new HorizontalChangeHandler()));
  73. }
  74. }
  75. }
  76. @Override
  77. public void onBackPressed() {
  78. finish();
  79. }
  80. }