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