MagicCallActivity.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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.content.res.Configuration;
  22. import android.os.Bundle;
  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.events.ConfigurationChangeEvent;
  36. import com.nextcloud.talk.utils.bundle.BundleKeys;
  37. import org.greenrobot.eventbus.EventBus;
  38. import javax.inject.Inject;
  39. import autodagger.AutoInjector;
  40. import butterknife.BindView;
  41. import butterknife.ButterKnife;
  42. @AutoInjector(NextcloudTalkApplication.class)
  43. public class MagicCallActivity extends BaseActivity {
  44. private static final String TAG = "MagicCallActivity";
  45. @Inject
  46. EventBus eventBus;
  47. @BindView(R.id.controller_container)
  48. ViewGroup container;
  49. private Router router;
  50. private static int getSystemUiVisibility() {
  51. int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
  52. flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
  53. return flags;
  54. }
  55. @Override
  56. protected void onCreate(Bundle savedInstanceState) {
  57. super.onCreate(savedInstanceState);
  58. NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
  59. requestWindowFeature(Window.FEATURE_NO_TITLE);
  60. getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN |
  61. WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
  62. WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
  63. WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
  64. getWindow().getDecorView().setSystemUiVisibility(getSystemUiVisibility());
  65. setContentView(R.layout.activity_magic_call);
  66. ButterKnife.bind(this);
  67. router = Conductor.attachRouter(this, container, savedInstanceState);
  68. router.setPopsLastView(true);
  69. if (!router.hasRootController()) {
  70. if (getIntent().getBooleanExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, false)) {
  71. router.setRoot(RouterTransaction.with(new CallNotificationController(getIntent().getExtras()))
  72. .pushChangeHandler(new HorizontalChangeHandler())
  73. .popChangeHandler(new HorizontalChangeHandler()));
  74. } else {
  75. router.setRoot(RouterTransaction.with(new CallController(getIntent().getExtras()))
  76. .pushChangeHandler(new HorizontalChangeHandler())
  77. .popChangeHandler(new HorizontalChangeHandler()));
  78. }
  79. }
  80. }
  81. @Override
  82. public void onConfigurationChanged(Configuration newConfig) {
  83. super.onConfigurationChanged(newConfig);
  84. eventBus.post(new ConfigurationChangeEvent());
  85. }
  86. }