Project

General

Profile

« Previous | Next » 

Revision dc78f395

Added by Leszek Koltunski over 3 years ago

Fix play screen popups in case the whole app is in 'multi-window' or 'pop-up window' state.

View differences:

src/main/java/org/distorted/screens/RubikScreenPlay.java
24 24
import android.graphics.drawable.BitmapDrawable;
25 25
import android.os.Bundle;
26 26
import android.util.TypedValue;
27
import android.view.Gravity;
28 27
import android.view.LayoutInflater;
29 28
import android.view.View;
30 29
import android.widget.Button;
......
34 33
import android.widget.PopupWindow;
35 34
import android.widget.ScrollView;
36 35

  
37
import org.distorted.control.RubikControl;
38 36
import org.distorted.dialogs.RubikDialogAbout;
39 37
import org.distorted.dialogs.RubikDialogPattern;
40 38
import org.distorted.dialogs.RubikDialogScores;
......
64 62

  
65 63
  private static final int NUM_BUTTONS = BUTTON_LABELS.length;
66 64
  private static final float LAST_BUTTON = 1.5f;
65
  private static final int[] mLocation = new int[2];
67 66

  
68 67
  private ImageButton mObjButton, mMenuButton, mSolveButton;
69 68
  private Button mPlayButton;
......
122 121
  private void setupObjectButton(final RubikActivity act, final float width)
123 122
    {
124 123
    final int margin  = (int)(width*RubikActivity.MARGIN);
124
    final int upperBarHeight = act.getHeightUpperBar();
125 125
    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);
126

  
126 127
    mObjButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT);
127 128

  
128 129
    mObjButton.setOnClickListener( new View.OnClickListener()
......
133 134
        if( mObjectPopup!=null && act.getPreRender().isUINotBlocked())
134 135
          {
135 136
          int rowCount = Math.min(mMaxRowCount,mRowCount);
136

  
137 137
          View popupView = mObjectPopup.getContentView();
138 138
          popupView.setSystemUiVisibility(RubikActivity.FLAGS);
139 139

  
140
          mObjectPopup.showAsDropDown(view, margin, margin);
141
          mObjectPopup.update(view, mObjectSize*mColCount, mObjectSize*rowCount);
140
          view.getLocationOnScreen(mLocation);
141
          final int x = mLocation[0];
142
          final int y = mLocation[1]+upperBarHeight+margin;
143

  
144
          mObjectPopup.showAsDropDown(view);
145
          mObjectPopup.update(x,y,mObjectSize*mColCount,mObjectSize*rowCount);
142 146
          }
143 147
        }
144 148
      });
......
149 153
  private void setupPlayButton(final RubikActivity act, final float width, final float height)
150 154
    {
151 155
    final int margin   = (int)(width*RubikActivity.MARGIN);
152
    int upperBarHeight = act.getHeightUpperBar();
156
    final int upperBarHeight = act.getHeightUpperBar();
153 157
    final int maxHeight= (int)(0.9f*(height-upperBarHeight) );
154 158

  
155 159
    mPlayButton = new TransparentButton(act, R.string.play, mButtonSize, width);
......
164 168
          View popupView = mPlayPopup.getContentView();
165 169
          popupView.setSystemUiVisibility(RubikActivity.FLAGS);
166 170

  
171
          view.getLocationOnScreen(mLocation);
172
          int width = view.getWidth();
173

  
167 174
          final int sizeIndex = ObjectList.getSizeIndex(mObject,mSize);
168 175
          final int dbLevel = ObjectList.getDBLevel(mObject, sizeIndex);
169 176
          final int levelsShown = Math.min(dbLevel,LEVELS_SHOWN);
170 177
          final int popupHeight = (int)(levelsShown*(mMenuItemSize+margin)+3*margin+mMenuItemSize*(LAST_BUTTON-1.0f));
178
          final int realHeight  = Math.min(popupHeight,maxHeight);
179
          final int x = mLocation[0]+width-mPlayLayoutWidth;
180
          final int y = mLocation[1]+upperBarHeight+margin;
171 181

  
172
          mPlayPopup.showAsDropDown(view, margin, margin);
173
          mPlayPopup.update(view, mPlayLayoutWidth, Math.min(popupHeight,maxHeight));
182
          mPlayPopup.showAsDropDown(view);
183
          mPlayPopup.update(x,y,mPlayLayoutWidth,realHeight);
174 184
          }
175 185
        }
176 186
      });
......
182 192
    {
183 193
    final int margin  = (int)(width*RubikActivity.MARGIN);
184 194
    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);
195
    final int upperBarHeight = act.getHeightUpperBar();
196

  
185 197
    mMenuButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT);
186 198

  
187 199
    mMenuButton.setOnClickListener( new View.OnClickListener()
......
194 206
          View popupView = mMenuPopup.getContentView();
195 207
          popupView.setSystemUiVisibility(RubikActivity.FLAGS);
196 208

  
197
          mMenuPopup.showAsDropDown(view, (int)(-width/12), margin, Gravity.CENTER);
198
          mMenuPopup.update(view, mMenuLayoutWidth, mMenuLayoutHeight);
209
          view.getLocationOnScreen(mLocation);
210
          int width = view.getWidth();
211
          final int x = mLocation[0]+(width-mMenuLayoutWidth)/2;
212
          final int y = mLocation[1]+upperBarHeight+margin;
213

  
214
          mMenuPopup.showAsDropDown(view);
215
          mMenuPopup.update(x,y,mMenuLayoutWidth,mMenuLayoutHeight);
199 216
          }
200 217
        }
201 218
      });
......
212 229
    int margin = (int)(width*RubikActivity.LARGE_MARGIN);
213 230
    mObjectSize = (int)(cubeWidth + 2*margin + 0.5f);
214 231
    int upperBarHeight  = act.getHeightUpperBar();
215
    mMaxRowCount = (int)((height-upperBarHeight)/mObjectSize);
232
    mMaxRowCount = (int)(0.9f*(height-upperBarHeight)/mObjectSize);
216 233
    GridLayout objectGrid = new GridLayout(act);
217 234
    mObjectPopup = new PopupWindow(act);
218 235
    mObjectPopup.setFocusable(true);

Also available in: Unified diff