Project

General

Profile

« Previous | Next » 

Revision b600ccd9

Added by Leszek Koltunski over 2 years ago

Add info pane: part 1.

View differences:

src/main/java/org/distorted/screens/RubikScreenPlay.java
21 21

  
22 22
import android.content.Context;
23 23
import android.content.SharedPreferences;
24
import android.content.res.Resources;
24 25
import android.graphics.drawable.BitmapDrawable;
25 26
import android.os.Build;
26 27
import android.os.Bundle;
......
33 34
import android.widget.ImageButton;
34 35
import android.widget.LinearLayout;
35 36
import android.widget.PopupWindow;
36
import android.widget.ScrollView;
37 37

  
38 38
import org.distorted.objectlib.main.ObjectControl;
39 39
import org.distorted.objectlib.main.ObjectType;
......
48 48
import org.distorted.helpers.TransparentImageButton;
49 49
import org.distorted.network.RubikScores;
50 50

  
51
import static android.view.View.inflate;
51 52
import static org.distorted.objectlib.main.ObjectType.NUM_OBJECTS;
52 53

  
53 54
///////////////////////////////////////////////////////////////////////////////////////////////////
......
69 70
  private static final float LAST_BUTTON = 1.5f;
70 71
  private static final int[] mLocation = new int[2];
71 72

  
72
  private TransparentImageButton mObjButton, mMenuButton, mSolveButton, mScrambleButton;
73
  private TransparentImageButton mObjButton, mMenuButton, mSolveButton, mScrambleButton, mDetailsButton;
73 74
  private TransparentButton mPlayButton;
74 75
  private PopupWindow mObjectPopup, mMenuPopup, mPlayPopup;
75 76
  private ObjectType mObject = DEF_OBJECT;
......
140 141
    {
141 142
    final int margin  = (int)(width*RubikActivity.MARGIN);
142 143
    final int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_menu,R.drawable.ui_medium_cube_menu, R.drawable.ui_big_cube_menu, R.drawable.ui_huge_cube_menu);
143

  
144
    mObjButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_MIDDLE);
144
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
145
    mObjButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
145 146

  
146 147
    mObjButton.setOnClickListener( new View.OnClickListener()
147 148
      {
......
207 208
    {
208 209
    final int margin = (int)(width*RubikActivity.MARGIN);
209 210
    final int icon = RubikActivity.getDrawable(R.drawable.ui_small_menu,R.drawable.ui_medium_menu, R.drawable.ui_big_menu, R.drawable.ui_huge_menu);
210

  
211
    mMenuButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_MIDDLE);
211
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
212
    mMenuButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
212 213

  
213 214
    mMenuButton.setOnClickListener( new View.OnClickListener()
214 215
      {
......
237 238
    {
238 239
    int icon = RubikActivity.getDrawable(R.drawable.cube_2s,R.drawable.cube_2m, R.drawable.cube_2b, R.drawable.cube_2h);
239 240

  
240
    BitmapDrawable bd = (BitmapDrawable) act.getResources().getDrawable(icon);
241
    Resources res = act.getResources();
242
    BitmapDrawable bd = (BitmapDrawable)res.getDrawable(icon);
241 243
    int cubeWidth = bd.getIntrinsicWidth();
242 244
    int margin = (int)(width*RubikActivity.LARGE_MARGIN);
243 245
    mObjectSize = (int)(cubeWidth + 2*margin + 0.5f);
244
    mMaxRowCount = (int)(0.9f*(height-mUpperBarHeight)/mObjectSize);
245
    GridLayout objectGrid = new GridLayout(act);
246
    mObjectPopup = new PopupWindow(act);
247
    mObjectPopup.setFocusable(true);
246
    mMaxRowCount = (int)((height-2.0f*mUpperBarHeight)/mObjectSize);
248 247

  
249
    if( mMaxRowCount<mRowCount )
250
      {
251
      ScrollView scrollView = new ScrollView(act);
252
      scrollView.addView(objectGrid);
253
      mObjectPopup.setContentView(scrollView);
254
      }
255
    else
256
      {
257
      mObjectPopup.setContentView(objectGrid);
258
      }
248
    int viewID = mMaxRowCount<mRowCount ? R.layout.popup_object_withscroll : R.layout.popup_object_scrollless;
249
    View view = inflate( act, viewID, null);
250
    GridLayout objectGrid = view.findViewById(R.id.objectGrid);
259 251

  
260 252
    GridLayout.Spec[] rowSpecs = new GridLayout.Spec[mRowCount];
261 253
    GridLayout.Spec[] colSpecs = new GridLayout.Spec[mColCount];
......
263 255
    objectGrid.setColumnCount(mColCount);
264 256
    objectGrid.setRowCount(mRowCount);
265 257

  
258
    LinearLayout bottomLayout = view.findViewById(R.id.bottomLayout);
259
    setupDetailsButton(act);
260
    bottomLayout.addView(mDetailsButton);
261

  
262
    mObjectPopup = new PopupWindow(act);
263
    mObjectPopup.setFocusable(true);
264
    mObjectPopup.setContentView(view);
265

  
266 266
    int[] nextInRow = new int[mRowCount];
267 267

  
268 268
    for(int row=0; row<mRowCount; row++)
......
398 398
      }
399 399
    }
400 400

  
401
///////////////////////////////////////////////////////////////////////////////////////////////////
402

  
403
  void setupDetailsButton(final RubikActivity act)
404
    {
405
    int butWidth = 100;
406
    int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_solve_new,R.drawable.ui_medium_cube_solve_new, R.drawable.ui_big_cube_solve_new, R.drawable.ui_huge_cube_solve_new);
407
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(butWidth,LinearLayout.LayoutParams.MATCH_PARENT);
408
    mDetailsButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
409

  
410
    mDetailsButton.setOnClickListener( new View.OnClickListener()
411
      {
412
      @Override
413
      public void onClick(View v)
414
        {
415
        android.util.Log.e("D", "DETAILS CLICKED!!");
416
        }
417
      });
418
    }
419

  
401 420
///////////////////////////////////////////////////////////////////////////////////////////////////
402 421

  
403 422
  void setupSolveButton(final RubikActivity act)
404 423
    {
405 424
    int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_solve_new,R.drawable.ui_medium_cube_solve_new, R.drawable.ui_big_cube_solve_new, R.drawable.ui_huge_cube_solve_new);
406
    mSolveButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_END);
425
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
426
    mSolveButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_END,params);
407 427

  
408 428
    mSolveButton.setOnClickListener( new View.OnClickListener()
409 429
      {
......
421 441
  private void setupScrambleButton(final RubikActivity act)
422 442
    {
423 443
    int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_scramble_new,R.drawable.ui_medium_cube_scramble_new, R.drawable.ui_big_cube_scramble_new, R.drawable.ui_huge_cube_scramble_new);
424
    mScrambleButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_START);
444
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
445
    mScrambleButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_START, params);
425 446

  
426 447
    mScrambleButton.setOnClickListener( new View.OnClickListener()
427 448
      {

Also available in: Unified diff