170 {
171 super.onCreate(savedInstanceState);
172
173 hideSystemBars();
174
175 this.setContentView(R.layout.session);
176
177 Log.v(TAG, "Session.onCreate");
178
179
180
181
182
183
184
185
186 final View activityRootView = findViewById(R.id.session_root_view);
187 activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(
188 new OnGlobalLayoutListener() {
189 @Override public void onGlobalLayout()
190 {
191 screen_width = activityRootView.getWidth();
192 screen_height = activityRootView.getHeight();
193
194
195 if (!sessionRunning && getIntent() != null)
196 {
197 processIntent(getIntent());
198 sessionRunning = true;
199 }
200 }
201 });
202
203 sessionView = findViewById(R.id.sessionView);
204 sessionView.requestFocus();
205
206 touchPointerView = findViewById(R.id.touchPointerView);
207
208 KeyboardView keyboardView = findViewById(R.id.extended_keyboard);
209 KeyboardView modifiersKeyboardView = findViewById(R.id.extended_keyboard_header);
210
211 scrollView = findViewById(R.id.sessionScrollView);
212 sessionViewModel = new ViewModelProvider(this).get(SessionViewModel.class);
213 sessionViewModel.getState().observe(this, this::onConnectionStateChanged);
214
215 dialogs = new SessionDialogs(this, new SessionDialogs.OnUserCancelListener() {
216 @Override public void onUserCancel()
217 {
218 connectCancelledByUser = true;
219 }
220 });
221
222
223 inputManager = new SessionInputManager(this, scrollView, sessionView, touchPointerView,
224 keyboardView, modifiersKeyboardView);
225 sessionView.setSessionViewListener(inputManager);
226 touchPointerView.setTouchPointerListener(inputManager);
227 sessionView.setScaleGestureDetector(
228 new ScaleGestureDetector(this, inputManager.getPinchZoomListener()));
229
230 mClipboardManager = ClipboardManagerProxy.getClipboardManager(this);
231 mClipboardManager.addClipboardChangedListener(this);
232
233 getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
234 @Override public void handleOnBackPressed()
235 {
236 handleBackPressed();
237 }
238 });
239
240 hideSystemBars();
241 }