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