Revision fd0b901a
Added by Leszek Koltunski about 4 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.DisplayCutout; |
|
30 | 31 |
import android.view.View; |
31 | 32 |
import android.view.ViewGroup; |
32 | 33 |
import android.view.WindowManager; |
... | ... | |
106 | 107 |
mIsLocked = false; |
107 | 108 |
|
108 | 109 |
hideNavigationBar(); |
109 |
huaweiHack(); |
|
110 | 110 |
|
111 |
// huaweiHack(); |
|
111 | 112 |
// askForPermissions(); |
112 | 113 |
} |
113 | 114 |
|
... | ... | |
142 | 143 |
@Override |
143 | 144 |
public void onAttachedToWindow() |
144 | 145 |
{ |
146 |
super.onAttachedToWindow(); |
|
147 |
|
|
145 | 148 |
final float RATIO = 0.10f; |
146 | 149 |
float height = getScreenHeightInPixels(); |
147 | 150 |
|
... | ... | |
154 | 157 |
ViewGroup.LayoutParams paramsBot = layoutBot.getLayoutParams(); |
155 | 158 |
paramsBot.height = (int)(height*RATIO); |
156 | 159 |
layoutBot.setLayoutParams(paramsBot); |
160 |
|
|
161 |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) |
|
162 |
{ |
|
163 |
DisplayCutout cutout = getWindow().getDecorView().getRootWindowInsets().getDisplayCutout(); |
|
164 |
int inset = cutout!=null ? cutout.getSafeInsetTop() : 0; |
|
165 |
RubikStatePlay.setSafeInsetTop(inset); |
|
166 |
} |
|
157 | 167 |
} |
158 | 168 |
|
159 | 169 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/states/RubikStatePlay.java | ||
---|---|---|
24 | 24 |
import android.graphics.drawable.BitmapDrawable; |
25 | 25 |
import android.os.Bundle; |
26 | 26 |
import android.util.TypedValue; |
27 |
import android.view.Gravity; |
|
28 | 27 |
import android.view.LayoutInflater; |
29 | 28 |
import android.view.View; |
30 | 29 |
import android.widget.Button; |
... | ... | |
56 | 55 |
private static int[] BUTTON_LABELS = { R.string.scores, R.string.patterns, R.string.solver, R.string.about }; |
57 | 56 |
private static final int NUM_BUTTONS = BUTTON_LABELS.length; |
58 | 57 |
|
58 |
private static int mSafeInsetTop; |
|
59 |
|
|
59 | 60 |
private ImageButton mObjButton, mMenuButton, mPrevButton, mSolveButton, mLockButton; |
60 | 61 |
private Button mPlayButton; |
61 | 62 |
private PopupWindow mObjectPopup, mMenuPopup, mPlayPopup; |
... | ... | |
175 | 176 |
View popupView = mObjectPopup.getContentView(); |
176 | 177 |
popupView.setSystemUiVisibility(RubikActivity.FLAGS); |
177 | 178 |
|
178 |
mObjectPopup.showAsDropDown(view, margin, margin, Gravity.LEFT);
|
|
179 |
mObjectPopup.showAsDropDown(view, margin, margin + mSafeInsetTop);
|
|
179 | 180 |
mObjectPopup.update(view, mObjectSize*mColCount, mObjectSize*mRowCount); |
180 | 181 |
|
181 | 182 |
mObjectPopup.setFocusable(true); |
... | ... | |
214 | 215 |
final int maxLevel = ObjectList.getMaxLevel(mObject, sizeIndex); |
215 | 216 |
final int levelsShown = Math.min(maxLevel,LEVELS_SHOWN); |
216 | 217 |
|
217 |
mPlayPopup.showAsDropDown(view, margin, margin, Gravity.RIGHT);
|
|
218 |
mPlayPopup.showAsDropDown(view, margin, margin + mSafeInsetTop);
|
|
218 | 219 |
mPlayPopup.update(view, mPlayLayoutWidth, (int)(levelsShown*(mMenuItemSize+margin)+2*margin)); |
219 | 220 |
|
220 | 221 |
mPlayPopup.setFocusable(true); |
... | ... | |
251 | 252 |
View popupView = mMenuPopup.getContentView(); |
252 | 253 |
popupView.setSystemUiVisibility(RubikActivity.FLAGS); |
253 | 254 |
|
254 |
mMenuPopup.showAsDropDown(view, (int)(-width/12), margin, Gravity.CENTER);
|
|
255 |
mMenuPopup.showAsDropDown(view, (int)(-width/12), margin + mSafeInsetTop);
|
|
255 | 256 |
mMenuPopup.update(view, mMenuLayoutWidth, mMenuLayoutHeight); |
256 | 257 |
|
257 | 258 |
mMenuPopup.setFocusable(true); |
... | ... | |
662 | 663 |
} |
663 | 664 |
} |
664 | 665 |
|
666 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
667 |
|
|
668 |
public static void setSafeInsetTop(int top) |
|
669 |
{ |
|
670 |
mSafeInsetTop = top; |
|
671 |
} |
|
672 |
|
|
665 | 673 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
666 | 674 |
|
667 | 675 |
public int getLevel() |
Also available in: Unified diff
Avoid the possible cutouts at the top of the screen.