Revision a5972f92
Added by Leszek Koltunski about 2 months ago
src/main/java/org/distorted/tutorials/TutorialActivity.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import java.io.InputStream; |
13 | 13 |
|
14 |
import android.os.Build; |
|
15 | 14 |
import android.os.Bundle; |
16 |
import android.util.DisplayMetrics; |
|
17 |
import android.view.View; |
|
18 | 15 |
import android.view.ViewGroup; |
19 |
import android.view.WindowManager; |
|
20 | 16 |
import android.webkit.WebView; |
21 | 17 |
import android.widget.LinearLayout; |
22 | 18 |
|
23 |
import androidx.appcompat.app.AppCompatActivity; |
|
24 |
|
|
25 | 19 |
import org.distorted.dialogs.RubikDialogTutorial; |
20 |
import org.distorted.helpers.BaseActivity; |
|
26 | 21 |
import org.distorted.library.main.DistortedLibrary; |
27 | 22 |
|
28 |
import org.distorted.main.MainActivity; |
|
29 | 23 |
import org.distorted.objectlib.main.InitAssets; |
30 | 24 |
import org.distorted.objectlib.main.ObjectControl; |
31 | 25 |
import org.distorted.objectlib.main.TwistyObject; |
... | ... | |
38 | 32 |
|
39 | 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
40 | 34 |
|
41 |
public class TutorialActivity extends AppCompatActivity
|
|
35 |
public class TutorialActivity extends BaseActivity
|
|
42 | 36 |
{ |
43 | 37 |
private static final String URL = "https://www.youtube.com/embed/"; |
44 | 38 |
private static final int ACTIVITY_NUMBER = 0; |
45 | 39 |
public static final float BAR_RATIO = 0.17f; |
46 |
public static final int FLAGS = MainActivity.FLAGS; |
|
47 | 40 |
|
48 |
private static int mScreenWidth, mScreenHeight; |
|
49 |
private int mCurrentApiVersion; |
|
50 | 41 |
private TutorialScreen mScreen; |
51 | 42 |
private int mObjectOrdinal; |
52 | 43 |
private TutorialWebView mWebView; |
... | ... | |
58 | 49 |
@Override |
59 | 50 |
protected void onCreate(Bundle savedState) |
60 | 51 |
{ |
61 |
setTheme(R.style.MaterialThemeNoActionBar); |
|
62 | 52 |
super.onCreate(savedState); |
63 | 53 |
DistortedLibrary.onCreate(ACTIVITY_NUMBER); |
64 | 54 |
|
... | ... | |
84 | 74 |
mIsFree = (obj!=null && obj.isFree()); |
85 | 75 |
} |
86 | 76 |
|
87 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
88 |
getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics); |
|
89 |
mScreenWidth =displaymetrics.widthPixels; |
|
90 |
mScreenHeight=displaymetrics.heightPixels; |
|
91 |
|
|
77 |
computeScreenDimensions(); |
|
92 | 78 |
hideNavigationBar(); |
93 | 79 |
cutoutHack(); |
94 | 80 |
showDialog(); |
... | ... | |
108 | 94 |
} |
109 | 95 |
} |
110 | 96 |
|
111 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
112 |
|
|
113 |
private void hideNavigationBar() |
|
114 |
{ |
|
115 |
mCurrentApiVersion = Build.VERSION.SDK_INT; |
|
116 |
|
|
117 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT) |
|
118 |
{ |
|
119 |
final View decorView = getWindow().getDecorView(); |
|
120 |
|
|
121 |
decorView.setSystemUiVisibility(FLAGS); |
|
122 |
|
|
123 |
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() |
|
124 |
{ |
|
125 |
@Override |
|
126 |
public void onSystemUiVisibilityChange(int visibility) |
|
127 |
{ |
|
128 |
if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) |
|
129 |
{ |
|
130 |
decorView.setSystemUiVisibility(FLAGS); |
|
131 |
} |
|
132 |
} |
|
133 |
}); |
|
134 |
} |
|
135 |
} |
|
136 |
|
|
137 | 97 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
138 | 98 |
|
139 | 99 |
public void loadTutorial(String url) |
... | ... | |
150 | 110 |
} |
151 | 111 |
} |
152 | 112 |
|
153 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
154 |
// do not avoid cutouts |
|
155 |
|
|
156 |
private void cutoutHack() |
|
157 |
{ |
|
158 |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) |
|
159 |
{ |
|
160 |
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; |
|
161 |
} |
|
162 |
} |
|
163 |
|
|
164 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
165 |
|
|
166 |
@Override |
|
167 |
public void onWindowFocusChanged(boolean hasFocus) |
|
168 |
{ |
|
169 |
super.onWindowFocusChanged(hasFocus); |
|
170 |
|
|
171 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus) |
|
172 |
{ |
|
173 |
getWindow().getDecorView().setSystemUiVisibility(FLAGS); |
|
174 |
} |
|
175 |
} |
|
176 |
|
|
177 | 113 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
178 | 114 |
|
179 | 115 |
@Override |
... | ... | |
258 | 194 |
|
259 | 195 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
260 | 196 |
// PUBLIC API |
261 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
262 |
|
|
263 |
public int getScreenWidthInPixels() |
|
264 |
{ |
|
265 |
return mScreenWidth; |
|
266 |
} |
|
267 |
|
|
268 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
269 |
|
|
270 |
public int getScreenHeightInPixels() |
|
271 |
{ |
|
272 |
return mScreenHeight; |
|
273 |
} |
|
274 |
|
|
275 | 197 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
276 | 198 |
|
277 | 199 |
public boolean getIsFree() |
Also available in: Unified diff
common code from all activities to one BaseActivity