201 {
202 super.onCreate(savedInstanceState);
203
204 hideSystemBars();
205
206 this.setContentView(R.layout.session);
207
208 Log.v(TAG, "Session.onCreate");
209
210
211
212
213
214
215
216
217 final View activityRootView = findViewById(R.id.session_root_view);
218 activityRootView.setFitsSystemWindows(false);
219 ViewCompat.setOnApplyWindowInsetsListener(activityRootView,
220 (v, insets) -> onWindowInsetsChanged(v, insets));
221 activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(
222 new OnGlobalLayoutListener() {
223 @Override public void onGlobalLayout()
224 {
225 screen_width = scrollView.getWidth() - scrollView.getPaddingLeft() -
226 scrollView.getPaddingRight();
227 screen_height = scrollView.getHeight() - scrollView.getPaddingTop() -
228 scrollView.getPaddingBottom();
229
230
231 if (!sessionRunning && getIntent() != null)
232 {
233 processIntent(getIntent());
234 sessionRunning = true;
235 }
236 }
237 });
238
239 sessionView = findViewById(R.id.sessionView);
240 sessionView.requestFocus();
241
242 touchPointerView = findViewById(R.id.touchPointerView);
243
244 floatingToolbar = new FloatingToolbar(this, new FloatingToolbar.Listener() {
245 @Override public void onToggleTouchPointer()
246 {
247 if (inputManager != null)
248 inputManager.toggleTouchPointer();
249 }
250 @Override public void onToggleSysKeyboard()
251 {
252 if (inputManager != null)
253 inputManager.toggleSystemKeyboard();
254 }
255 @Override public void onToggleExtKeyboard()
256 {
257 if (inputManager != null)
258 inputManager.toggleExtendedKeyboard();
259 }
260 });
261
262 KeyboardView keyboardView = findViewById(R.id.extended_keyboard);
263 KeyboardView modifiersKeyboardView = findViewById(R.id.extended_keyboard_header);
264
265 scrollView = findViewById(R.id.sessionScrollView);
266 sessionViewModel = new ViewModelProvider(this).get(SessionViewModel.class);
267 sessionViewModel.getState().observe(this, this::onConnectionStateChanged);
268
269 dialogs = new SessionDialogs(this, new SessionDialogs.OnUserCancelListener() {
270 @Override public void onUserCancel()
271 {
272 connectCancelledByUser = true;
273 }
274 });
275
276
277 inputManager = new SessionInputManager(this, scrollView, sessionView, touchPointerView,
278 keyboardView, modifiersKeyboardView);
279 sessionView.setSessionViewListener(inputManager);
280 touchPointerView.setTouchPointerListener(inputManager);
281 sessionView.setScaleGestureDetector(
282 new ScaleGestureDetector(this, inputManager.getPinchZoomListener()));
283
284 mClipboardManager = ClipboardManagerProxy.getClipboardManager(this);
285 mClipboardManager.addClipboardChangedListener(this);
286
287 getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
288 @Override public void handleOnBackPressed()
289 {
290 handleBackPressed();
291 }
292 });
293
294 hideSystemBars();
295 }