-
Notifications
You must be signed in to change notification settings - Fork 215
/
PlatformActivity.java
90 lines (75 loc) · 2.78 KB
/
PlatformActivity.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
/* -*- 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;
import android.app.NativeActivity;
import android.Manifest;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import org.mozilla.vrbrowser.browser.SettingsStore;
import org.mozilla.vrbrowser.utils.SystemUtils;
public class PlatformActivity extends NativeActivity {
static String LOGTAG = SystemUtils.createLogtag(PlatformActivity.class);
public static boolean filterPermission(final String aPermission) {
if (aPermission.equals(Manifest.permission.CAMERA)) {
return true;
}
return false;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.e(LOGTAG,"in onCreate");
super.onCreate(savedInstanceState);
//getWindow().takeInputQueue(null);
// Keep the screen on
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
// Set up full screen
addFullScreenListener();
}
@Override
public void onBackPressed() {
queueRunnable(new Runnable() {
@Override
public void run() {
platformExit();
}
});
}
@Override
protected void onResume() {
setFullScreen();
super.onResume();
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
setFullScreen();
}
}
protected void setFullScreen() {
int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
getWindow().getDecorView().setSystemUiVisibility(flags);
}
private void addFullScreenListener() {
View decorView = getWindow().getDecorView();
decorView.setOnSystemUiVisibilityChangeListener(
new View.OnSystemUiVisibilityChangeListener() {
public void onSystemUiVisibilityChange(int visibility) {
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
setFullScreen();
}
}
});
}
protected native void queueRunnable(Runnable aRunnable);
protected native boolean platformExit();
}