Revision a5972f92
Added by Leszek Koltunski over 1 year ago
| src/main/java/org/distorted/bandaged/BandagedActivity.java | ||
|---|---|---|
| 17 | 17 |
import android.content.SharedPreferences; |
| 18 | 18 |
import android.content.res.Configuration; |
| 19 | 19 |
import android.graphics.Bitmap; |
| 20 |
import android.os.Build; |
|
| 21 | 20 |
import android.os.Bundle; |
| 22 |
import android.util.DisplayMetrics; |
|
| 23 |
import android.view.View; |
|
| 24 | 21 |
import android.view.ViewGroup; |
| 25 |
import android.view.WindowManager; |
|
| 26 | 22 |
import android.widget.LinearLayout; |
| 27 | 23 |
|
| 28 |
import androidx.appcompat.app.AppCompatActivity; |
|
| 29 | 24 |
import androidx.preference.PreferenceManager; |
| 30 | 25 |
|
| 31 | 26 |
import org.distorted.dialogs.RubikDialogError; |
| 32 | 27 |
import org.distorted.dialogs.RubikDialogMessage; |
| 33 | 28 |
import org.distorted.external.RubikFiles; |
| 29 |
import org.distorted.helpers.BaseActivity; |
|
| 34 | 30 |
import org.distorted.library.main.DistortedLibrary; |
| 35 |
import org.distorted.main.MainActivity; |
|
| 36 | 31 |
import org.distorted.main.R; |
| 37 | 32 |
import org.distorted.objectlib.main.InitAssets; |
| 38 | 33 |
import org.distorted.objectlib.main.TwistyJson; |
| ... | ... | |
| 42 | 37 |
|
| 43 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 44 | 39 |
|
| 45 |
public class BandagedActivity extends AppCompatActivity
|
|
| 40 |
public class BandagedActivity extends BaseActivity
|
|
| 46 | 41 |
{
|
| 47 | 42 |
public static final float SPINNER_TEXT_SIZE = 0.03f; |
| 48 | 43 |
public static final float PADDING = 0.010f; |
| 49 |
public static final int FLAGS = MainActivity.FLAGS; |
|
| 50 | 44 |
public static final float RATIO_SCROLL = 0.30f; |
| 51 | 45 |
|
| 52 | 46 |
private static final int ACTIVITY_NUMBER = 2; |
| 53 |
private static final float RATIO_BAR = MainActivity.RATIO_BAR; |
|
| 54 | 47 |
private static final float RATIO_BUT = 0.07f; |
| 55 | 48 |
private static final int NUM_SCRAMBLES = 300; |
| 56 | 49 |
|
| 57 |
private static int mScreenWidth, mScreenHeight; |
|
| 58 |
private int mCurrentApiVersion; |
|
| 59 | 50 |
private BandagedScreen mScreen; |
| 60 | 51 |
private boolean mRTL; |
| 61 | 52 |
private int mObjectOrdinal; |
| ... | ... | |
| 66 | 57 |
@Override |
| 67 | 58 |
protected void onCreate(Bundle savedState) |
| 68 | 59 |
{
|
| 69 |
setTheme(R.style.MaterialThemeNoActionBar); |
|
| 70 | 60 |
super.onCreate(savedState); |
| 71 | 61 |
|
| 72 |
Bundle b = getIntent().getExtras(); |
|
| 73 |
mObjectOrdinal = (b != null) ? b.getInt("obj") : 0;
|
|
| 74 |
|
|
| 75 | 62 |
DistortedLibrary.onCreate(ACTIVITY_NUMBER); |
| 76 | 63 |
setContentView(R.layout.bandaged); |
| 77 | 64 |
|
| 78 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 79 |
getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics); |
|
| 80 |
mScreenWidth =displaymetrics.widthPixels; |
|
| 81 |
mScreenHeight=displaymetrics.heightPixels; |
|
| 82 |
|
|
| 65 |
Bundle b = getIntent().getExtras(); |
|
| 66 |
mObjectOrdinal = (b != null) ? b.getInt("obj") : 0;
|
|
| 83 | 67 |
mDisplayMessageDialog = true; |
| 84 | 68 |
|
| 85 | 69 |
final Configuration config = getResources().getConfiguration(); |
| 86 | 70 |
final int layoutDirection = config.getLayoutDirection(); |
| 87 | 71 |
mRTL = layoutDirection==LAYOUT_DIRECTION_RTL; |
| 88 | 72 |
|
| 73 |
computeScreenDimensions(); |
|
| 89 | 74 |
hideNavigationBar(); |
| 90 | 75 |
cutoutHack(); |
| 91 | 76 |
computeHeights(); |
| ... | ... | |
| 125 | 110 |
creator.setLayoutParams(paramsC); |
| 126 | 111 |
} |
| 127 | 112 |
|
| 128 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 129 |
|
|
| 130 |
private void hideNavigationBar() |
|
| 131 |
{
|
|
| 132 |
mCurrentApiVersion = Build.VERSION.SDK_INT; |
|
| 133 |
|
|
| 134 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT) |
|
| 135 |
{
|
|
| 136 |
final View decorView = getWindow().getDecorView(); |
|
| 137 |
|
|
| 138 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 139 |
|
|
| 140 |
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() |
|
| 141 |
{
|
|
| 142 |
@Override |
|
| 143 |
public void onSystemUiVisibilityChange(int visibility) |
|
| 144 |
{
|
|
| 145 |
if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) |
|
| 146 |
{
|
|
| 147 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 148 |
} |
|
| 149 |
} |
|
| 150 |
}); |
|
| 151 |
} |
|
| 152 |
} |
|
| 153 |
|
|
| 154 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 155 |
// do not avoid cutouts |
|
| 156 |
|
|
| 157 |
private void cutoutHack() |
|
| 158 |
{
|
|
| 159 |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) |
|
| 160 |
{
|
|
| 161 |
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; |
|
| 162 |
} |
|
| 163 |
} |
|
| 164 |
|
|
| 165 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 166 |
|
|
| 167 |
@Override |
|
| 168 |
public void onWindowFocusChanged(boolean hasFocus) |
|
| 169 |
{
|
|
| 170 |
super.onWindowFocusChanged(hasFocus); |
|
| 171 |
|
|
| 172 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus) |
|
| 173 |
{
|
|
| 174 |
getWindow().getDecorView().setSystemUiVisibility(FLAGS); |
|
| 175 |
} |
|
| 176 |
} |
|
| 177 |
|
|
| 178 | 113 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 179 | 114 |
|
| 180 | 115 |
@Override |
| ... | ... | |
| 353 | 288 |
mScreen.iconCreationDone(this,bmp); |
| 354 | 289 |
} |
| 355 | 290 |
|
| 356 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 357 |
|
|
| 358 |
public int getScreenWidthInPixels() |
|
| 359 |
{
|
|
| 360 |
return mScreenWidth; |
|
| 361 |
} |
|
| 362 |
|
|
| 363 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 364 |
|
|
| 365 |
public int getScreenHeightInPixels() |
|
| 366 |
{
|
|
| 367 |
return mScreenHeight; |
|
| 368 |
} |
|
| 369 |
|
|
| 370 | 291 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 371 | 292 |
|
| 372 | 293 |
public int getObjectOrdinal() |
| src/main/java/org/distorted/config/ConfigActivity.java | ||
|---|---|---|
| 10 | 10 |
package org.distorted.config; |
| 11 | 11 |
|
| 12 | 12 |
import android.content.SharedPreferences; |
| 13 |
import android.os.Build; |
|
| 14 | 13 |
import android.os.Bundle; |
| 15 |
import android.util.DisplayMetrics; |
|
| 16 |
import android.view.View; |
|
| 17 |
import android.view.ViewGroup; |
|
| 18 |
import android.view.WindowManager; |
|
| 19 |
import android.widget.LinearLayout; |
|
| 20 | 14 |
|
| 21 |
import androidx.appcompat.app.AppCompatActivity; |
|
| 22 | 15 |
import androidx.preference.PreferenceManager; |
| 23 | 16 |
|
| 24 | 17 |
import org.distorted.dialogs.RubikDialogError; |
| 25 | 18 |
import org.distorted.dialogs.RubikDialogMessage; |
| 19 |
import org.distorted.helpers.BaseActivity; |
|
| 26 | 20 |
import org.distorted.library.main.DistortedLibrary; |
| 27 |
import org.distorted.main.MainActivity; |
|
| 28 | 21 |
import org.distorted.main.R; |
| 29 | 22 |
import org.distorted.objectlib.main.InitAssets; |
| 30 | 23 |
import org.distorted.objectlib.main.ObjectControl; |
| ... | ... | |
| 37 | 30 |
|
| 38 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 39 | 32 |
|
| 40 |
public class ConfigActivity extends AppCompatActivity
|
|
| 33 |
public class ConfigActivity extends BaseActivity
|
|
| 41 | 34 |
{
|
| 42 | 35 |
private static final int ACTIVITY_NUMBER = 7; |
| 43 |
private static final float RATIO_BAR = MainActivity.RATIO_BAR; |
|
| 44 |
public static final int FLAGS = MainActivity.FLAGS; |
|
| 45 |
|
|
| 46 |
private static int mScreenWidth, mScreenHeight; |
|
| 47 | 36 |
private ConfigScreen mScreen; |
| 48 | 37 |
private ConfigScreenPane mPane; |
| 49 |
private int mCurrentApiVersion; |
|
| 50 | 38 |
private int mObjectOrdinal; |
| 51 | 39 |
private boolean mSupportsAdjColors; |
| 52 | 40 |
private boolean mDisplayMessageDialog; |
| ... | ... | |
| 56 | 44 |
@Override |
| 57 | 45 |
protected void onCreate(Bundle savedState) |
| 58 | 46 |
{
|
| 59 |
setTheme(R.style.MaterialThemeNoActionBar); |
|
| 60 | 47 |
super.onCreate(savedState); |
| 61 | 48 |
DistortedLibrary.onCreate(ACTIVITY_NUMBER); |
| 62 | 49 |
setContentView(R.layout.config); |
| ... | ... | |
| 66 | 53 |
|
| 67 | 54 |
mDisplayMessageDialog = true; |
| 68 | 55 |
|
| 69 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 70 |
getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics); |
|
| 71 |
mScreenWidth =displaymetrics.widthPixels; |
|
| 72 |
mScreenHeight=displaymetrics.heightPixels; |
|
| 73 |
|
|
| 56 |
computeScreenDimensions(); |
|
| 74 | 57 |
hideNavigationBar(); |
| 75 | 58 |
cutoutHack(); |
| 76 |
computeBarHeights(); |
|
| 77 |
} |
|
| 78 |
|
|
| 79 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 80 |
// this does not include possible insets |
|
| 81 |
|
|
| 82 |
private void computeBarHeights() |
|
| 83 |
{
|
|
| 84 |
int barHeight = (int)(mScreenHeight*RATIO_BAR); |
|
| 85 |
LinearLayout layout = findViewById(R.id.lowerBar); |
|
| 86 |
ViewGroup.LayoutParams params = layout.getLayoutParams(); |
|
| 87 |
params.height = barHeight; |
|
| 88 |
layout.setLayoutParams(params); |
|
| 89 |
} |
|
| 90 |
|
|
| 91 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 92 |
|
|
| 93 |
private void hideNavigationBar() |
|
| 94 |
{
|
|
| 95 |
mCurrentApiVersion = Build.VERSION.SDK_INT; |
|
| 96 |
|
|
| 97 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT) |
|
| 98 |
{
|
|
| 99 |
final View decorView = getWindow().getDecorView(); |
|
| 100 |
|
|
| 101 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 102 |
|
|
| 103 |
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() |
|
| 104 |
{
|
|
| 105 |
@Override |
|
| 106 |
public void onSystemUiVisibilityChange(int visibility) |
|
| 107 |
{
|
|
| 108 |
if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) |
|
| 109 |
{
|
|
| 110 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 111 |
} |
|
| 112 |
} |
|
| 113 |
}); |
|
| 114 |
} |
|
| 115 |
} |
|
| 116 |
|
|
| 117 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 118 |
// do not avoid cutouts |
|
| 119 |
|
|
| 120 |
private void cutoutHack() |
|
| 121 |
{
|
|
| 122 |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) |
|
| 123 |
{
|
|
| 124 |
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; |
|
| 125 |
} |
|
| 126 |
} |
|
| 127 |
|
|
| 128 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 129 |
|
|
| 130 |
@Override |
|
| 131 |
public void onWindowFocusChanged(boolean hasFocus) |
|
| 132 |
{
|
|
| 133 |
super.onWindowFocusChanged(hasFocus); |
|
| 134 |
|
|
| 135 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus) |
|
| 136 |
{
|
|
| 137 |
getWindow().getDecorView().setSystemUiVisibility(FLAGS); |
|
| 138 |
} |
|
| 59 |
computeLowerBarHeight(RATIO_BAR); |
|
| 139 | 60 |
} |
| 140 | 61 |
|
| 141 | 62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 305 | 226 |
mPane.resetUI(this); |
| 306 | 227 |
} |
| 307 | 228 |
|
| 308 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 309 |
|
|
| 310 |
public int getScreenWidthInPixels() |
|
| 311 |
{
|
|
| 312 |
return mScreenWidth; |
|
| 313 |
} |
|
| 314 |
|
|
| 315 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 316 |
|
|
| 317 |
public int getScreenHeightInPixels() |
|
| 318 |
{
|
|
| 319 |
return mScreenHeight; |
|
| 320 |
} |
|
| 321 |
|
|
| 322 | 229 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 323 | 230 |
|
| 324 | 231 |
public ObjectControl getControl() |
| src/main/java/org/distorted/helpers/BaseActivity.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2024 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Magic Cube. // |
|
| 5 |
// // |
|
| 6 |
// Magic Cube is proprietary software licensed under an EULA which you should have received // |
|
| 7 |
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html // |
|
| 8 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 9 |
|
|
| 10 |
package org.distorted.helpers; |
|
| 11 |
|
|
| 12 |
import android.content.res.Configuration; |
|
| 13 |
import android.os.Build; |
|
| 14 |
import android.os.Bundle; |
|
| 15 |
import android.util.DisplayMetrics; |
|
| 16 |
import android.view.View; |
|
| 17 |
import android.view.ViewGroup; |
|
| 18 |
import android.view.WindowManager; |
|
| 19 |
import android.widget.LinearLayout; |
|
| 20 |
|
|
| 21 |
import androidx.appcompat.app.AppCompatActivity; |
|
| 22 |
|
|
| 23 |
import org.distorted.main.R; |
|
| 24 |
|
|
| 25 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 26 |
|
|
| 27 |
public class BaseActivity extends AppCompatActivity |
|
| 28 |
{
|
|
| 29 |
public static final float RATIO_BAR = 0.080f; |
|
| 30 |
public static final int FLAGS = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
| 31 |
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
| 32 |
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
|
| 33 |
| View.SYSTEM_UI_FLAG_FULLSCREEN |
|
| 34 |
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; |
|
| 35 |
|
|
| 36 |
private int mCurrentApiVersion; |
|
| 37 |
protected int mScreenWidth, mScreenHeight; |
|
| 38 |
protected int mHeightLowerBar, mHeightUpperBar; |
|
| 39 |
|
|
| 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 41 |
|
|
| 42 |
@Override |
|
| 43 |
protected void onCreate(Bundle savedState) |
|
| 44 |
{
|
|
| 45 |
setTheme(R.style.MaterialThemeNoActionBar); |
|
| 46 |
super.onCreate(savedState); |
|
| 47 |
} |
|
| 48 |
|
|
| 49 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 50 |
|
|
| 51 |
protected void getWindowWidth(Configuration conf) |
|
| 52 |
{
|
|
| 53 |
int dpi = getResources().getDisplayMetrics().densityDpi; |
|
| 54 |
float conv = ((float) dpi/DisplayMetrics.DENSITY_DEFAULT); |
|
| 55 |
|
|
| 56 |
mScreenWidth = (int) (conf.screenWidthDp*conv + 0.5f); |
|
| 57 |
mScreenHeight= (int) (conf.screenHeightDp*conv + 0.5f); |
|
| 58 |
} |
|
| 59 |
|
|
| 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 61 |
|
|
| 62 |
protected void computeScreenDimensions() |
|
| 63 |
{
|
|
| 64 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 65 |
getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics); |
|
| 66 |
mScreenWidth =displaymetrics.widthPixels; |
|
| 67 |
mScreenHeight=displaymetrics.heightPixels; |
|
| 68 |
} |
|
| 69 |
|
|
| 70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 71 |
|
|
| 72 |
protected void computeLowerBarHeight(float ratio) |
|
| 73 |
{
|
|
| 74 |
int barHeight = (int)(mScreenHeight*ratio); |
|
| 75 |
mHeightLowerBar = barHeight; |
|
| 76 |
|
|
| 77 |
LinearLayout layout = findViewById(R.id.lowerBar); |
|
| 78 |
ViewGroup.LayoutParams params = layout.getLayoutParams(); |
|
| 79 |
params.height = barHeight; |
|
| 80 |
layout.setLayoutParams(params); |
|
| 81 |
} |
|
| 82 |
|
|
| 83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 84 |
// this does not include possible insets |
|
| 85 |
|
|
| 86 |
protected void computeUpperBarHeight(float ratio) |
|
| 87 |
{
|
|
| 88 |
int barHeight = (int)(mScreenHeight*ratio); |
|
| 89 |
mHeightUpperBar = barHeight; |
|
| 90 |
|
|
| 91 |
LinearLayout layout = findViewById(R.id.upperBar); |
|
| 92 |
ViewGroup.LayoutParams params = layout.getLayoutParams(); |
|
| 93 |
params.height = barHeight; |
|
| 94 |
layout.setLayoutParams(params); |
|
| 95 |
} |
|
| 96 |
|
|
| 97 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 98 |
|
|
| 99 |
protected void hideNavigationBar() |
|
| 100 |
{
|
|
| 101 |
mCurrentApiVersion = Build.VERSION.SDK_INT; |
|
| 102 |
|
|
| 103 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT) |
|
| 104 |
{
|
|
| 105 |
final View decorView = getWindow().getDecorView(); |
|
| 106 |
|
|
| 107 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 108 |
|
|
| 109 |
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() |
|
| 110 |
{
|
|
| 111 |
@Override |
|
| 112 |
public void onSystemUiVisibilityChange(int visibility) |
|
| 113 |
{
|
|
| 114 |
if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) |
|
| 115 |
{
|
|
| 116 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 117 |
} |
|
| 118 |
} |
|
| 119 |
}); |
|
| 120 |
} |
|
| 121 |
} |
|
| 122 |
|
|
| 123 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 124 |
// do not avoid cutouts |
|
| 125 |
|
|
| 126 |
protected void cutoutHack() |
|
| 127 |
{
|
|
| 128 |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) |
|
| 129 |
{
|
|
| 130 |
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; |
|
| 131 |
} |
|
| 132 |
} |
|
| 133 |
|
|
| 134 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 135 |
|
|
| 136 |
@Override |
|
| 137 |
public void onWindowFocusChanged(boolean hasFocus) |
|
| 138 |
{
|
|
| 139 |
super.onWindowFocusChanged(hasFocus); |
|
| 140 |
|
|
| 141 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus) |
|
| 142 |
{
|
|
| 143 |
getWindow().getDecorView().setSystemUiVisibility(FLAGS); |
|
| 144 |
} |
|
| 145 |
} |
|
| 146 |
|
|
| 147 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 148 |
|
|
| 149 |
public int getScreenWidthInPixels() |
|
| 150 |
{
|
|
| 151 |
return mScreenWidth; |
|
| 152 |
} |
|
| 153 |
|
|
| 154 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 155 |
|
|
| 156 |
public int getScreenHeightInPixels() |
|
| 157 |
{
|
|
| 158 |
return mScreenHeight; |
|
| 159 |
} |
|
| 160 |
|
|
| 161 |
} |
|
| src/main/java/org/distorted/info/InfoActivity.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 |
import android.view.ViewGroup; |
|
| 19 |
import android.view.WindowManager; |
|
| 20 |
import android.widget.LinearLayout; |
|
| 21 |
import androidx.appcompat.app.AppCompatActivity; |
|
| 22 | 15 |
|
| 16 |
import org.distorted.helpers.BaseActivity; |
|
| 23 | 17 |
import org.distorted.library.main.DistortedLibrary; |
| 24 |
import org.distorted.main.MainActivity; |
|
| 25 | 18 |
import org.distorted.objectlib.main.InitAssets; |
| 26 | 19 |
import org.distorted.objectlib.main.ObjectControl; |
| 27 | 20 |
import org.distorted.main.R; |
| ... | ... | |
| 32 | 25 |
|
| 33 | 26 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 34 | 27 |
|
| 35 |
public class InfoActivity extends AppCompatActivity
|
|
| 28 |
public class InfoActivity extends BaseActivity
|
|
| 36 | 29 |
{
|
| 37 | 30 |
private static final int ACTIVITY_NUMBER = 1; |
| 38 |
private static final float RATIO_BAR = MainActivity.RATIO_BAR; |
|
| 39 |
public static final int FLAGS = MainActivity.FLAGS; |
|
| 40 |
|
|
| 41 |
private static int mScreenWidth, mScreenHeight; |
|
| 42 |
private int mCurrentApiVersion; |
|
| 43 | 31 |
private InfoScreen mScreen; |
| 44 | 32 |
private int mObjectOrdinal; |
| 45 |
private int mHeightBar; |
|
| 46 | 33 |
|
| 47 | 34 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 48 | 35 |
|
| 49 | 36 |
@Override |
| 50 | 37 |
protected void onCreate(Bundle savedState) |
| 51 | 38 |
{
|
| 52 |
setTheme(R.style.MaterialThemeNoActionBar); |
|
| 53 | 39 |
super.onCreate(savedState); |
| 54 | 40 |
DistortedLibrary.onCreate(ACTIVITY_NUMBER); |
| 55 | 41 |
setContentView(R.layout.info); |
| 56 | 42 |
|
| 57 | 43 |
Bundle b = getIntent().getExtras(); |
| 58 |
|
|
| 59 | 44 |
if(b != null) mObjectOrdinal = b.getInt("obj");
|
| 60 | 45 |
|
| 61 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 62 |
getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics); |
|
| 63 |
mScreenWidth =displaymetrics.widthPixels; |
|
| 64 |
mScreenHeight=displaymetrics.heightPixels; |
|
| 65 |
|
|
| 46 |
computeScreenDimensions(); |
|
| 66 | 47 |
hideNavigationBar(); |
| 67 | 48 |
cutoutHack(); |
| 68 |
computeBarHeights(); |
|
| 69 |
} |
|
| 70 |
|
|
| 71 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 72 |
// this does not include possible insets |
|
| 73 |
|
|
| 74 |
private void computeBarHeights() |
|
| 75 |
{
|
|
| 76 |
int barHeight = (int)(mScreenHeight*RATIO_BAR); |
|
| 77 |
mHeightBar = barHeight; |
|
| 78 |
|
|
| 79 |
LinearLayout layout = findViewById(R.id.lowerBar); |
|
| 80 |
ViewGroup.LayoutParams params = layout.getLayoutParams(); |
|
| 81 |
params.height = barHeight; |
|
| 82 |
layout.setLayoutParams(params); |
|
| 83 |
} |
|
| 84 |
|
|
| 85 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 86 |
|
|
| 87 |
private void hideNavigationBar() |
|
| 88 |
{
|
|
| 89 |
mCurrentApiVersion = Build.VERSION.SDK_INT; |
|
| 90 |
|
|
| 91 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT) |
|
| 92 |
{
|
|
| 93 |
final View decorView = getWindow().getDecorView(); |
|
| 94 |
|
|
| 95 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 96 |
|
|
| 97 |
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() |
|
| 98 |
{
|
|
| 99 |
@Override |
|
| 100 |
public void onSystemUiVisibilityChange(int visibility) |
|
| 101 |
{
|
|
| 102 |
if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) |
|
| 103 |
{
|
|
| 104 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 105 |
} |
|
| 106 |
} |
|
| 107 |
}); |
|
| 108 |
} |
|
| 109 |
} |
|
| 110 |
|
|
| 111 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 112 |
// do not avoid cutouts |
|
| 113 |
|
|
| 114 |
private void cutoutHack() |
|
| 115 |
{
|
|
| 116 |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) |
|
| 117 |
{
|
|
| 118 |
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; |
|
| 119 |
} |
|
| 120 |
} |
|
| 121 |
|
|
| 122 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 123 |
|
|
| 124 |
@Override |
|
| 125 |
public void onWindowFocusChanged(boolean hasFocus) |
|
| 126 |
{
|
|
| 127 |
super.onWindowFocusChanged(hasFocus); |
|
| 128 |
|
|
| 129 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus) |
|
| 130 |
{
|
|
| 131 |
getWindow().getDecorView().setSystemUiVisibility(FLAGS); |
|
| 132 |
} |
|
| 49 |
computeLowerBarHeight(RATIO_BAR); |
|
| 133 | 50 |
} |
| 134 | 51 |
|
| 135 | 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 197 | 114 |
|
| 198 | 115 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 199 | 116 |
// PUBLIC API |
| 200 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 201 |
|
|
| 202 |
public void changeObject(int ordinal) |
|
| 203 |
{
|
|
| 204 |
mObjectOrdinal = ordinal; |
|
| 205 |
RubikObject object = RubikObjectList.getObject(ordinal); |
|
| 206 |
InfoSurfaceView view = findViewById(R.id.infoSurfaceView); |
|
| 207 |
ObjectControl control = view.getObjectControl(); |
|
| 208 |
changeIfDifferent(object,ordinal,control); |
|
| 209 |
} |
|
| 210 |
|
|
| 211 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 212 |
|
|
| 213 |
public int getHeightBar() |
|
| 214 |
{
|
|
| 215 |
return mHeightBar; |
|
| 216 |
} |
|
| 217 |
|
|
| 218 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 219 |
|
|
| 220 |
public int getScreenWidthInPixels() |
|
| 221 |
{
|
|
| 222 |
return mScreenWidth; |
|
| 223 |
} |
|
| 224 |
|
|
| 225 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 226 |
|
|
| 227 |
public int getScreenHeightInPixels() |
|
| 228 |
{
|
|
| 229 |
return mScreenHeight; |
|
| 230 |
} |
|
| 231 |
|
|
| 232 | 117 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 233 | 118 |
|
| 234 | 119 |
public ObjectControl getControl() |
| src/main/java/org/distorted/main/MainActivity.java | ||
|---|---|---|
| 16 | 16 |
import android.content.res.Configuration; |
| 17 | 17 |
import android.os.Build; |
| 18 | 18 |
import android.os.Bundle; |
| 19 |
import android.util.DisplayMetrics; |
|
| 20 | 19 |
import android.util.TypedValue; |
| 21 | 20 |
import android.view.DisplayCutout; |
| 22 | 21 |
import android.view.View; |
| 23 | 22 |
import android.view.ViewGroup; |
| 24 |
import android.view.WindowManager; |
|
| 25 | 23 |
import android.widget.LinearLayout; |
| 26 | 24 |
import android.widget.ScrollView; |
| 27 | 25 |
import android.widget.TextView; |
| 28 | 26 |
|
| 29 | 27 |
import androidx.annotation.NonNull; |
| 30 |
import androidx.appcompat.app.AppCompatActivity; |
|
| 31 | 28 |
import androidx.preference.PreferenceManager; |
| 32 | 29 |
|
| 33 | 30 |
import com.google.firebase.analytics.FirebaseAnalytics; |
| ... | ... | |
| 35 | 32 |
|
| 36 | 33 |
import org.distorted.bandaged.BandagedActivity; |
| 37 | 34 |
import org.distorted.config.ConfigActivity; |
| 35 |
import org.distorted.helpers.BaseActivity; |
|
| 38 | 36 |
import org.distorted.info.InfoActivity; |
| 39 | 37 |
import org.distorted.dialogs.RubikDialogAbout; |
| 40 | 38 |
import org.distorted.dialogs.RubikDialogCreators; |
| ... | ... | |
| 54 | 52 |
|
| 55 | 53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 56 | 54 |
|
| 57 |
public class MainActivity extends AppCompatActivity implements RubikNetwork.Updatee, RubikDialogScores.ScoresInvoker
|
|
| 55 |
public class MainActivity extends BaseActivity implements RubikNetwork.Updatee, RubikDialogScores.ScoresInvoker
|
|
| 58 | 56 |
{
|
| 59 |
public static final float RATIO_BAR = 0.080f; |
|
| 60 |
public static final int FLAGS = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
| 61 |
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
| 62 |
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
|
| 63 |
| View.SYSTEM_UI_FLAG_FULLSCREEN |
|
| 64 |
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; |
|
| 65 |
|
|
| 66 | 57 |
private boolean mJustStarted; |
| 67 | 58 |
private FirebaseAnalytics mFirebaseAnalytics; |
| 68 |
private int mCurrentApiVersion; |
|
| 69 | 59 |
private String mOldVersion, mCurrVersion; |
| 70 |
private int mScreenWidth, mScreenHeight; |
|
| 71 | 60 |
private TextView mBubbleUpdates; |
| 72 | 61 |
private int mNumUpdates; |
| 73 | 62 |
private int mCurrentObject; |
| ... | ... | |
| 79 | 68 |
@Override |
| 80 | 69 |
protected void onCreate(Bundle savedState) |
| 81 | 70 |
{
|
| 82 |
setTheme(R.style.MaterialThemeNoActionBar); |
|
| 83 | 71 |
super.onCreate(savedState); |
| 84 | 72 |
setContentView(R.layout.main); |
| 85 |
hideNavigationBar(); |
|
| 86 | 73 |
|
| 87 | 74 |
mCurrentObject = 0; |
| 88 | 75 |
mJustStarted = true; |
| 89 | 76 |
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); |
| 90 | 77 |
|
| 78 |
hideNavigationBar(); |
|
| 91 | 79 |
cutoutHack(); |
| 92 | 80 |
computeHeights(); |
| 93 | 81 |
|
| ... | ... | |
| 127 | 115 |
layoutBot.setLayoutParams(pL); |
| 128 | 116 |
} |
| 129 | 117 |
|
| 130 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 131 |
|
|
| 132 |
private void hideNavigationBar() |
|
| 133 |
{
|
|
| 134 |
mCurrentApiVersion = Build.VERSION.SDK_INT; |
|
| 135 |
|
|
| 136 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT) |
|
| 137 |
{
|
|
| 138 |
final View decorView = getWindow().getDecorView(); |
|
| 139 |
|
|
| 140 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 141 |
|
|
| 142 |
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() |
|
| 143 |
{
|
|
| 144 |
@Override |
|
| 145 |
public void onSystemUiVisibilityChange(int visibility) |
|
| 146 |
{
|
|
| 147 |
if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) |
|
| 148 |
{
|
|
| 149 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 150 |
} |
|
| 151 |
} |
|
| 152 |
}); |
|
| 153 |
} |
|
| 154 |
} |
|
| 155 |
|
|
| 156 | 118 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 157 | 119 |
|
| 158 | 120 |
@Override |
| ... | ... | |
| 182 | 144 |
} |
| 183 | 145 |
} |
| 184 | 146 |
|
| 185 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 186 |
// do not avoid cutouts |
|
| 187 |
|
|
| 188 |
private void cutoutHack() |
|
| 189 |
{
|
|
| 190 |
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.P ) |
|
| 191 |
{
|
|
| 192 |
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; |
|
| 193 |
} |
|
| 194 |
} |
|
| 195 |
|
|
| 196 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 197 |
|
|
| 198 |
private void getWindowWidth(Configuration conf) |
|
| 199 |
{
|
|
| 200 |
int dpi = getResources().getDisplayMetrics().densityDpi; |
|
| 201 |
float conv = ((float) dpi/DisplayMetrics.DENSITY_DEFAULT); |
|
| 202 |
|
|
| 203 |
mScreenWidth = (int) (conf.screenWidthDp*conv + 0.5f); |
|
| 204 |
mScreenHeight= (int) (conf.screenHeightDp*conv + 0.5f); |
|
| 205 |
} |
|
| 206 |
|
|
| 207 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 208 |
|
|
| 209 |
@Override |
|
| 210 |
public void onWindowFocusChanged(boolean hasFocus) |
|
| 211 |
{
|
|
| 212 |
super.onWindowFocusChanged(hasFocus); |
|
| 213 |
|
|
| 214 |
if( mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus ) |
|
| 215 |
{
|
|
| 216 |
getWindow().getDecorView().setSystemUiVisibility(FLAGS); |
|
| 217 |
} |
|
| 218 |
} |
|
| 219 |
|
|
| 220 | 147 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 221 | 148 |
|
| 222 | 149 |
@Override |
| src/main/java/org/distorted/patternui/PatternActivity.java | ||
|---|---|---|
| 12 | 12 |
import android.content.SharedPreferences; |
| 13 | 13 |
import android.os.Build; |
| 14 | 14 |
import android.os.Bundle; |
| 15 |
import android.util.DisplayMetrics; |
|
| 16 | 15 |
import android.view.DisplayCutout; |
| 17 |
import android.view.View; |
|
| 18 | 16 |
import android.view.ViewGroup; |
| 19 |
import android.view.WindowManager; |
|
| 20 | 17 |
import android.widget.LinearLayout; |
| 21 | 18 |
|
| 22 |
import androidx.appcompat.app.AppCompatActivity; |
|
| 23 | 19 |
import androidx.preference.PreferenceManager; |
| 24 | 20 |
|
| 25 | 21 |
import org.distorted.dialogs.RubikDialogError; |
| 22 |
import org.distorted.helpers.BaseActivity; |
|
| 26 | 23 |
import org.distorted.library.main.DistortedLibrary; |
| 27 | 24 |
import org.distorted.library.main.DistortedScreen; |
| 28 |
import org.distorted.main.MainActivity; |
|
| 29 | 25 |
import org.distorted.main.R; |
| 30 | 26 |
import org.distorted.objectlib.main.InitAssets; |
| 31 | 27 |
import org.distorted.objectlib.main.ObjectControl; |
| ... | ... | |
| 38 | 34 |
|
| 39 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 40 | 36 |
|
| 41 |
public class PatternActivity extends AppCompatActivity
|
|
| 37 |
public class PatternActivity extends BaseActivity
|
|
| 42 | 38 |
{
|
| 43 |
public static final float RATIO_BAR = 0.100f;
|
|
| 39 |
public static final float RATIO_UPP = 0.100f;
|
|
| 44 | 40 |
public static final float PADDING = 0.010f; |
| 45 | 41 |
public static final float SMALL_MARGIN = 0.004f; |
| 46 | 42 |
public static final float BUTTON_TEXT_SIZE= 0.050f; |
| ... | ... | |
| 49 | 45 |
private static final int ACTIVITY_NUMBER = 5; |
| 50 | 46 |
private static final float RATIO_INSET= 0.09f; |
| 51 | 47 |
|
| 52 |
private static int mScreenWidth, mScreenHeight; |
|
| 53 |
private int mCurrentApiVersion; |
|
| 54 |
private int mHeightUpperBar; |
|
| 55 | 48 |
private int mObjectOrdinal; |
| 56 | 49 |
|
| 57 | 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 59 | 52 |
@Override |
| 60 | 53 |
protected void onCreate(Bundle savedState) |
| 61 | 54 |
{
|
| 62 |
setTheme(R.style.MaterialThemeNoActionBar); |
|
| 63 | 55 |
super.onCreate(savedState); |
| 64 | 56 |
DistortedLibrary.onCreate(ACTIVITY_NUMBER); |
| 65 | 57 |
setContentView(R.layout.pattern); |
| 66 |
hideNavigationBar(); |
|
| 67 | 58 |
|
| 68 | 59 |
Bundle b = getIntent().getExtras(); |
| 69 | 60 |
mObjectOrdinal = b!=null ? b.getInt("obj") : 0;
|
| 70 | 61 |
|
| 71 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 72 |
getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics); |
|
| 73 |
mScreenWidth =displaymetrics.widthPixels; |
|
| 74 |
mScreenHeight=displaymetrics.heightPixels; |
|
| 75 |
|
|
| 62 |
computeScreenDimensions(); |
|
| 63 |
hideNavigationBar(); |
|
| 76 | 64 |
cutoutHack(); |
| 77 |
computeBarHeights(); |
|
| 78 |
} |
|
| 79 |
|
|
| 80 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 81 |
// this does not include possible insets |
|
| 82 |
|
|
| 83 |
private void computeBarHeights() |
|
| 84 |
{
|
|
| 85 |
int barHeight = (int)(mScreenHeight*RATIO_BAR); |
|
| 86 |
mHeightUpperBar = barHeight; |
|
| 87 |
|
|
| 88 |
LinearLayout layoutTop = findViewById(R.id.upperBar); |
|
| 89 |
LinearLayout layoutBot = findViewById(R.id.lowerBar); |
|
| 90 |
|
|
| 91 |
ViewGroup.LayoutParams paramsTop = layoutTop.getLayoutParams(); |
|
| 92 |
paramsTop.height = mHeightUpperBar; |
|
| 93 |
layoutTop.setLayoutParams(paramsTop); |
|
| 94 |
ViewGroup.LayoutParams paramsBot = layoutBot.getLayoutParams(); |
|
| 95 |
paramsBot.height = barHeight; |
|
| 96 |
layoutBot.setLayoutParams(paramsBot); |
|
| 97 |
} |
|
| 98 |
|
|
| 99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 100 |
|
|
| 101 |
private void hideNavigationBar() |
|
| 102 |
{
|
|
| 103 |
mCurrentApiVersion = Build.VERSION.SDK_INT; |
|
| 104 |
|
|
| 105 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT) |
|
| 106 |
{
|
|
| 107 |
final View decorView = getWindow().getDecorView(); |
|
| 108 |
|
|
| 109 |
decorView.setSystemUiVisibility(MainActivity.FLAGS); |
|
| 110 |
|
|
| 111 |
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() |
|
| 112 |
{
|
|
| 113 |
@Override |
|
| 114 |
public void onSystemUiVisibilityChange(int visibility) |
|
| 115 |
{
|
|
| 116 |
if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) |
|
| 117 |
{
|
|
| 118 |
decorView.setSystemUiVisibility(MainActivity.FLAGS); |
|
| 119 |
} |
|
| 120 |
} |
|
| 121 |
}); |
|
| 122 |
} |
|
| 65 |
computeLowerBarHeight(RATIO_BAR); |
|
| 66 |
computeUpperBarHeight(RATIO_UPP); |
|
| 123 | 67 |
} |
| 124 | 68 |
|
| 125 | 69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 138 | 82 |
ViewGroup.LayoutParams paramsHid = layoutHid.getLayoutParams(); |
| 139 | 83 |
paramsHid.height = (int)(insetHeight*RATIO_INSET); |
| 140 | 84 |
layoutHid.setLayoutParams(paramsHid); |
| 141 |
mHeightUpperBar += paramsHid.height; |
|
| 142 |
} |
|
| 143 |
} |
|
| 144 |
|
|
| 145 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 146 |
// do not avoid cutouts |
|
| 147 |
|
|
| 148 |
private void cutoutHack() |
|
| 149 |
{
|
|
| 150 |
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.P ) |
|
| 151 |
{
|
|
| 152 |
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; |
|
| 153 |
} |
|
| 154 |
} |
|
| 155 |
|
|
| 156 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 157 |
|
|
| 158 |
@Override |
|
| 159 |
public void onWindowFocusChanged(boolean hasFocus) |
|
| 160 |
{
|
|
| 161 |
super.onWindowFocusChanged(hasFocus); |
|
| 162 |
|
|
| 163 |
if( mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus ) |
|
| 164 |
{
|
|
| 165 |
getWindow().getDecorView().setSystemUiVisibility(MainActivity.FLAGS); |
|
| 166 | 85 |
} |
| 167 | 86 |
} |
| 168 | 87 |
|
| ... | ... | |
| 263 | 182 |
return view.getObjectControl(); |
| 264 | 183 |
} |
| 265 | 184 |
|
| 266 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 267 |
|
|
| 268 |
public int getScreenWidthInPixels() |
|
| 269 |
{
|
|
| 270 |
return mScreenWidth; |
|
| 271 |
} |
|
| 272 |
|
|
| 273 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 274 |
|
|
| 275 |
public int getScreenHeightInPixels() |
|
| 276 |
{
|
|
| 277 |
return mScreenHeight; |
|
| 278 |
} |
|
| 279 |
|
|
| 280 | 185 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 281 | 186 |
|
| 282 | 187 |
public int getObjectOrdinal() |
| src/main/java/org/distorted/playui/PlayActivity.java | ||
|---|---|---|
| 14 | 14 |
import android.content.SharedPreferences; |
| 15 | 15 |
import android.os.Build; |
| 16 | 16 |
import android.os.Bundle; |
| 17 |
import android.util.DisplayMetrics; |
|
| 18 | 17 |
import android.view.DisplayCutout; |
| 19 |
import android.view.View; |
|
| 20 | 18 |
import android.view.ViewGroup; |
| 21 |
import android.view.WindowManager; |
|
| 22 | 19 |
import android.widget.LinearLayout; |
| 23 | 20 |
|
| 24 |
import androidx.appcompat.app.AppCompatActivity; |
|
| 25 | 21 |
import androidx.preference.PreferenceManager; |
| 26 | 22 |
|
| 27 | 23 |
import com.google.firebase.analytics.FirebaseAnalytics; |
| 28 | 24 |
|
| 29 | 25 |
import org.distorted.dialogs.RubikDialogScores; |
| 30 | 26 |
import org.distorted.external.RubikScores; |
| 27 |
import org.distorted.helpers.BaseActivity; |
|
| 31 | 28 |
import org.distorted.library.main.DistortedLibrary; |
| 32 | 29 |
import org.distorted.objectlib.main.InitAssets; |
| 33 | 30 |
import org.distorted.objectlib.main.ObjectControl; |
| 34 | 31 |
import org.distorted.objectlib.main.TwistyObject; |
| 35 | 32 |
import org.distorted.dialogs.RubikDialogError; |
| 36 | 33 |
import org.distorted.external.RubikFiles; |
| 37 |
import org.distorted.main.MainActivity; |
|
| 38 | 34 |
import org.distorted.main.R; |
| 39 | 35 |
import org.distorted.objects.RubikObject; |
| 40 | 36 |
import org.distorted.objects.RubikObjectList; |
| ... | ... | |
| 42 | 38 |
|
| 43 | 39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 44 | 40 |
|
| 45 |
public class PlayActivity extends AppCompatActivity implements RubikDialogScores.ScoresInvoker
|
|
| 41 |
public class PlayActivity extends BaseActivity implements RubikDialogScores.ScoresInvoker
|
|
| 46 | 42 |
{
|
| 47 |
public static final int FLAGS = MainActivity.FLAGS; |
|
| 48 | 43 |
public static final float TITLE_TEXT_SIZE= 0.060f; |
| 49 | 44 |
private static final int ACTIVITY_NUMBER = 6; |
| 50 |
private static final float RATIO_BAR = MainActivity.RATIO_BAR; |
|
| 51 | 45 |
private static final float RATIO_INSET = 0.09f; |
| 52 | 46 |
|
| 53 | 47 |
private static final String KEY_FREE = "movesController_free"; |
| 54 | 48 |
private static final String KEY_SOLV = "movesController_solv"; |
| 55 | 49 |
|
| 56 |
private static int mScreenWidth, mScreenHeight; |
|
| 57 |
private int mCurrentApiVersion; |
|
| 58 | 50 |
private String mObjectName; |
| 59 | 51 |
private int mNumScrambles; |
| 60 |
private int mHeightUpperBar; |
|
| 61 | 52 |
private boolean mObjectLocal; |
| 62 | 53 |
private int mObjectOrdinal; |
| 63 | 54 |
private int mLevel; |
| ... | ... | |
| 70 | 61 |
@Override |
| 71 | 62 |
protected void onCreate(Bundle savedState) |
| 72 | 63 |
{
|
| 73 |
setTheme(R.style.MaterialThemeNoActionBar); |
|
| 74 | 64 |
super.onCreate(savedState); |
| 75 | 65 |
DistortedLibrary.onCreate(ACTIVITY_NUMBER); |
| 76 | 66 |
setContentView(R.layout.play); |
| ... | ... | |
| 99 | 89 |
|
| 100 | 90 |
mModeFree = (mLevel<0); |
| 101 | 91 |
|
| 102 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 103 |
getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics); |
|
| 104 |
mScreenWidth =displaymetrics.widthPixels; |
|
| 105 |
mScreenHeight=displaymetrics.heightPixels; |
|
| 106 |
|
|
| 92 |
computeScreenDimensions(); |
|
| 107 | 93 |
hideNavigationBar(); |
| 108 | 94 |
cutoutHack(); |
| 109 |
computeBarHeights(); |
|
| 110 |
} |
|
| 111 |
|
|
| 112 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 113 |
// this does not include possible insets |
|
| 114 |
|
|
| 115 |
private void computeBarHeights() |
|
| 116 |
{
|
|
| 117 |
int barHeight = (int)(mScreenHeight*RATIO_BAR); |
|
| 118 |
mHeightUpperBar = barHeight; |
|
| 119 |
|
|
| 120 |
LinearLayout layoutTop = findViewById(R.id.upperBar); |
|
| 121 |
LinearLayout layoutBot = findViewById(R.id.lowerBar); |
|
| 122 |
|
|
| 123 |
ViewGroup.LayoutParams paramsTop = layoutTop.getLayoutParams(); |
|
| 124 |
paramsTop.height = mHeightUpperBar; |
|
| 125 |
layoutTop.setLayoutParams(paramsTop); |
|
| 126 |
ViewGroup.LayoutParams paramsBot = layoutBot.getLayoutParams(); |
|
| 127 |
paramsBot.height = barHeight; |
|
| 128 |
layoutBot.setLayoutParams(paramsBot); |
|
| 129 |
} |
|
| 130 |
|
|
| 131 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 132 |
|
|
| 133 |
private void hideNavigationBar() |
|
| 134 |
{
|
|
| 135 |
mCurrentApiVersion = Build.VERSION.SDK_INT; |
|
| 136 |
|
|
| 137 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT) |
|
| 138 |
{
|
|
| 139 |
final View decorView = getWindow().getDecorView(); |
|
| 140 |
|
|
| 141 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 142 |
|
|
| 143 |
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() |
|
| 144 |
{
|
|
| 145 |
@Override |
|
| 146 |
public void onSystemUiVisibilityChange(int visibility) |
|
| 147 |
{
|
|
| 148 |
if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) |
|
| 149 |
{
|
|
| 150 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 151 |
} |
|
| 152 |
} |
|
| 153 |
}); |
|
| 154 |
} |
|
| 95 |
computeUpperBarHeight(RATIO_BAR); |
|
| 96 |
computeLowerBarHeight(RATIO_BAR); |
|
| 155 | 97 |
} |
| 156 | 98 |
|
| 157 | 99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 170 | 112 |
ViewGroup.LayoutParams paramsHid = layoutHid.getLayoutParams(); |
| 171 | 113 |
paramsHid.height = (int)(insetHeight*RATIO_INSET); |
| 172 | 114 |
layoutHid.setLayoutParams(paramsHid); |
| 173 |
mHeightUpperBar += paramsHid.height; |
|
| 174 |
} |
|
| 175 |
} |
|
| 176 |
|
|
| 177 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 178 |
// do not avoid cutouts |
|
| 179 |
|
|
| 180 |
private void cutoutHack() |
|
| 181 |
{
|
|
| 182 |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) |
|
| 183 |
{
|
|
| 184 |
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; |
|
| 185 |
} |
|
| 186 |
} |
|
| 187 |
|
|
| 188 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 189 |
|
|
| 190 |
@Override |
|
| 191 |
public void onWindowFocusChanged(boolean hasFocus) |
|
| 192 |
{
|
|
| 193 |
super.onWindowFocusChanged(hasFocus); |
|
| 194 |
|
|
| 195 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus) |
|
| 196 |
{
|
|
| 197 |
getWindow().getDecorView().setSystemUiVisibility(FLAGS); |
|
| 198 | 115 |
} |
| 199 | 116 |
} |
| 200 | 117 |
|
| ... | ... | |
| 369 | 286 |
return mFirebaseAnalytics; |
| 370 | 287 |
} |
| 371 | 288 |
|
| 372 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 373 |
|
|
| 374 |
public int getScreenWidthInPixels() |
|
| 375 |
{
|
|
| 376 |
return mScreenWidth; |
|
| 377 |
} |
|
| 378 |
|
|
| 379 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 380 |
|
|
| 381 |
public int getScreenHeightInPixels() |
|
| 382 |
{
|
|
| 383 |
return mScreenHeight; |
|
| 384 |
} |
|
| 385 |
|
|
| 386 | 289 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 387 | 290 |
|
| 388 | 291 |
public int getNumScrambles() |
| src/main/java/org/distorted/purchase/PurchaseActivity.java | ||
|---|---|---|
| 10 | 10 |
package org.distorted.purchase; |
| 11 | 11 |
|
| 12 | 12 |
import android.content.SharedPreferences; |
| 13 |
import android.os.Build; |
|
| 14 | 13 |
import android.os.Bundle; |
| 15 |
import android.util.DisplayMetrics; |
|
| 16 | 14 |
import android.view.View; |
| 17 | 15 |
import android.view.ViewGroup; |
| 18 |
import android.view.WindowManager; |
|
| 19 | 16 |
|
| 20 |
import androidx.appcompat.app.AppCompatActivity; |
|
| 21 | 17 |
import androidx.preference.PreferenceManager; |
| 22 | 18 |
|
| 23 | 19 |
import org.distorted.dialogs.RubikDialogError; |
| 24 | 20 |
import org.distorted.external.RubikScores; |
| 21 |
import org.distorted.helpers.BaseActivity; |
|
| 25 | 22 |
import org.distorted.library.main.DistortedLibrary; |
| 26 |
import org.distorted.main.MainActivity; |
|
| 27 | 23 |
import org.distorted.main.R; |
| 28 | 24 |
import org.distorted.objectlib.main.InitAssets; |
| 29 | 25 |
import org.distorted.objectlib.main.ObjectControl; |
| ... | ... | |
| 35 | 31 |
|
| 36 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 37 | 33 |
|
| 38 |
public class PurchaseActivity extends AppCompatActivity
|
|
| 34 |
public class PurchaseActivity extends BaseActivity
|
|
| 39 | 35 |
{
|
| 40 | 36 |
private static final int ACTIVITY_NUMBER = 3; |
| 41 | 37 |
private static final float RATIO_UBAR = 0.14f; |
| 42 | 38 |
private static final float RATIO_LBAR = 0.10f; |
| 43 | 39 |
private static final float RATIO_VIEW = 0.50f; |
| 44 |
public static final int FLAGS = MainActivity.FLAGS; |
|
| 45 | 40 |
|
| 46 |
private static int mScreenWidth, mScreenHeight; |
|
| 47 |
private int mCurrentApiVersion; |
|
| 48 | 41 |
private PurchaseScreen mScreen; |
| 49 | 42 |
private int mObjectOrdinal; |
| 50 | 43 |
|
| ... | ... | |
| 53 | 46 |
@Override |
| 54 | 47 |
protected void onCreate(Bundle savedState) |
| 55 | 48 |
{
|
| 56 |
setTheme(R.style.MaterialThemeNoActionBar); |
|
| 57 | 49 |
super.onCreate(savedState); |
| 58 | 50 |
DistortedLibrary.onCreate(ACTIVITY_NUMBER); |
| 59 | 51 |
setContentView(R.layout.purchase); |
| 60 | 52 |
|
| 61 | 53 |
Bundle b = getIntent().getExtras(); |
| 62 |
|
|
| 63 | 54 |
if(b != null) mObjectOrdinal = b.getInt("obj");
|
| 64 | 55 |
|
| 65 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 66 |
getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics); |
|
| 67 |
mScreenWidth =displaymetrics.widthPixels; |
|
| 68 |
mScreenHeight=displaymetrics.heightPixels; |
|
| 69 |
|
|
| 56 |
computeScreenDimensions(); |
|
| 70 | 57 |
hideNavigationBar(); |
| 71 | 58 |
cutoutHack(); |
| 72 | 59 |
setHeights(); |
| ... | ... | |
| 103 | 90 |
setViewHeight(R.id.purchaseLayoutAll , layHeight); |
| 104 | 91 |
} |
| 105 | 92 |
|
| 106 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 107 |
|
|
| 108 |
private void hideNavigationBar() |
|
| 109 |
{
|
|
| 110 |
mCurrentApiVersion = Build.VERSION.SDK_INT; |
|
| 111 |
|
|
| 112 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT) |
|
| 113 |
{
|
|
| 114 |
final View decorView = getWindow().getDecorView(); |
|
| 115 |
|
|
| 116 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 117 |
|
|
| 118 |
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() |
|
| 119 |
{
|
|
| 120 |
@Override |
|
| 121 |
public void onSystemUiVisibilityChange(int visibility) |
|
| 122 |
{
|
|
| 123 |
if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) |
|
| 124 |
{
|
|
| 125 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 126 |
} |
|
| 127 |
} |
|
| 128 |
}); |
|
| 129 |
} |
|
| 130 |
} |
|
| 131 |
|
|
| 132 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 133 |
// do not avoid cutouts |
|
| 134 |
|
|
| 135 |
private void cutoutHack() |
|
| 136 |
{
|
|
| 137 |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) |
|
| 138 |
{
|
|
| 139 |
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; |
|
| 140 |
} |
|
| 141 |
} |
|
| 142 |
|
|
| 143 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 144 |
|
|
| 145 |
@Override |
|
| 146 |
public void onWindowFocusChanged(boolean hasFocus) |
|
| 147 |
{
|
|
| 148 |
super.onWindowFocusChanged(hasFocus); |
|
| 149 |
|
|
| 150 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus) |
|
| 151 |
{
|
|
| 152 |
getWindow().getDecorView().setSystemUiVisibility(FLAGS); |
|
| 153 |
} |
|
| 154 |
} |
|
| 155 |
|
|
| 156 | 93 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 157 | 94 |
|
| 158 | 95 |
@Override |
| ... | ... | |
| 194 | 131 |
DistortedLibrary.onDestroy(ACTIVITY_NUMBER); |
| 195 | 132 |
} |
| 196 | 133 |
|
| 197 |
|
|
| 198 | 134 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 199 | 135 |
|
| 200 | 136 |
private void savePreferences() |
| ... | ... | |
| 233 | 169 |
|
| 234 | 170 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 235 | 171 |
// PUBLIC API |
| 236 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 237 |
|
|
| 238 |
public int getScreenWidthInPixels() |
|
| 239 |
{
|
|
| 240 |
return mScreenWidth; |
|
| 241 |
} |
|
| 242 |
|
|
| 243 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 244 |
|
|
| 245 |
public int getScreenHeightInPixels() |
|
| 246 |
{
|
|
| 247 |
return mScreenHeight; |
|
| 248 |
} |
|
| 249 |
|
|
| 250 | 172 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 251 | 173 |
|
| 252 | 174 |
public ObjectControl getControl() |
| src/main/java/org/distorted/solverui/SolverActivity.java | ||
|---|---|---|
| 12 | 12 |
import android.content.SharedPreferences; |
| 13 | 13 |
import android.os.Build; |
| 14 | 14 |
import android.os.Bundle; |
| 15 |
import android.util.DisplayMetrics; |
|
| 16 | 15 |
import android.view.DisplayCutout; |
| 17 |
import android.view.View; |
|
| 18 | 16 |
import android.view.ViewGroup; |
| 19 |
import android.view.WindowManager; |
|
| 20 | 17 |
import android.widget.LinearLayout; |
| 21 | 18 |
|
| 22 |
import androidx.appcompat.app.AppCompatActivity; |
|
| 23 | 19 |
import androidx.preference.PreferenceManager; |
| 24 | 20 |
|
| 25 | 21 |
import org.distorted.dialogs.RubikDialogError; |
| 26 | 22 |
import org.distorted.dialogs.RubikDialogMessage; |
| 23 |
import org.distorted.helpers.BaseActivity; |
|
| 27 | 24 |
import org.distorted.library.main.DistortedLibrary; |
| 28 | 25 |
import org.distorted.library.main.DistortedScreen; |
| 29 |
import org.distorted.main.MainActivity; |
|
| 30 | 26 |
import org.distorted.main.R; |
| 31 | 27 |
import org.distorted.objectlib.helpers.OperatingSystemInterface; |
| 32 | 28 |
import org.distorted.objectlib.main.InitAssets; |
| ... | ... | |
| 41 | 37 |
|
| 42 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 43 | 39 |
|
| 44 |
public class SolverActivity extends AppCompatActivity
|
|
| 40 |
public class SolverActivity extends BaseActivity
|
|
| 45 | 41 |
{
|
| 46 |
public static final float RATIO_BAR = 0.100f;
|
|
| 42 |
public static final float RATIO_UPP = 0.100f;
|
|
| 47 | 43 |
public static final float PADDING = 0.010f; |
| 48 | 44 |
public static final float SMALL_MARGIN = 0.004f; |
| 49 | 45 |
public static final float BUTTON_TEXT_SIZE= 0.050f; |
| ... | ... | |
| 52 | 48 |
private static final int ACTIVITY_NUMBER = 4; |
| 53 | 49 |
private static final float RATIO_INSET= 0.09f; |
| 54 | 50 |
|
| 55 |
private static int mScreenWidth, mScreenHeight; |
|
| 56 |
private int mCurrentApiVersion; |
|
| 57 |
private int mHeightUpperBar; |
|
| 58 | 51 |
private int mSolverOrdinal; |
| 59 | 52 |
private int mObjectOrdinal; |
| 60 | 53 |
private boolean mDisplayMessageDialog; |
| ... | ... | |
| 64 | 57 |
@Override |
| 65 | 58 |
protected void onCreate(Bundle savedState) |
| 66 | 59 |
{
|
| 67 |
setTheme(R.style.MaterialThemeNoActionBar); |
|
| 68 | 60 |
super.onCreate(savedState); |
| 69 | 61 |
DistortedLibrary.onCreate(ACTIVITY_NUMBER); |
| 70 | 62 |
setContentView(R.layout.solver); |
| 71 |
hideNavigationBar(); |
|
| 72 | 63 |
|
| 73 | 64 |
Bundle b = getIntent().getExtras(); |
| 74 | 65 |
mObjectOrdinal = b!=null ? b.getInt("obj") : 0;
|
| 75 | 66 |
mSolverOrdinal = ImplementedSolversList.getSolverOrdinal(mObjectOrdinal); |
| 76 |
|
|
| 77 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 78 |
getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics); |
|
| 79 |
mScreenWidth =displaymetrics.widthPixels; |
|
| 80 |
mScreenHeight=displaymetrics.heightPixels; |
|
| 81 |
|
|
| 82 | 67 |
mDisplayMessageDialog = true; |
| 83 | 68 |
|
| 69 |
computeScreenDimensions(); |
|
| 70 |
hideNavigationBar(); |
|
| 84 | 71 |
cutoutHack(); |
| 85 |
computeBarHeights(); |
|
| 86 |
} |
|
| 87 |
|
|
| 88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 89 |
// this does not include possible insets |
|
| 90 |
|
|
| 91 |
private void computeBarHeights() |
|
| 92 |
{
|
|
| 93 |
int barHeight = (int)(mScreenHeight*RATIO_BAR); |
|
| 94 |
mHeightUpperBar = barHeight; |
|
| 95 |
|
|
| 96 |
LinearLayout layoutTop = findViewById(R.id.upperBar); |
|
| 97 |
LinearLayout layoutBot = findViewById(R.id.lowerBar); |
|
| 98 |
|
|
| 99 |
ViewGroup.LayoutParams paramsTop = layoutTop.getLayoutParams(); |
|
| 100 |
paramsTop.height = mHeightUpperBar; |
|
| 101 |
layoutTop.setLayoutParams(paramsTop); |
|
| 102 |
ViewGroup.LayoutParams paramsBot = layoutBot.getLayoutParams(); |
|
| 103 |
paramsBot.height = barHeight; |
|
| 104 |
layoutBot.setLayoutParams(paramsBot); |
|
| 105 |
} |
|
| 106 |
|
|
| 107 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 108 |
|
|
| 109 |
private void hideNavigationBar() |
|
| 110 |
{
|
|
| 111 |
mCurrentApiVersion = Build.VERSION.SDK_INT; |
|
| 112 |
|
|
| 113 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT) |
|
| 114 |
{
|
|
| 115 |
final View decorView = getWindow().getDecorView(); |
|
| 116 |
|
|
| 117 |
decorView.setSystemUiVisibility(MainActivity.FLAGS); |
|
| 118 |
|
|
| 119 |
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() |
|
| 120 |
{
|
|
| 121 |
@Override |
|
| 122 |
public void onSystemUiVisibilityChange(int visibility) |
|
| 123 |
{
|
|
| 124 |
if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) |
|
| 125 |
{
|
|
| 126 |
decorView.setSystemUiVisibility(MainActivity.FLAGS); |
|
| 127 |
} |
|
| 128 |
} |
|
| 129 |
}); |
|
| 130 |
} |
|
| 72 |
computeUpperBarHeight(RATIO_UPP); |
|
| 73 |
computeLowerBarHeight(RATIO_BAR); |
|
| 131 | 74 |
} |
| 132 | 75 |
|
| 133 | 76 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 146 | 89 |
ViewGroup.LayoutParams paramsHid = layoutHid.getLayoutParams(); |
| 147 | 90 |
paramsHid.height = (int)(insetHeight*RATIO_INSET); |
| 148 | 91 |
layoutHid.setLayoutParams(paramsHid); |
| 149 |
mHeightUpperBar += paramsHid.height; |
|
| 150 |
} |
|
| 151 |
} |
|
| 152 |
|
|
| 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(MainActivity.FLAGS); |
|
| 174 | 92 |
} |
| 175 | 93 |
} |
| 176 | 94 |
|
| ... | ... | |
| 296 | 214 |
return view.getObjectControl(); |
| 297 | 215 |
} |
| 298 | 216 |
|
| 299 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 300 |
|
|
| 301 |
public int getScreenWidthInPixels() |
|
| 302 |
{
|
|
| 303 |
return mScreenWidth; |
|
| 304 |
} |
|
| 305 |
|
|
| 306 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 307 |
|
|
| 308 |
public int getScreenHeightInPixels() |
|
| 309 |
{
|
|
| 310 |
return mScreenHeight; |
|
| 311 |
} |
|
| 312 |
|
|
| 313 | 217 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 314 | 218 |
|
| 315 | 219 |
public int getSolverOrdinal() |
| 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 |
|
|
Also available in: Unified diff
common code from all activities to one BaseActivity