MagicCallActivity.java 3.9 KB

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