-
Notifications
You must be signed in to change notification settings - Fork 215
/
WindowWidget.java
724 lines (608 loc) · 23.6 KB
/
WindowWidget.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.vrbrowser.ui.widgets;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import org.mozilla.geckoview.AllowOrDeny;
import org.mozilla.geckoview.GeckoDisplay;
import org.mozilla.geckoview.GeckoResult;
import org.mozilla.geckoview.GeckoSession;
import org.mozilla.geckoview.GeckoSessionSettings;
import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.browser.SessionStore;
import org.mozilla.vrbrowser.browser.SettingsStore;
import org.mozilla.vrbrowser.ui.views.BookmarksView;
import org.mozilla.vrbrowser.ui.widgets.prompts.AlertPromptWidget;
import org.mozilla.vrbrowser.ui.widgets.prompts.ChoicePromptWidget;
import org.mozilla.vrbrowser.ui.widgets.prompts.ConfirmPromptWidget;
import org.mozilla.vrbrowser.ui.widgets.prompts.TextPromptWidget;
public class WindowWidget extends UIWidget implements SessionStore.SessionChangeListener,
GeckoSession.ContentDelegate, GeckoSession.PromptDelegate, TrayListener, BookmarkListener {
private static final String LOGTAG = "VRB";
private int mSessionId;
private GeckoDisplay mDisplay;
private Surface mSurface;
private int mWidth;
private int mHeight;
private int mHandle;
private WidgetPlacement mWidgetPlacement;
private WidgetManagerDelegate mWidgetManager;
private ChoicePromptWidget mChoicePrompt;
private AlertPromptWidget mAlertPrompt;
private ConfirmPromptWidget mConfirmPrompt;
private TextPromptWidget mTextPrompt;
private int mWidthBackup;
private int mHeightBackup;
private int mBorderWidth;
Runnable mFirstDrawCallback;
private boolean mIsInVRVideoMode;
private boolean mSaveResizeChanges;
private View mView;
private BookmarksView mBookmarksView;
public WindowWidget(Context aContext, int aSessionId) {
super(aContext);
mSessionId = aSessionId;
mWidgetManager = (WidgetManagerDelegate) aContext;
mBorderWidth = SettingsStore.getInstance(aContext).getTransparentBorderWidth();
SessionStore.get().addSessionChangeListener(this);
SessionStore.get().addPromptListener(this);
SessionStore.get().addContentListener(this);
setFocusable(true);
GeckoSession session = SessionStore.get().getSession(mSessionId);
if (session != null) {
session.getTextInput().setView(this);
}
mHandle = ((WidgetManagerDelegate)aContext).newWidgetHandle();
mWidgetPlacement = new WidgetPlacement(aContext);
initializeWidgetPlacement(mWidgetPlacement);
handleResizeEvent(SettingsStore.getInstance(getContext()).getBrowserWorldWidth(),
SettingsStore.getInstance(getContext()).getBrowserWorldHeight());
mSaveResizeChanges = true;
}
@Override
protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {
Context context = getContext();
aPlacement.width = SettingsStore.getInstance(getContext()).getWindowWidth() + mBorderWidth * 2;
aPlacement.height = SettingsStore.getInstance(getContext()).getWindowHeight() + mBorderWidth * 2;
aPlacement.density = 1.0f;
aPlacement.translationX = 0.0f;
aPlacement.translationY = WidgetPlacement.unitFromMeters(context, R.dimen.window_world_y);
aPlacement.translationZ = WidgetPlacement.unitFromMeters(context, R.dimen.window_world_z);
aPlacement.anchorX = 0.5f;
aPlacement.anchorY = 0.0f;
aPlacement.visible = true;
aPlacement.cylinder = true;
}
@Override
public void show(boolean focus) {
if (!mWidgetPlacement.visible) {
mWidgetPlacement.visible = true;
}
mWidgetManager.updateWidget(this);
if (focus) {
setFocusableInTouchMode(true);
requestFocusFromTouch();
}
}
@Override
public void hide(@HideFlags int aHideFlag) {
if (mWidgetPlacement.visible) {
mWidgetPlacement.visible = false;
}
mWidgetManager.updateWidget(this);
clearFocus();
}
@Override
protected void onDismiss() {
if (mView != null) {
if (SessionStore.get().canGoBack()) {
SessionStore.get().goBack();
} else if (SessionStore.get().canUnstackSession()) {
SessionStore.get().unstackSession();
}
unsetView(mView);
}
}
public void setBookmarksView(BookmarksView view) {
mBookmarksView = view;
}
public void setView(View view) {
pauseCompositor();
mView = view;
removeView(view);
mView.setVisibility(VISIBLE);
addView(mView);
mWidgetPlacement.density = getContext().getResources().getDisplayMetrics().density;
if (mTexture != null && mSurface != null && mRenderer == null) {
// Create the UI Renderer for the current surface.
// Surface must be released when switching back to WebView surface or the browser
// will not render it correctly. See release code in unsetView().
mRenderer = new UISurfaceTextureRenderer(mSurface, mWidgetPlacement.textureWidth(), mWidgetPlacement.textureHeight());
}
mWidgetManager.updateWidget(this);
mWidgetManager.pushWorldBrightness(this, WidgetManagerDelegate.DEFAULT_DIM_BRIGHTNESS);
mWidgetManager.pushBackHandler(mBackHandler);
setWillNotDraw(false);
postInvalidate();
}
public void unsetView(View view) {
if (mView != null && mView == view) {
mView = null;
removeView(view);
view.setVisibility(GONE);
setWillNotDraw(true);
if (mTexture != null) {
// Surface must be recreated here when not using layers.
// When using layers the new Surface is received via the setSurface() method.
if (mRenderer != null) {
mRenderer.release();
mRenderer = null;
}
mSurface = new Surface(mTexture);
}
mWidgetPlacement.density = 1.0f;
mWidgetManager.updateWidget(this);
mWidgetManager.popWorldBrightness(this);
mWidgetManager.popBackHandler(mBackHandler);
}
}
public void pauseCompositor() {
if (mDisplay == null) {
return;
}
mDisplay.surfaceDestroyed();
}
public void resumeCompositor() {
if (mDisplay == null) {
return;
}
if (mSurface == null) {
return;
}
callSurfaceChanged();
}
public void enableVRVideoMode(int aVideoWidth, int aVideoHeight, boolean aResetBorder) {
if (!mIsInVRVideoMode) {
mWidthBackup = mWidth;
mHeightBackup = mHeight;
mIsInVRVideoMode = true;
}
boolean borderChanged = aResetBorder && mBorderWidth > 0;
if (aVideoWidth == mWidth && aVideoHeight == mHeight && !borderChanged) {
return;
}
if (aResetBorder) {
mBorderWidth = 0;
}
mWidgetPlacement.width = aVideoWidth + mBorderWidth * 2;
mWidgetPlacement.height = aVideoHeight + mBorderWidth * 2;
mWidgetManager.updateWidget(this);
}
public void disableVRVideoMode() {
if (!mIsInVRVideoMode || mWidthBackup == 0 || mHeightBackup == 0) {
return;
}
mIsInVRVideoMode = false;
int border = SettingsStore.getInstance(getContext()).getTransparentBorderWidth();
if (mWidthBackup == mWidth && mHeightBackup == mHeight && border == mBorderWidth) {
return;
}
mBorderWidth = border;
mWidgetPlacement.width = mWidthBackup;
mWidgetPlacement.height = mHeightBackup;
mWidgetManager.updateWidget(this);
}
@Override
public void resizeByMultiplier(float aspect, float multiplier) {
float worldWidth = WidgetPlacement.floatDimension(getContext(), R.dimen.window_world_width);
float worldHeight = worldWidth / aspect;
float area = worldWidth * worldHeight * multiplier;
float targetWidth = (float) Math.sqrt(area * aspect);
float targetHeight = (float) Math.sqrt(area / aspect);
handleResizeEvent(targetWidth, targetHeight);
}
public int getBorderWidth() {
return mBorderWidth;
}
public void setSaveResizeChanges(boolean aSave) {
mSaveResizeChanges = aSave;
}
@Override
public void setSurfaceTexture(SurfaceTexture aTexture, final int aWidth, final int aHeight) {
if (mView != null) {
super.setSurfaceTexture(aTexture, aWidth, aHeight);
} else {
GeckoSession session = SessionStore.get().getSession(mSessionId);
if (session == null) {
return;
}
if (aTexture == null) {
setWillNotDraw(true);
return;
}
mWidth = aWidth;
mHeight = aHeight;
mTexture = aTexture;
aTexture.setDefaultBufferSize(aWidth, aHeight);
mSurface = new Surface(aTexture);
if (mDisplay == null) {
mDisplay = session.acquireDisplay();
} else {
Log.e(LOGTAG, "GeckoDisplay was not null in BrowserWidget.setSurfaceTexture()");
}
callSurfaceChanged();
}
}
@Override
public void setSurface(Surface aSurface, final int aWidth, final int aHeight, Runnable aFirstDrawCallback) {
if (mView != null) {
super.setSurface(aSurface, aWidth, aHeight, aFirstDrawCallback);
} else {
GeckoSession session = SessionStore.get().getSession(mSessionId);
if (session == null) {
return;
}
mWidth = aWidth;
mHeight = aHeight;
mSurface = aSurface;
mFirstDrawCallback = aFirstDrawCallback;
if (mDisplay == null) {
mDisplay = session.acquireDisplay();
} else {
Log.e(LOGTAG, "GeckoDisplay was not null in BrowserWidget.setSurfaceTexture()");
}
if (mSurface != null) {
callSurfaceChanged();
} else {
mDisplay.surfaceDestroyed();
}
}
}
private void callSurfaceChanged() {
mDisplay.surfaceChanged(mSurface, mBorderWidth, mBorderWidth, mWidth - mBorderWidth * 2, mHeight - mBorderWidth * 2);
}
@Override
public void resizeSurface(final int aWidth, final int aHeight) {
if (mView != null) {
super.resizeSurface(aWidth, aHeight);
}
mWidth = aWidth;
mHeight = aHeight;
if (mTexture != null) {
mTexture.setDefaultBufferSize(aWidth, aHeight);
}
if (mSurface != null && mView == null) {
callSurfaceChanged();
}
}
@Override
public int getHandle() {
return mHandle;
}
@Override
public WidgetPlacement getPlacement() {
return mWidgetPlacement;
}
@Override
public void handleTouchEvent(MotionEvent aEvent) {
if (mView != null) {
super.handleTouchEvent(aEvent);
} else {
if (aEvent.getActionMasked() == MotionEvent.ACTION_UP) {
requestFocus();
requestFocusFromTouch();
}
GeckoSession session = SessionStore.get().getSession(mSessionId);
if (session == null) {
return;
}
session.getPanZoomController().onTouchEvent(aEvent);
}
}
@Override
public void handleHoverEvent(MotionEvent aEvent) {
if (mView != null) {
super.handleHoverEvent(aEvent);
} else {
GeckoSession session = SessionStore.get().getSession(mSessionId);
if (session == null) {
return;
}
session.getPanZoomController().onMotionEvent(aEvent);
}
}
@Override
public void handleResizeEvent(float aWorldWidth, float aWorldHeight) {
float worldWidth = WidgetPlacement.floatDimension(getContext(), R.dimen.window_world_width);
int defaultWidth = SettingsStore.getInstance(getContext()).getWindowWidth();
int defaultHeight = SettingsStore.getInstance(getContext()).getWindowHeight();
float aspect = (float) defaultWidth / (float) defaultHeight;
float worldHeight = worldWidth / aspect;
mWidgetPlacement.width = (int) ((aWorldWidth * defaultWidth) / worldWidth) + mBorderWidth * 2;
mWidgetPlacement.height = (int) ((aWorldHeight * defaultHeight) / worldHeight) + mBorderWidth * 2;
mWidgetPlacement.worldWidth = aWorldWidth;
mWidgetManager.updateWidget(this);
if (mSaveResizeChanges) {
SettingsStore.getInstance(getContext()).setBrowserWorldWidth(aWorldWidth);
SettingsStore.getInstance(getContext()).setBrowserWorldHeight(aWorldHeight);
}
}
@Override
public void releaseWidget() {
SessionStore.get().removeSessionChangeListener(this);
SessionStore.get().removePromptListener(this);
SessionStore.get().removeContentListener(this);
GeckoSession session = SessionStore.get().getSession(mSessionId);
if (session == null) {
return;
}
if (mDisplay != null) {
mDisplay.surfaceDestroyed();
session.releaseDisplay(mDisplay);
mDisplay = null;
}
session.getTextInput().setView(null);
}
@Override
public void setFirstDraw(final boolean aIsFirstDraw) {
mWidgetPlacement.firstDraw = aIsFirstDraw;
}
@Override
public boolean getFirstDraw() {
return mWidgetPlacement.firstDraw;
}
@Override
public boolean isVisible() {
return mWidgetPlacement.visible;
}
@Override
public void setVisible(boolean aVisible) {
if (mWidgetPlacement.visible == aVisible) {
return;
}
mWidgetPlacement.visible = aVisible;
mWidgetManager.updateWidget(this);
if (!aVisible) {
clearFocus();
}
}
@Override
public void draw(Canvas aCanvas) {
if (mView != null) {
super.draw(aCanvas);
}
}
// SessionStore.GeckoSessionChange
@Override
public void onNewSession(GeckoSession aSession, int aId) {
}
@Override
public void onRemoveSession(GeckoSession aSession, int aId) {
}
@Override
public void onCurrentSessionChange(GeckoSession aSession, int aId) {
Log.d(LOGTAG, "onCurrentSessionChange: " + this.toString());
if (mSessionId == aId) {
Log.d(LOGTAG, "BrowserWidget.onCurrentSessionChange session id same, bail: " + aId);
return;
}
GeckoSession oldSession = SessionStore.get().getSession(mSessionId);
if (oldSession != null && mDisplay != null) {
Log.d(LOGTAG, "Detach from previous session: " + mSessionId);
oldSession.getTextInput().setView(null);
mDisplay.surfaceDestroyed();
oldSession.releaseDisplay(mDisplay);
mDisplay = null;
}
mSessionId = aId;
mDisplay = aSession.acquireDisplay();
Log.d(LOGTAG, "surfaceChanged: " + aId);
callSurfaceChanged();
aSession.getTextInput().setView(this);
boolean isPrivateMode = aSession.getSettings().getBoolean(GeckoSessionSettings.USE_PRIVATE_MODE);
if (isPrivateMode)
setPrivateBrowsingEnabled(true);
else
setPrivateBrowsingEnabled(false);
}
// View
@Override
public InputConnection onCreateInputConnection(final EditorInfo outAttrs) {
Log.d(LOGTAG, "BrowserWidget onCreateInputConnection");
GeckoSession session = SessionStore.get().getSession(mSessionId);
if (session == null) {
return null;
}
return session.getTextInput().onCreateInputConnection(outAttrs);
}
@Override
public boolean onCheckIsTextEditor() {
return SessionStore.get().isInputActive(mSessionId);
}
@Override
public boolean onKeyPreIme(int aKeyCode, KeyEvent aEvent) {
if (super.onKeyPreIme(aKeyCode, aEvent)) {
return true;
}
GeckoSession session = SessionStore.get().getSession(mSessionId);
return (session != null) && session.getTextInput().onKeyPreIme(aKeyCode, aEvent);
}
@Override
public boolean onKeyUp(int aKeyCode, KeyEvent aEvent) {
if (super.onKeyUp(aKeyCode, aEvent)) {
return true;
}
GeckoSession session = SessionStore.get().getSession(mSessionId);
return (session != null) && session.getTextInput().onKeyUp(aKeyCode, aEvent);
}
@Override
public boolean onKeyDown(int aKeyCode, KeyEvent aEvent) {
if (super.onKeyDown(aKeyCode, aEvent)) {
return true;
}
GeckoSession session = SessionStore.get().getSession(mSessionId);
return (session != null) && session.getTextInput().onKeyDown(aKeyCode, aEvent);
}
@Override
public boolean onKeyLongPress(int aKeyCode, KeyEvent aEvent) {
if (super.onKeyLongPress(aKeyCode, aEvent)) {
return true;
}
GeckoSession session = SessionStore.get().getSession(mSessionId);
return (session != null) && session.getTextInput().onKeyLongPress(aKeyCode, aEvent);
}
@Override
public boolean onKeyMultiple(int aKeyCode, int repeatCount, KeyEvent aEvent) {
if (super.onKeyMultiple(aKeyCode, repeatCount, aEvent)) {
return true;
}
GeckoSession session = SessionStore.get().getSession(mSessionId);
return (session != null) && session.getTextInput().onKeyMultiple(aKeyCode, repeatCount, aEvent);
}
@Override
protected void onFocusChanged(boolean aGainFocus, int aDirection, Rect aPreviouslyFocusedRect) {
super.onFocusChanged(aGainFocus, aDirection, aPreviouslyFocusedRect);
Log.d(LOGTAG, "BrowserWidget onFocusChanged: " + (aGainFocus ? "true" : "false"));
}
@Override
public boolean onTouchEvent(MotionEvent aEvent) {
GeckoSession session = SessionStore.get().getSession(mSessionId);
return (session != null) && session.getPanZoomController().onTouchEvent(aEvent);
}
@Override
public boolean onGenericMotionEvent(MotionEvent aEvent) {
GeckoSession session = SessionStore.get().getSession(mSessionId);
return (session != null) && session.getPanZoomController().onMotionEvent(aEvent);
}
private void setPrivateBrowsingEnabled(boolean isEnabled) {
// TODO: Fade in/out the browser window. Waiting for https://github.com/MozillaReality/FirefoxReality/issues/77
}
// PromptDelegate
@Override
public void onAlert(GeckoSession session, String title, String msg, AlertCallback callback) {
mAlertPrompt = new AlertPromptWidget(getContext());
mAlertPrompt.mWidgetPlacement.parentHandle = getHandle();
mAlertPrompt.setTitle(title);
mAlertPrompt.setMessage(msg);
mAlertPrompt.setDelegate(callback);
mAlertPrompt.show();
}
@Override
public void onButtonPrompt(GeckoSession session, String title, String msg, String[] btnMsg, ButtonCallback callback) {
mConfirmPrompt = new ConfirmPromptWidget(getContext());
mConfirmPrompt.mWidgetPlacement.parentHandle = getHandle();
mConfirmPrompt.setTitle(title);
mConfirmPrompt.setMessage(msg);
mConfirmPrompt.setButtons(btnMsg);
mConfirmPrompt.setDelegate(callback);
mConfirmPrompt.show();
}
@Override
public void onTextPrompt(GeckoSession session, String title, String msg, String value, TextCallback callback) {
mTextPrompt = new TextPromptWidget(getContext());
mTextPrompt.mWidgetPlacement.parentHandle = getHandle();
mTextPrompt.setTitle(title);
mTextPrompt.setMessage(msg);
mTextPrompt.setDefaultText(value);
mTextPrompt.setDelegate(callback);
mTextPrompt.show();
}
@Override
public void onAuthPrompt(GeckoSession session, String title, String msg, AuthOptions options, AuthCallback callback) {
}
@Override
public void onChoicePrompt(GeckoSession session, String title, String msg, int type, final Choice[] choices, final ChoiceCallback callback) {
mChoicePrompt = new ChoicePromptWidget(getContext());
mChoicePrompt.mWidgetPlacement.parentHandle = getHandle();
mChoicePrompt.setTitle(title);
mChoicePrompt.setMessage(msg);
mChoicePrompt.setChoices(choices);
mChoicePrompt.setMenuType(type);
mChoicePrompt.setDelegate(callback);
mChoicePrompt.show();
}
@Override
public void onColorPrompt(GeckoSession session, String title, String value, TextCallback callback) {
}
@Override
public void onDateTimePrompt(GeckoSession session, String title, int type, String value, String min, String max, TextCallback callback) {
}
@Override
public void onFilePrompt(GeckoSession session, String title, int type, String[] mimeTypes, FileCallback callback) {
}
@Override
public GeckoResult<AllowOrDeny> onPopupRequest(final GeckoSession session, final String targetUri) {
return GeckoResult.fromValue(AllowOrDeny.ALLOW);
}
// BookmarkListener
@Override
public void onBookmarksShown() {
}
@Override
public void onBookmarksHidden() {
unsetView(mBookmarksView);
}
// TrayListener
@Override
public void onBookmarksClicked() {
if (mBookmarksView.getVisibility() == View.VISIBLE) {
unsetView(mBookmarksView);
SessionStore.get().unstackSession();
} else {
int sessionId;
if (SessionStore.get().isCurrentSessionPrivate()) {
sessionId = SessionStore.get().createSession(true);
} else {
sessionId = SessionStore.get().createSession();
}
SessionStore.get().stackSession(sessionId);
setView(mBookmarksView);
}
}
@Override
public void onPrivateBrowsingClicked() {
if (mBookmarksView.getVisibility() == VISIBLE) {
SessionStore.get().unstackSession();
}
}
// GeckoSession.ContentDelegate
@Override
public void onTitleChange(GeckoSession session, String title) {
}
@Override
public void onFocusRequest(GeckoSession session) {
}
@Override
public void onCloseRequest(GeckoSession session) {
}
@Override
public void onFullScreen(GeckoSession session, boolean fullScreen) {
}
@Override
public void onContextMenu(GeckoSession session, int screenX, int screenY, ContextElement element) {
}
@Override
public void onExternalResponse(GeckoSession session, GeckoSession.WebResponseInfo response) {
}
@Override
public void onCrash(GeckoSession session) {
}
@Override
public void onFirstComposite(GeckoSession session) {
if (mFirstDrawCallback != null) {
mFirstDrawCallback.run();
mFirstDrawCallback = null;
}
}
}