Project

General

Profile

« Previous | Next » 

Revision f3563327

Added by Leszek Koltunski about 2 years ago

Bandaged 3x3: solve and scramble buttons.

View differences:

src/main/java/org/distorted/bandaged/BandagedPlayActivity.java
22 22
import android.os.Build;
23 23
import android.os.Bundle;
24 24
import android.util.DisplayMetrics;
25
import android.view.DisplayCutout;
25 26
import android.view.View;
26 27
import android.view.ViewGroup;
27 28
import android.view.WindowManager;
......
46 47
{
47 48
    private static final int ACTIVITY_NUMBER = 4;
48 49
    private static final float RATIO_BAR  = 0.10f;
50
    private static final float RATIO_INSET= 0.09f;
49 51

  
50 52
    public static final float DIALOG_BUTTON_SIZE  = 0.06f;
51 53
    public static final float MENU_BIG_TEXT_SIZE  = 0.05f;
52
    public static final float BUTTON_TEXT_SIZE    = 0.05f;
53 54

  
54 55
    public static final int FLAGS =  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
55 56
                                   | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
......
62 63
    private int mCurrentApiVersion;
63 64
    private BandagedPlayScreen mScreen;
64 65
    private String mObjectName;
65
    private int mHeightBar;
66
    private int mHeightLowerBar, mHeightUpperBar;
66 67

  
67 68
///////////////////////////////////////////////////////////////////////////////////////////////////
68 69

  
......
96 97

  
97 98
    private void computeBarHeights()
98 99
      {
99
      int barHeight = (int)(mScreenHeight*RATIO_BAR);
100
      mHeightBar = barHeight;
101

  
102
      LinearLayout layout = findViewById(R.id.lowerBar);
103
      ViewGroup.LayoutParams params = layout.getLayoutParams();
104
      params.height = barHeight;
105
      layout.setLayoutParams(params);
100
      float height = mScreenHeight;
101
      int barHeight = (int)(height*RATIO_BAR);
102
      mHeightLowerBar = barHeight;
103
      mHeightUpperBar = barHeight;
104

  
105
      LinearLayout layoutTop = findViewById(R.id.upperBar);
106
      LinearLayout layoutBot = findViewById(R.id.lowerBar);
107

  
108
      ViewGroup.LayoutParams paramsTop = layoutTop.getLayoutParams();
109
      paramsTop.height = mHeightUpperBar;
110
      layoutTop.setLayoutParams(paramsTop);
111
      ViewGroup.LayoutParams paramsBot = layoutBot.getLayoutParams();
112
      paramsBot.height = mHeightLowerBar;
113
      layoutBot.setLayoutParams(paramsBot);
106 114
      }
107 115

  
108 116
///////////////////////////////////////////////////////////////////////////////////////////////////
......
131 139
        }
132 140
      }
133 141

  
142
///////////////////////////////////////////////////////////////////////////////////////////////////
143

  
144
    @Override
145
    public void onAttachedToWindow()
146
      {
147
      super.onAttachedToWindow();
148

  
149
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
150
        {
151
        DisplayCutout cutout = getWindow().getDecorView().getRootWindowInsets().getDisplayCutout();
152
        int insetHeight = cutout!=null ? cutout.getSafeInsetTop() : 0;
153

  
154
        LinearLayout layoutHid = findViewById(R.id.hiddenBar);
155
        ViewGroup.LayoutParams paramsHid = layoutHid.getLayoutParams();
156
        paramsHid.height = (int)(insetHeight*RATIO_INSET);
157
        layoutHid.setLayoutParams(paramsHid);
158
        mHeightUpperBar += paramsHid.height;
159
        }
160
      }
161

  
134 162
///////////////////////////////////////////////////////////////////////////////////////////////////
135 163
// do not avoid cutouts
136 164

  
......
177 205
      view.onResume();
178 206

  
179 207
      if( mScreen==null ) mScreen = new BandagedPlayScreen();
180
      mScreen.onAttachedToWindow(this,mObjectName);
208
      mScreen.onAttachedToWindow(this);
181 209

  
182 210
      if( mObjectName.length()>0 )
183 211
        {
......
240 268

  
241 269
    public int getHeightBar()
242 270
      {
243
      return mHeightBar;
271
      return mHeightLowerBar;
244 272
      }
245 273

  
246 274
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff