Project

General

Profile

« Previous | Next » 

Revision 71cda061

Added by Leszek Koltunski over 1 year ago

IAP part 5: new 'Purchase' activity (cont'd)

View differences:

src/main/java/org/distorted/purchase/PurchaseActivity.java
15 15
import android.view.View;
16 16
import android.view.ViewGroup;
17 17
import android.view.WindowManager;
18
import android.widget.LinearLayout;
19 18

  
20 19
import androidx.appcompat.app.AppCompatActivity;
21 20

  
......
34 33
public class PurchaseActivity extends AppCompatActivity
35 34
{
36 35
    private static final int ACTIVITY_NUMBER = 5;
37
    private static final float RATIO_BAR  = 0.10f;
36
    private static final float RATIO_UBAR = 0.14f;
37
    private static final float RATIO_LBAR = 0.10f;
38
    private static final float RATIO_VIEW = 0.50f;
38 39

  
39 40
    public static final float DIALOG_BUTTON_SIZE  = 0.06f;
40 41
    public static final float MENU_BIG_TEXT_SIZE  = 0.05f;
......
49 50
    private int mCurrentApiVersion;
50 51
    private PurchaseScreen mScreen;
51 52
    private int mObjectOrdinal;
52
    private int mHeightBar;
53 53

  
54 54
///////////////////////////////////////////////////////////////////////////////////////////////////
55 55

  
......
72 72

  
73 73
      hideNavigationBar();
74 74
      cutoutHack();
75
      computeBarHeights();
75
      setHeights();
76 76
      }
77 77

  
78 78
///////////////////////////////////////////////////////////////////////////////////////////////////
79
// this does not include possible insets
80 79

  
81
    private void computeBarHeights()
80
    private void setViewHeight(int id, int height)
82 81
      {
83
      int barHeight = (int)(mScreenHeight*RATIO_BAR);
84
      mHeightBar = barHeight;
82
      View view = findViewById(id);
83

  
84
      if( view!=null )
85
        {
86
        ViewGroup.LayoutParams params = view.getLayoutParams();
87
        params.height = height;
88
        view.setLayoutParams(params);
89
        }
90
      }
91

  
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93
// this does not include possible insets
85 94

  
86
      LinearLayout layout = findViewById(R.id.lowerBar);
87
      ViewGroup.LayoutParams params = layout.getLayoutParams();
88
      params.height = barHeight;
89
      layout.setLayoutParams(params);
95
    private void setHeights()
96
      {
97
      int ubarHeight= (int)(mScreenHeight*RATIO_UBAR);
98
      int lbarHeight= (int)(mScreenHeight*RATIO_LBAR);
99
      int viewHeight= (int)(mScreenHeight*RATIO_VIEW);
100
      int layHeight = (int)(mScreenHeight*(1-RATIO_UBAR-RATIO_LBAR-RATIO_VIEW)*0.5f);
101

  
102
      setViewHeight(R.id.upperBar           , ubarHeight);
103
      setViewHeight(R.id.lowerBar           , lbarHeight);
104
      setViewHeight(R.id.purchaseSurfaceView, viewHeight);
105
      setViewHeight(R.id.purchaseLayoutOne  , layHeight);
106
      setViewHeight(R.id.purchaseLayoutAll  , layHeight);
90 107
      }
91 108

  
92 109
///////////////////////////////////////////////////////////////////////////////////////////////////
......
216 233
      changeIfDifferent(object,ordinal,control);
217 234
      }
218 235

  
219
///////////////////////////////////////////////////////////////////////////////////////////////////
220

  
221
    public void changeMeshState(RubikObject object, int ordinal)
222
      {
223
      if( object!=null )
224
        {
225
        PurchaseSurfaceView view = findViewById(R.id.purchaseSurfaceView);
226
        ObjectControl control = view.getObjectControl();
227

  
228
        int meshState          = object.getMeshState();
229
        int iconMode           = TwistyObject.MODE_NORM;
230
        InputStream jsonStream = object.getObjectStream(this);
231
        InputStream meshStream = object.getMeshStream(this);
232

  
233
        control.changeObject(ordinal,meshState,iconMode,jsonStream,meshStream);
234
        }
235
      }
236

  
237
///////////////////////////////////////////////////////////////////////////////////////////////////
238

  
239
    public int getHeightBar()
240
      {
241
      return mHeightBar;
242
      }
243

  
244 236
///////////////////////////////////////////////////////////////////////////////////////////////////
245 237

  
246 238
    public int getScreenWidthInPixels()

Also available in: Unified diff