Project

General

Profile

« Previous | Next » 

Revision 97a4ae23

Added by Leszek Koltunski over 2 years ago

Progress with ConfigScreen.

View differences:

src/main/java/org/distorted/config/ConfigActivity.java
22 22
import android.os.Build;
23 23
import android.os.Bundle;
24 24
import android.util.DisplayMetrics;
25
import android.view.DisplayCutout;
26 25
import android.view.View;
27 26
import android.view.ViewGroup;
28 27
import android.view.WindowManager;
......
39 38
import org.distorted.main.R;
40 39
import org.distorted.objectlib.main.ObjectControl;
41 40
import org.distorted.objectlib.main.ObjectType;
42
import org.distorted.tutorials.TutorialScreen;
43 41

  
44 42
import java.io.InputStream;
45 43

  
......
48 46
public class ConfigActivity extends AppCompatActivity
49 47
{
50 48
    private static final int ACTIVITY_NUMBER = 2;
51
    private static final float RATIO_INSET= 0.08f;
52
    public static final float BAR_RATIO = 0.17f;
49
    private static final float RATIO_BAR  = 0.10f;
53 50

  
54 51
    public static final float DIALOG_BUTTON_SIZE  = 0.06f;
55 52
    public static final float MENU_BIG_TEXT_SIZE  = 0.05f;
......
65 62
    private int mCurrentApiVersion;
66 63
    private ConfigScreen mScreen;
67 64
    private int mObjectOrdinal;
68
    private int mHeightUpperBar;
65
    private int mHeightBar;
69 66

  
70 67
///////////////////////////////////////////////////////////////////////////////////////////////////
71 68

  
......
87 84
      getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
88 85
      mScreenWidth =displaymetrics.widthPixels;
89 86
      mScreenHeight=displaymetrics.heightPixels;
90

  
87
      mScreenHeight = (int)(1.07f*mScreenHeight); // add 7% for the upper bar
88
                                                  // which is not yet hidden.
89
                                                  // TODO: figure this out exactly.
91 90
      hideNavigationBar();
92 91
      cutoutHack();
92
      computeBarHeights();
93
      }
94

  
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96
// this does not include possible insets
97

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

  
103
      LinearLayout layout = findViewById(R.id.lowerBar);
104
      ViewGroup.LayoutParams params = layout.getLayoutParams();
105
      params.height = barHeight;
106
      layout.setLayoutParams(params);
93 107
      }
94 108

  
95 109
///////////////////////////////////////////////////////////////////////////////////////////////////
......
125 139
      {
126 140
      super.onAttachedToWindow();
127 141

  
128
      int insetHeight = 0;
129

  
130
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
131
        {
132
        DisplayCutout cutout = getWindow().getDecorView().getRootWindowInsets().getDisplayCutout();
133
        insetHeight = cutout!=null ? cutout.getSafeInsetTop() : 0;
134
        }
135

  
136
      LinearLayout layoutHid = findViewById(R.id.hiddenBar);
137
      ViewGroup.LayoutParams paramsHid = layoutHid.getLayoutParams();
138
      paramsHid.height = (int)(insetHeight*RATIO_INSET);
139
      layoutHid.setLayoutParams(paramsHid);
140
      mHeightUpperBar += paramsHid.height;
141

  
142 142
      if( mScreen==null ) mScreen = new ConfigScreen();
143
      mScreen.createScreen(this);
143
      mScreen.enterScreen(this,mObjectOrdinal);
144 144
      }
145 145

  
146 146
///////////////////////////////////////////////////////////////////////////////////////////////////
......
221 221
      control.changeIfDifferent(type.ordinal(),jsonStream,meshStream);
222 222
      }
223 223

  
224
///////////////////////////////////////////////////////////////////////////////////////////////////
225

  
226
    ConfigScreen getState()
227
      {
228
      return mScreen;
229
      }
230

  
231 224
///////////////////////////////////////////////////////////////////////////////////////////////////
232 225
// PUBLIC API
233 226
///////////////////////////////////////////////////////////////////////////////////////////////////
......
239 232

  
240 233
///////////////////////////////////////////////////////////////////////////////////////////////////
241 234

  
242
    public int getHeightUpperBar()
235
    public int getHeightBar()
243 236
      {
244
      return mHeightUpperBar;
237
      return mHeightBar;
245 238
      }
246 239

  
247 240
///////////////////////////////////////////////////////////////////////////////////////////////////
......
251 244
      return mScreenWidth;
252 245
      }
253 246

  
247
///////////////////////////////////////////////////////////////////////////////////////////////////
248

  
249
    public int getScreenHeightInPixels()
250
      {
251
      return mScreenHeight;
252
      }
253

  
254 254
///////////////////////////////////////////////////////////////////////////////////////////////////
255 255

  
256 256
    public ObjectControl getControl()
......
301 301
      ConfigSurfaceView view = findViewById(R.id.configSurfaceView);
302 302
      return view.isVertical();
303 303
      }
304

  
305
///////////////////////////////////////////////////////////////////////////////////////////////////
306

  
307
    public void changeObject(ObjectType newObject)
308
      {
309
      ConfigSurfaceView view = findViewById(R.id.configSurfaceView);
310
      ObjectControl control = view.getObjectControl();
311
      changeIfDifferent(newObject,control);
312
      }
304 313
}

Also available in: Unified diff