Revision 0254cfd7
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/main/RubikActivity.java | ||
---|---|---|
27 | 27 |
import androidx.appcompat.app.AppCompatActivity; |
28 | 28 |
|
29 | 29 |
import android.util.DisplayMetrics; |
30 |
import android.view.View; |
|
30 | 31 |
|
31 | 32 |
import com.google.firebase.analytics.FirebaseAnalytics; |
32 | 33 |
|
... | ... | |
68 | 69 |
private FirebaseAnalytics mFirebaseAnalytics; |
69 | 70 |
private static int mScreenWidth, mScreenHeight; |
70 | 71 |
private boolean mPolicyAccepted, mIsChinese; |
72 |
private int mCurrentApiVersion; |
|
71 | 73 |
|
72 | 74 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
73 | 75 |
|
... | ... | |
87 | 89 |
mScreenHeight=displaymetrics.heightPixels; |
88 | 90 |
|
89 | 91 |
mIsChinese = localeIsChinese(); |
90 |
/* |
|
92 |
|
|
93 |
hideNavigationBar(); |
|
94 |
|
|
95 |
// askForPermissions(); |
|
96 |
} |
|
97 |
|
|
98 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
99 |
|
|
100 |
private void hideNavigationBar() |
|
101 |
{ |
|
102 |
mCurrentApiVersion = android.os.Build.VERSION.SDK_INT; |
|
103 |
|
|
104 |
final int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
105 |
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
106 |
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
107 |
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
|
108 |
| View.SYSTEM_UI_FLAG_FULLSCREEN |
|
109 |
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; |
|
110 |
|
|
111 |
// This work only for android 4.4+ |
|
112 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT) |
|
113 |
{ |
|
114 |
getWindow().getDecorView().setSystemUiVisibility(flags); |
|
115 |
|
|
116 |
// Code below is to handle presses of Volume up or Volume down. |
|
117 |
// Without this, after pressing volume buttons, the navigation bar will |
|
118 |
// show up and won't hide |
|
119 |
final View decorView = getWindow().getDecorView(); |
|
120 |
|
|
121 |
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() |
|
122 |
{ |
|
123 |
@Override |
|
124 |
public void onSystemUiVisibilityChange(int visibility) |
|
125 |
{ |
|
126 |
if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) |
|
127 |
{ |
|
128 |
decorView.setSystemUiVisibility(flags); |
|
129 |
} |
|
130 |
} |
|
131 |
}); |
|
132 |
} |
|
133 |
} |
|
134 |
|
|
135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
136 |
|
|
137 |
@Override |
|
138 |
public void onWindowFocusChanged(boolean hasFocus) |
|
139 |
{ |
|
140 |
super.onWindowFocusChanged(hasFocus); |
|
141 |
|
|
142 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus) |
|
143 |
{ |
|
144 |
getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
145 |
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
146 |
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
147 |
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
|
148 |
| View.SYSTEM_UI_FLAG_FULLSCREEN |
|
149 |
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); |
|
150 |
} |
|
151 |
} |
|
152 |
|
|
153 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
154 |
|
|
155 |
private void askForPermissions() |
|
156 |
{ |
|
91 | 157 |
final int REQUEST_EXTERNAL_STORAGE = 1; |
92 | 158 |
|
93 | 159 |
String[] PERMISSIONS_STORAGE = |
... | ... | |
102 | 168 |
{ |
103 | 169 |
androidx.core.app.ActivityCompat.requestPermissions( this, PERMISSIONS_STORAGE, REQUEST_EXTERNAL_STORAGE ); |
104 | 170 |
} |
105 |
*/ |
|
106 | 171 |
} |
107 | 172 |
|
108 | 173 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Add hiding the Navigation bar (still unfinished, the bar re-appears when a DialogFragment or a PopupWindow appears)
Integrate the Level Spinner and the Play button into one
Move the Menu button up