1
1
package home .smart .fly .animations .ui .activity ;
2
2
3
3
import android .annotation .SuppressLint ;
4
+
4
5
import androidx .appcompat .app .ActionBar ;
5
6
import androidx .appcompat .app .AppCompatActivity ;
7
+
8
+ import android .graphics .Color ;
9
+ import android .os .Build ;
6
10
import android .os .Bundle ;
7
11
import android .os .Handler ;
12
+ import android .util .Log ;
8
13
import android .view .MotionEvent ;
9
14
import android .view .View ;
15
+ import android .view .WindowManager ;
10
16
import android .widget .ImageView ;
11
17
12
18
import home .smart .fly .animations .R ;
17
23
* status bar and navigation/system bar) with user interaction.
18
24
*/
19
25
public class FullscreenADActivity extends SimpleBaseActivity {
26
+ private static final String TAG = "FullscreenADActivity" ;
20
27
/**
21
28
* Whether or not the system UI should be auto-hidden after
22
29
* {@link #AUTO_HIDE_DELAY_MILLIS} milliseconds.
@@ -40,23 +47,26 @@ public class FullscreenADActivity extends SimpleBaseActivity {
40
47
@ SuppressLint ("InlinedApi" )
41
48
@ Override
42
49
public void run () {
50
+ Log .d (TAG , "mHidePart2Runnable run() called" );
43
51
// Delayed removal of status and navigation bar
44
52
45
53
// Note that some of these constants are new as of API 16 (Jelly Bean)
46
54
// and API 19 (KitKat). It is safe to use them, as they are inlined
47
55
// at compile-time and do nothing on earlier devices.
48
- mContentView .setSystemUiVisibility (View .SYSTEM_UI_FLAG_LOW_PROFILE
49
- | View .SYSTEM_UI_FLAG_FULLSCREEN
50
- | View .SYSTEM_UI_FLAG_LAYOUT_STABLE
51
- | View .SYSTEM_UI_FLAG_IMMERSIVE_STICKY
52
- | View .SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
53
- | View .SYSTEM_UI_FLAG_HIDE_NAVIGATION );
56
+ mContentView .setSystemUiVisibility (
57
+ View .SYSTEM_UI_FLAG_LOW_PROFILE
58
+ | View .SYSTEM_UI_FLAG_FULLSCREEN
59
+ | View .SYSTEM_UI_FLAG_LAYOUT_STABLE
60
+ | View .SYSTEM_UI_FLAG_IMMERSIVE_STICKY
61
+ | View .SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
62
+ | View .SYSTEM_UI_FLAG_HIDE_NAVIGATION );
54
63
}
55
64
};
56
65
private View mControlsView ;
57
66
private final Runnable mShowPart2Runnable = new Runnable () {
58
67
@ Override
59
68
public void run () {
69
+ Log .d (TAG , "mShowPart2Runnable run() called" );
60
70
// Delayed display of UI elements
61
71
ActionBar actionBar = getSupportActionBar ();
62
72
if (actionBar != null ) {
@@ -72,27 +82,13 @@ public void run() {
72
82
hide ();
73
83
}
74
84
};
75
- /**
76
- * Touch listener to use for in-layout UI controls to delay hiding the
77
- * system UI. This is to prevent the jarring behavior of controls going away
78
- * while interacting with activity UI.
79
- */
80
- private final View .OnTouchListener mDelayHideTouchListener = new View .OnTouchListener () {
81
- @ Override
82
- public boolean onTouch (View view , MotionEvent motionEvent ) {
83
- if (AUTO_HIDE ) {
84
- delayedHide (AUTO_HIDE_DELAY_MILLIS );
85
- }
86
- return false ;
87
- }
88
- };
89
85
90
86
@ Override
91
87
protected void onCreate (Bundle savedInstanceState ) {
92
88
super .onCreate (savedInstanceState );
93
89
94
90
setContentView (R .layout .activity_fullscreen_ad );
95
- int resId = getIntent ().getIntExtra ("url" ,R .drawable .girl );
91
+ int resId = getIntent ().getIntExtra ("url" , R .drawable .girl );
96
92
mVisible = true ;
97
93
mControlsView = findViewById (R .id .fullscreen_content_controls );
98
94
mContentView = findViewById (R .id .fullscreen_content );
@@ -108,7 +104,13 @@ public void onClick(View view) {
108
104
// Upon interacting with UI controls, delay any scheduled hide()
109
105
// operations to prevent the jarring behavior of controls going away
110
106
// while interacting with the UI.
111
- findViewById (R .id .dummy_button ).setOnTouchListener (mDelayHideTouchListener );
107
+
108
+ getWindow ().setStatusBarColor (Color .TRANSPARENT );
109
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .P ) {
110
+ WindowManager .LayoutParams params = getWindow ().getAttributes ();
111
+ params .layoutInDisplayCutoutMode = WindowManager .LayoutParams .LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES ;
112
+ getWindow ().setAttributes (params );
113
+ }
112
114
}
113
115
114
116
@ Override
@@ -130,6 +132,7 @@ private void toggle() {
130
132
}
131
133
132
134
private void hide () {
135
+ Log .d (TAG , "hide() called" );
133
136
// Hide UI first
134
137
ActionBar actionBar = getSupportActionBar ();
135
138
if (actionBar != null ) {
@@ -145,9 +148,9 @@ private void hide() {
145
148
146
149
@ SuppressLint ("InlinedApi" )
147
150
private void show () {
151
+ Log .d (TAG , "show() called" );
148
152
// Show the system bar
149
- mContentView .setSystemUiVisibility (View .SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
150
- | View .SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION );
153
+ mContentView .setSystemUiVisibility (View .SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View .SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION );
151
154
mVisible = true ;
152
155
153
156
// Schedule a runnable to display UI elements after a delay
0 commit comments