Project

General

Profile

« Previous | Next » 

Revision 30667941

Added by Leszek Koltunski 11 months ago

improve the object popup in Config Activity.

View differences:

src/main/java/org/distorted/config/ConfigScreen.java
37 37
  private static final float TEXT_SIZE = 0.0310f;
38 38
  private static final float PADDING   = 0.0060f;
39 39
  private static final float MARGIN    = 0.0024f;
40
  private static final int NUM_COLUMNS = 5;
41 40
  private static final int[] mLocation = new int[2];
42
  private static final float POPUP_MARGIN  = 0.016f;
41
  private static final float POPUP_W  = 0.8f;
43 42

  
44 43
  private TransparentImageButton mBackButton, mObjectButton, mPrevButton, mNextButton;
45 44
  private TextView mMovesText;
46 45
  private PopupWindow mObjectPopup;
47 46
  private ConfigScreenPane mPane;
48 47
  private int mObjectOrdinal;
49
  private int mColCount, mRowCount, mMaxRowCount;
50
  private int mObjectSize;
51
  private int mBarHeight;
52 48
  private float mButtonSize;
53 49

  
54 50
///////////////////////////////////////////////////////////////////////////////////////////////////
......
56 52
  private void setupObjectWindow(final ConfigActivity act, final float width, final float height)
57 53
    {
58 54
    int numObjects= RubikObjectList.getNumObjects();
59
    mRowCount = (numObjects + NUM_COLUMNS-1) / NUM_COLUMNS;
60
    mColCount = NUM_COLUMNS;
61

  
62
    int cubeSize  = (int)( (Math.min(width,(int)(height*0.7f))) / 9 );
63
    int margin    = (int)(height*POPUP_MARGIN);
64
    mObjectSize   = (int)(cubeSize + 2*margin + 0.5f);
65
    mMaxRowCount  = (int)((height-mBarHeight)/mObjectSize);
66

  
67 55
    ScrollView view = (ScrollView)inflate( act, R.layout.popup_object_simple, null);
68 56
    GridLayout objectGrid = view.findViewById(R.id.objectGrid);
69 57

  
......
133 121
      @Override
134 122
      public void onClick(View view)
135 123
        {
136
        if( mObjectPopup==null )
137
          {
138
          setupObjectWindow(act,width,height);
139
          }
140

  
141
        int rowCount = Math.min(mMaxRowCount,mRowCount);
124
        if( mObjectPopup==null ) setupObjectWindow(act,width,height);
142 125
        View popupView = mObjectPopup.getContentView();
143 126
        popupView.setSystemUiVisibility(MainActivity.FLAGS);
144
        displayPopup(act,view,mObjectPopup,mObjectSize*mColCount,mObjectSize*rowCount+5*margin,margin,margin);
127
        displayPopup(act,view,mObjectPopup,width,height,margin,margin);
145 128
        }
146 129
      });
147 130
    }
......
279 262
    int numObjects = RubikObjectList.getNumObjects();
280 263
    int width = act.getScreenWidthInPixels();
281 264
    int height= act.getScreenHeightInPixels();
282
    mBarHeight = act.getHeightBar();
265
    int barHeight = act.getHeightBar();
283 266
    mButtonSize = height*TEXT_SIZE;
284 267
    mObjectOrdinal = objectOrdinal;
285 268

  
......
294 277
    LinearLayout layoutRight= new LinearLayout(act);
295 278
    layoutRight.setLayoutParams(paramsR);
296 279

  
297
    setupObjectButton(act,width,height);
280
    int popupW = (int)(POPUP_W*width);
281
    int popupH = (int)(height-barHeight);
282

  
283
    setupObjectButton(act,popupW,popupH);
298 284
    setupPrevButton(act);
299 285
    setupNextButton(act);
300 286
    setupTextView(act,height,numObjects);

Also available in: Unified diff