1 |
211b48f2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2020 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Magic Cube. //
|
5 |
|
|
// //
|
6 |
3782bd44
|
Leszek Koltunski
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
7 |
|
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
8 |
211b48f2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9 |
|
|
|
10 |
fcd5b990
|
Leszek Koltunski
|
package org.distorted.screens;
|
11 |
211b48f2
|
Leszek Koltunski
|
|
12 |
179f7189
|
Leszek Koltunski
|
import java.lang.ref.WeakReference;
|
13 |
|
|
|
14 |
|
|
import android.app.Activity;
|
15 |
4c0cd600
|
Leszek Koltunski
|
import android.content.Context;
|
16 |
211b48f2
|
Leszek Koltunski
|
import android.content.SharedPreferences;
|
17 |
be65535e
|
Leszek Koltunski
|
import android.content.res.ColorStateList;
|
18 |
8a47642f
|
Leszek Koltunski
|
import android.content.res.Resources;
|
19 |
255492a0
|
Leszek Koltunski
|
import android.os.Build;
|
20 |
e03e0352
|
Leszek Koltunski
|
import android.os.Bundle;
|
21 |
e3c74c0f
|
Leszek Koltunski
|
import android.util.TypedValue;
|
22 |
255492a0
|
Leszek Koltunski
|
import android.view.Gravity;
|
23 |
211b48f2
|
Leszek Koltunski
|
import android.view.LayoutInflater;
|
24 |
|
|
import android.view.View;
|
25 |
|
|
import android.widget.Button;
|
26 |
e07c48a2
|
Leszek Koltunski
|
import android.widget.GridLayout;
|
27 |
211b48f2
|
Leszek Koltunski
|
import android.widget.ImageButton;
|
28 |
|
|
import android.widget.LinearLayout;
|
29 |
4c0cd600
|
Leszek Koltunski
|
import android.widget.PopupWindow;
|
30 |
d6e7c7fb
|
Leszek Koltunski
|
import android.widget.RelativeLayout;
|
31 |
10373dc7
|
Leszek Koltunski
|
import android.widget.TextView;
|
32 |
211b48f2
|
Leszek Koltunski
|
|
33 |
93a1c364
|
Leszek Koltunski
|
import org.distorted.dialogs.RubikDialogSolvers;
|
34 |
6b034729
|
Leszek Koltunski
|
import org.distorted.dialogs.RubikDialogStarsStatus;
|
35 |
5f3801d3
|
Leszek Koltunski
|
import org.distorted.dialogs.RubikDialogUpdates;
|
36 |
34d6b123
|
Leszek Koltunski
|
import org.distorted.dialogs.RubikDialogWhatsNew;
|
37 |
acabdd83
|
Leszek Koltunski
|
import org.distorted.external.RubikNetwork;
|
38 |
1088a219
|
Leszek Koltunski
|
import org.distorted.external.RubikScores;
|
39 |
acabdd83
|
Leszek Koltunski
|
import org.distorted.external.RubikUpdates;
|
40 |
3f7a4363
|
Leszek Koltunski
|
|
41 |
432a5f2c
|
Leszek Koltunski
|
import org.distorted.helpers.PopupCreator;
|
42 |
3f7a4363
|
Leszek Koltunski
|
import org.distorted.main.R;
|
43 |
|
|
import org.distorted.main.RubikActivity;
|
44 |
a8576d91
|
Leszek Koltunski
|
import org.distorted.dialogs.RubikDialogPattern;
|
45 |
e03e0352
|
Leszek Koltunski
|
import org.distorted.dialogs.RubikDialogScores;
|
46 |
234a7582
|
Leszek Koltunski
|
import org.distorted.dialogs.RubikDialogTutorial;
|
47 |
55e6be1d
|
Leszek Koltunski
|
import org.distorted.helpers.TransparentImageButton;
|
48 |
b1629e16
|
Leszek Koltunski
|
import org.distorted.objectlib.effects.BaseEffect;
|
49 |
4f3e2d90
|
Leszek Koltunski
|
import org.distorted.objectlib.main.ObjectControl;
|
50 |
d433b50e
|
Leszek Koltunski
|
import org.distorted.objects.RubikObject;
|
51 |
|
|
import org.distorted.objects.RubikObjectList;
|
52 |
211b48f2
|
Leszek Koltunski
|
|
53 |
6b034729
|
Leszek Koltunski
|
import static android.view.View.GONE;
|
54 |
b600ccd9
|
Leszek Koltunski
|
import static android.view.View.inflate;
|
55 |
6b034729
|
Leszek Koltunski
|
import static org.distorted.main.RubikActivity.USE_IAP;
|
56 |
88d28110
|
Leszek Koltunski
|
|
57 |
211b48f2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
58 |
|
|
|
59 |
63dd19c4
|
Leszek Koltunski
|
public class RubikScreenPlay extends RubikScreenBase implements RubikNetwork.Updatee
|
60 |
211b48f2
|
Leszek Koltunski
|
{
|
61 |
cc0fc0c5
|
Leszek Koltunski
|
private static final float MENU_BUTTON_HEIGHT = 0.068f;
|
62 |
|
|
private static final float MENU_TEXT_SIZE = 0.027f;
|
63 |
24cd23dd
|
Leszek Koltunski
|
private static final float MENU_MARGIN = 0.008f;
|
64 |
09bcbc45
|
Leszek Koltunski
|
private static final float MENU_WIDTH = 0.650f;
|
65 |
|
|
private static final float LEVEL_BUTTON_HEIGHT = 0.089f;
|
66 |
24cd23dd
|
Leszek Koltunski
|
|
67 |
6e3fcb91
|
Leszek Koltunski
|
public static final int NUM_COLUMNS = 5;
|
68 |
adbd16d9
|
Leszek Koltunski
|
public static final int LEVELS_SHOWN = 8;
|
69 |
dc78f395
|
Leszek Koltunski
|
private static final int[] mLocation = new int[2];
|
70 |
e03e0352
|
Leszek Koltunski
|
|
71 |
756f152c
|
Leszek Koltunski
|
private TransparentImageButton mObjButton, mMenuButton, mSolveButton, mScrambleButton;
|
72 |
4f3e2d90
|
Leszek Koltunski
|
private PopupWindow mObjectPopup, mMenuPopup;
|
73 |
|
|
private WeakReference<RubikActivity> mWeakAct;
|
74 |
10373dc7
|
Leszek Koltunski
|
private TextView mBubbleUpdates;
|
75 |
1088a219
|
Leszek Koltunski
|
private Button[] mLevel;
|
76 |
369a0fce
|
Leszek Koltunski
|
private int mObjectSize, mMenuLayoutWidth, mMenuLayoutHeight, mMenuButtonHeight, mMenuTextSize;
|
77 |
85b09df4
|
Leszek Koltunski
|
private int mLevelValue;
|
78 |
598de3ee
|
Leszek Koltunski
|
private int mColCount, mRowCount, mMaxRowCount;
|
79 |
255492a0
|
Leszek Koltunski
|
private int mUpperBarHeight;
|
80 |
dd874ae8
|
Leszek Koltunski
|
private boolean mShouldReactToEndOfScrambling;
|
81 |
9dfb553f
|
Leszek Koltunski
|
private float mScreenWidth, mScreenHeight;
|
82 |
24cd23dd
|
Leszek Koltunski
|
private int mLevelHeight, mLevelWidth;
|
83 |
2011391d
|
Leszek Koltunski
|
private int mOldNumScramble;
|
84 |
255492a0
|
Leszek Koltunski
|
|
85 |
211b48f2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
86 |
|
|
|
87 |
f5da732a
|
Leszek Koltunski
|
void leaveScreen(RubikActivity act)
|
88 |
211b48f2
|
Leszek Koltunski
|
{
|
89 |
85b09df4
|
Leszek Koltunski
|
|
90 |
211b48f2
|
Leszek Koltunski
|
}
|
91 |
|
|
|
92 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
93 |
|
|
|
94 |
f5da732a
|
Leszek Koltunski
|
void enterScreen(final RubikActivity act)
|
95 |
211b48f2
|
Leszek Koltunski
|
{
|
96 |
179f7189
|
Leszek Koltunski
|
mWeakAct = new WeakReference<>(act);
|
97 |
9dfb553f
|
Leszek Koltunski
|
mScreenWidth = act.getScreenWidthInPixels();
|
98 |
|
|
mScreenHeight = act.getScreenHeightInPixels();
|
99 |
255492a0
|
Leszek Koltunski
|
mUpperBarHeight = act.getHeightUpperBar();
|
100 |
a8576d91
|
Leszek Koltunski
|
|
101 |
24cd23dd
|
Leszek Koltunski
|
mMenuButtonHeight = (int)(mScreenHeight*MENU_BUTTON_HEIGHT);
|
102 |
|
|
mMenuTextSize = (int)(mScreenHeight*MENU_TEXT_SIZE);
|
103 |
e3c74c0f
|
Leszek Koltunski
|
|
104 |
ac1900c3
|
Leszek Koltunski
|
mObjectPopup = null;
|
105 |
e07c48a2
|
Leszek Koltunski
|
|
106 |
211b48f2
|
Leszek Koltunski
|
// TOP ////////////////////////////
|
107 |
7289fd6c
|
Leszek Koltunski
|
LinearLayout layoutTop = act.findViewById(R.id.upperBar);
|
108 |
211b48f2
|
Leszek Koltunski
|
layoutTop.removeAllViews();
|
109 |
85b09df4
|
Leszek Koltunski
|
|
110 |
c1df05fa
|
Leszek Koltunski
|
setupSolveButton(act);
|
111 |
|
|
layoutTop.addView(mSolveButton);
|
112 |
24cd23dd
|
Leszek Koltunski
|
setupMenuButton(act,mScreenWidth, mScreenHeight);
|
113 |
0254cfd7
|
Leszek Koltunski
|
layoutTop.addView(mMenuButton);
|
114 |
756f152c
|
Leszek Koltunski
|
setupScrambleButton(act);
|
115 |
c1df05fa
|
Leszek Koltunski
|
layoutTop.addView(mScrambleButton);
|
116 |
|
|
|
117 |
|
|
// BOTTOM /////////////////////////
|
118 |
|
|
setupObjectButton(act,mScreenWidth);
|
119 |
c95b37a4
|
Leszek Koltunski
|
createBottomPane(act,mObjButton);
|
120 |
769d7b9f
|
Leszek Koltunski
|
}
|
121 |
211b48f2
|
Leszek Koltunski
|
|
122 |
8ab435b9
|
Leszek Koltunski
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
123 |
4c0cd600
|
Leszek Koltunski
|
|
124 |
ad0c8e0e
|
Leszek Koltunski
|
private void setupObjectButton(final RubikActivity act, final float width)
|
125 |
769d7b9f
|
Leszek Koltunski
|
{
|
126 |
c651024f
|
Leszek Koltunski
|
final int margin = (int)(width*RubikActivity.SMALL_MARGIN);
|
127 |
e07c48a2
|
Leszek Koltunski
|
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);
|
128 |
b600ccd9
|
Leszek Koltunski
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
|
129 |
|
|
mObjButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
|
130 |
769d7b9f
|
Leszek Koltunski
|
|
131 |
|
|
mObjButton.setOnClickListener( new View.OnClickListener()
|
132 |
|
|
{
|
133 |
|
|
@Override
|
134 |
|
|
public void onClick(View view)
|
135 |
4c0cd600
|
Leszek Koltunski
|
{
|
136 |
c95b37a4
|
Leszek Koltunski
|
if( act.getControl().isScramblingAndSolvingNotBlocked() )
|
137 |
2da68298
|
Leszek Koltunski
|
{
|
138 |
c95b37a4
|
Leszek Koltunski
|
if( mObjectPopup==null )
|
139 |
|
|
{
|
140 |
|
|
float width = act.getScreenWidthInPixels();
|
141 |
|
|
float height= act.getScreenHeightInPixels();
|
142 |
|
|
setupObjectWindow(act,width,height);
|
143 |
|
|
}
|
144 |
|
|
|
145 |
|
|
int rowCount = Math.min(mMaxRowCount,mRowCount);
|
146 |
|
|
View popupView = mObjectPopup.getContentView();
|
147 |
|
|
popupView.setSystemUiVisibility(RubikActivity.FLAGS);
|
148 |
|
|
displayPopup(act,view,mObjectPopup,mObjectSize*mColCount,mObjectSize*rowCount+5*margin,margin,margin);
|
149 |
2da68298
|
Leszek Koltunski
|
}
|
150 |
769d7b9f
|
Leszek Koltunski
|
}
|
151 |
|
|
});
|
152 |
|
|
}
|
153 |
4c0cd600
|
Leszek Koltunski
|
|
154 |
e31abc1e
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
155 |
|
|
|
156 |
24cd23dd
|
Leszek Koltunski
|
private void setupMenuButton(final RubikActivity act, final float width, final float height)
|
157 |
e31abc1e
|
Leszek Koltunski
|
{
|
158 |
0254cfd7
|
Leszek Koltunski
|
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);
|
159 |
b600ccd9
|
Leszek Koltunski
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
|
160 |
|
|
mMenuButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
|
161 |
e31abc1e
|
Leszek Koltunski
|
|
162 |
e03e0352
|
Leszek Koltunski
|
mMenuButton.setOnClickListener( new View.OnClickListener()
|
163 |
e31abc1e
|
Leszek Koltunski
|
{
|
164 |
|
|
@Override
|
165 |
|
|
public void onClick(View view)
|
166 |
|
|
{
|
167 |
c95b37a4
|
Leszek Koltunski
|
if( act.getControl().isScramblingAndSolvingNotBlocked() )
|
168 |
2da68298
|
Leszek Koltunski
|
{
|
169 |
c95b37a4
|
Leszek Koltunski
|
if( mMenuPopup==null )
|
170 |
|
|
{
|
171 |
|
|
float width = act.getScreenWidthInPixels();
|
172 |
|
|
setupMenuWindow(act,width,height);
|
173 |
|
|
}
|
174 |
|
|
|
175 |
|
|
View popupView = mMenuPopup.getContentView();
|
176 |
|
|
popupView.setSystemUiVisibility(RubikActivity.FLAGS);
|
177 |
|
|
setupLevelButtonVisibilityAndColor(act);
|
178 |
|
|
displayPopup(act,view,mMenuPopup,mMenuLayoutWidth,mMenuLayoutHeight,(int)(-mMenuLayoutWidth/2 + width/6),0);
|
179 |
2da68298
|
Leszek Koltunski
|
}
|
180 |
e31abc1e
|
Leszek Koltunski
|
}
|
181 |
|
|
});
|
182 |
|
|
}
|
183 |
|
|
|
184 |
4c0cd600
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
185 |
|
|
|
186 |
598de3ee
|
Leszek Koltunski
|
private void setupObjectWindow(final RubikActivity act, final float width, final float height)
|
187 |
4c0cd600
|
Leszek Koltunski
|
{
|
188 |
fad10885
|
Leszek Koltunski
|
int numObjects = RubikObjectList.getNumObjects();
|
189 |
|
|
mRowCount = (numObjects + NUM_COLUMNS-1) / NUM_COLUMNS;
|
190 |
ac1900c3
|
Leszek Koltunski
|
mColCount = NUM_COLUMNS;
|
191 |
|
|
|
192 |
27401bea
|
Leszek Koltunski
|
int cubeSize = (int)( (Math.min(width,(int)(height*0.7f))) / 9 );
|
193 |
|
|
int margin = (int)(height*RubikActivity.POPUP_MARGIN);
|
194 |
|
|
int padding = (int)(height*RubikActivity.POPUP_PADDING);
|
195 |
adbd16d9
|
Leszek Koltunski
|
mObjectSize = (int)(cubeSize + 2*margin + 0.5f);
|
196 |
0b162619
|
Leszek Koltunski
|
mMaxRowCount = (int)((height-1.8f*mUpperBarHeight)/mObjectSize);
|
197 |
598de3ee
|
Leszek Koltunski
|
|
198 |
8d1da3f1
|
Leszek Koltunski
|
LinearLayout view = (LinearLayout)inflate( act, R.layout.popup_object, null);
|
199 |
b600ccd9
|
Leszek Koltunski
|
GridLayout objectGrid = view.findViewById(R.id.objectGrid);
|
200 |
d6e7c7fb
|
Leszek Koltunski
|
RelativeLayout bottomLayout = view.findViewById(R.id.bottomLayout);
|
201 |
|
|
setupBottomLayout(act,bottomLayout);
|
202 |
0b162619
|
Leszek Koltunski
|
|
203 |
a88b947f
|
Leszek Koltunski
|
PopupCreator.createObjectGrid(objectGrid,act,mRowCount,mColCount,numObjects,margin,cubeSize,padding);
|
204 |
769d7b9f
|
Leszek Koltunski
|
|
205 |
432a5f2c
|
Leszek Koltunski
|
for(int child=0; child<numObjects; child++)
|
206 |
769d7b9f
|
Leszek Koltunski
|
{
|
207 |
302c76a0
|
Leszek Koltunski
|
final RubikObject obj = RubikObjectList.getObject(child);
|
208 |
|
|
View v = objectGrid.getChildAt(child);
|
209 |
|
|
ImageButton button = PopupCreator.getButton(obj,v);
|
210 |
432a5f2c
|
Leszek Koltunski
|
final int ordinal = child;
|
211 |
314e9ff0
|
Leszek Koltunski
|
|
212 |
7ac0ee88
|
Leszek Koltunski
|
button.setOnClickListener( new View.OnClickListener()
|
213 |
769d7b9f
|
Leszek Koltunski
|
{
|
214 |
7ac0ee88
|
Leszek Koltunski
|
@Override
|
215 |
|
|
public void onClick(View v)
|
216 |
769d7b9f
|
Leszek Koltunski
|
{
|
217 |
919b830e
|
Leszek Koltunski
|
if( obj!=null && act.getControl().isScramblingAndSolvingNotBlocked() && ScreenList.getCurrentScreen()==ScreenList.PLAY )
|
218 |
769d7b9f
|
Leszek Koltunski
|
{
|
219 |
c7238c67
|
Leszek Koltunski
|
if( obj.isFree() )
|
220 |
|
|
{
|
221 |
|
|
RubikObjectList.setCurrObject(ordinal);
|
222 |
|
|
act.changeObject(ordinal,true);
|
223 |
2011391d
|
Leszek Koltunski
|
if( mMenuPopup!=null ) setupLevelButtonVisibilityAndColor(act);
|
224 |
c7238c67
|
Leszek Koltunski
|
mMovesController.clearMoves(act);
|
225 |
|
|
}
|
226 |
|
|
else
|
227 |
|
|
{
|
228 |
|
|
act.switchToPurchase(ordinal);
|
229 |
|
|
}
|
230 |
769d7b9f
|
Leszek Koltunski
|
}
|
231 |
|
|
|
232 |
1f3bc259
|
Leszek Koltunski
|
if( mObjectPopup!=null ) mObjectPopup.dismiss();
|
233 |
7ac0ee88
|
Leszek Koltunski
|
}
|
234 |
|
|
});
|
235 |
769d7b9f
|
Leszek Koltunski
|
}
|
236 |
432a5f2c
|
Leszek Koltunski
|
|
237 |
|
|
mObjectPopup = new PopupWindow(act);
|
238 |
|
|
mObjectPopup.setFocusable(true);
|
239 |
|
|
mObjectPopup.setContentView(view);
|
240 |
4c0cd600
|
Leszek Koltunski
|
}
|
241 |
|
|
|
242 |
8d1da3f1
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
243 |
|
|
|
244 |
d6e7c7fb
|
Leszek Koltunski
|
private void setupBottomLayout(final RubikActivity act, final RelativeLayout layout)
|
245 |
8d1da3f1
|
Leszek Koltunski
|
{
|
246 |
|
|
int iconT = RubikActivity.getDrawable(R.drawable.ui_small_tutorial,R.drawable.ui_medium_tutorial, R.drawable.ui_big_tutorial, R.drawable.ui_huge_tutorial);
|
247 |
d6e7c7fb
|
Leszek Koltunski
|
int iconD = RubikActivity.getDrawable(R.drawable.ui_small_download,R.drawable.ui_medium_download, R.drawable.ui_big_download, R.drawable.ui_huge_download);
|
248 |
|
|
int iconI = RubikActivity.getDrawable(R.drawable.ui_small_info,R.drawable.ui_medium_info, R.drawable.ui_big_info, R.drawable.ui_huge_info);
|
249 |
8d1da3f1
|
Leszek Koltunski
|
|
250 |
|
|
ImageButton buttonTut = layout.findViewById(R.id.buttonTut);
|
251 |
d6e7c7fb
|
Leszek Koltunski
|
ImageButton buttonDow = layout.findViewById(R.id.buttonDow);
|
252 |
|
|
ImageButton buttonInf = layout.findViewById(R.id.buttonInf);
|
253 |
8d1da3f1
|
Leszek Koltunski
|
|
254 |
|
|
buttonTut.setImageResource(iconT);
|
255 |
d6e7c7fb
|
Leszek Koltunski
|
buttonDow.setImageResource(iconD);
|
256 |
|
|
buttonInf.setImageResource(iconI);
|
257 |
8d1da3f1
|
Leszek Koltunski
|
|
258 |
|
|
TypedValue outValue = new TypedValue();
|
259 |
|
|
act.getTheme().resolveAttribute(android.R.attr.selectableItemBackgroundBorderless, outValue, true);
|
260 |
|
|
buttonTut.setBackgroundResource(outValue.resourceId);
|
261 |
d6e7c7fb
|
Leszek Koltunski
|
buttonDow.setBackgroundResource(outValue.resourceId);
|
262 |
|
|
buttonInf.setBackgroundResource(outValue.resourceId);
|
263 |
8d1da3f1
|
Leszek Koltunski
|
|
264 |
|
|
buttonTut.setOnClickListener( new View.OnClickListener()
|
265 |
|
|
{
|
266 |
|
|
@Override
|
267 |
|
|
public void onClick(View v)
|
268 |
|
|
{
|
269 |
|
|
if( mObjectPopup!=null ) mObjectPopup.dismiss();
|
270 |
|
|
RubikDialogTutorial tDiag = new RubikDialogTutorial();
|
271 |
|
|
tDiag.show( act.getSupportFragmentManager(), RubikDialogTutorial.getDialogTag() );
|
272 |
|
|
}
|
273 |
|
|
});
|
274 |
|
|
|
275 |
d6e7c7fb
|
Leszek Koltunski
|
buttonDow.setOnClickListener( new View.OnClickListener()
|
276 |
|
|
{
|
277 |
|
|
@Override
|
278 |
|
|
public void onClick(View v)
|
279 |
|
|
{
|
280 |
5f3801d3
|
Leszek Koltunski
|
if( mObjectPopup!=null ) mObjectPopup.dismiss();
|
281 |
|
|
RubikDialogUpdates uDiag = new RubikDialogUpdates();
|
282 |
|
|
uDiag.show( act.getSupportFragmentManager(), RubikDialogUpdates.getDialogTag() );
|
283 |
d6e7c7fb
|
Leszek Koltunski
|
}
|
284 |
|
|
});
|
285 |
|
|
|
286 |
|
|
buttonInf.setOnClickListener( new View.OnClickListener()
|
287 |
8d1da3f1
|
Leszek Koltunski
|
{
|
288 |
|
|
@Override
|
289 |
|
|
public void onClick(View v)
|
290 |
|
|
{
|
291 |
f12e4de9
|
Leszek Koltunski
|
if( mObjectPopup!=null ) mObjectPopup.dismiss();
|
292 |
400ff34d
|
Leszek Koltunski
|
int currObject = RubikObjectList.getCurrObject();
|
293 |
|
|
act.switchConfig(currObject);
|
294 |
8d1da3f1
|
Leszek Koltunski
|
}
|
295 |
|
|
});
|
296 |
d6e7c7fb
|
Leszek Koltunski
|
|
297 |
10373dc7
|
Leszek Koltunski
|
mBubbleUpdates = layout.findViewById(R.id.bubbleUpdates);
|
298 |
|
|
mBubbleUpdates.setVisibility(View.INVISIBLE);
|
299 |
|
|
|
300 |
d6e7c7fb
|
Leszek Koltunski
|
RubikNetwork network = RubikNetwork.getInstance();
|
301 |
|
|
network.signUpForUpdates(this);
|
302 |
8d1da3f1
|
Leszek Koltunski
|
}
|
303 |
|
|
|
304 |
c1df05fa
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
305 |
|
|
|
306 |
|
|
void setupSolveButton(final RubikActivity act)
|
307 |
|
|
{
|
308 |
|
|
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_solve,R.drawable.ui_medium_cube_solve, R.drawable.ui_big_cube_solve, R.drawable.ui_huge_cube_solve);
|
309 |
|
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
|
310 |
|
|
mSolveButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE,params);
|
311 |
|
|
|
312 |
|
|
mSolveButton.setOnClickListener( new View.OnClickListener()
|
313 |
|
|
{
|
314 |
|
|
@Override
|
315 |
|
|
public void onClick(View v)
|
316 |
|
|
{
|
317 |
|
|
act.getControl().solveObject();
|
318 |
|
|
mMovesController.clearMoves(act);
|
319 |
|
|
}
|
320 |
|
|
});
|
321 |
|
|
}
|
322 |
|
|
|
323 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
324 |
|
|
|
325 |
|
|
private void setupScrambleButton(final RubikActivity act)
|
326 |
|
|
{
|
327 |
|
|
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_scramble,R.drawable.ui_medium_cube_scramble, R.drawable.ui_big_cube_scramble, R.drawable.ui_huge_cube_scramble);
|
328 |
|
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
|
329 |
|
|
mScrambleButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
|
330 |
|
|
|
331 |
|
|
mScrambleButton.setOnClickListener( new View.OnClickListener()
|
332 |
|
|
{
|
333 |
|
|
@Override
|
334 |
|
|
public void onClick(View v)
|
335 |
|
|
{
|
336 |
b1629e16
|
Leszek Koltunski
|
int duration = BaseEffect.Type.FAST_SCRAMBLE.getDuration();
|
337 |
0c768d69
|
Leszek Koltunski
|
boolean success = act.getControl().fastScrambleObject(duration,RubikObject.FAST_SCRAMBLES);
|
338 |
|
|
if( success ) mShouldReactToEndOfScrambling = false;
|
339 |
c1df05fa
|
Leszek Koltunski
|
}
|
340 |
|
|
});
|
341 |
|
|
}
|
342 |
|
|
|
343 |
e03e0352
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
344 |
|
|
|
345 |
24cd23dd
|
Leszek Koltunski
|
private void setupMenuWindow(final RubikActivity act, final float width, final float height)
|
346 |
e03e0352
|
Leszek Koltunski
|
{
|
347 |
|
|
LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
348 |
e07c48a2
|
Leszek Koltunski
|
final View layout = layoutInflater.inflate(R.layout.popup_menu, null);
|
349 |
e03e0352
|
Leszek Koltunski
|
|
350 |
|
|
mMenuPopup = new PopupWindow(act);
|
351 |
|
|
mMenuPopup.setContentView(layout);
|
352 |
|
|
mMenuPopup.setFocusable(true);
|
353 |
24cd23dd
|
Leszek Koltunski
|
int padding = (int)(height*MENU_MARGIN);
|
354 |
6b034729
|
Leszek Koltunski
|
int numButtons = USE_IAP ? 7 : 6;
|
355 |
09bcbc45
|
Leszek Koltunski
|
mLevelHeight = (int)(height*LEVEL_BUTTON_HEIGHT);
|
356 |
24cd23dd
|
Leszek Koltunski
|
mMenuLayoutHeight= padding + numButtons*(mMenuButtonHeight+padding) + mLevelHeight/3 + 3*(mLevelHeight+padding);
|
357 |
4279106d
|
Leszek Koltunski
|
mMenuLayoutWidth = Math.min((int)(width*MENU_WIDTH),mMenuLayoutHeight/2);
|
358 |
|
|
mLevelWidth = (mMenuLayoutWidth-4*padding)/3;
|
359 |
e03e0352
|
Leszek Koltunski
|
|
360 |
0b458a90
|
Leszek Koltunski
|
layout.setPadding(padding,0,padding,0);
|
361 |
e03e0352
|
Leszek Koltunski
|
|
362 |
6b034729
|
Leszek Koltunski
|
if( USE_IAP )
|
363 |
|
|
{
|
364 |
|
|
Button stars = layout.findViewById(R.id.menuStars);
|
365 |
|
|
stars.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
|
366 |
|
|
stars.setOnClickListener( new View.OnClickListener()
|
367 |
|
|
{
|
368 |
|
|
@Override
|
369 |
|
|
public void onClick(View v)
|
370 |
|
|
{
|
371 |
|
|
mMenuPopup.dismiss();
|
372 |
|
|
RubikDialogStarsStatus d = new RubikDialogStarsStatus();
|
373 |
|
|
d.show(act.getSupportFragmentManager(), null);
|
374 |
|
|
}
|
375 |
|
|
});
|
376 |
|
|
}
|
377 |
|
|
else
|
378 |
|
|
{
|
379 |
|
|
Button stars = layout.findViewById(R.id.menuStars);
|
380 |
|
|
stars.setVisibility(GONE);
|
381 |
|
|
}
|
382 |
|
|
|
383 |
93a1c364
|
Leszek Koltunski
|
Button solver = layout.findViewById(R.id.menuSolver);
|
384 |
|
|
solver.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
|
385 |
|
|
solver.setOnClickListener( new View.OnClickListener()
|
386 |
|
|
{
|
387 |
|
|
@Override
|
388 |
|
|
public void onClick(View v)
|
389 |
|
|
{
|
390 |
|
|
mMenuPopup.dismiss();
|
391 |
|
|
RubikDialogSolvers solvers = new RubikDialogSolvers();
|
392 |
|
|
solvers.show(act.getSupportFragmentManager(), RubikDialogSolvers.getDialogTag() );
|
393 |
|
|
}
|
394 |
|
|
});
|
395 |
|
|
|
396 |
0b458a90
|
Leszek Koltunski
|
Button highScores = layout.findViewById(R.id.menuHighScores);
|
397 |
369a0fce
|
Leszek Koltunski
|
highScores.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
|
398 |
0b458a90
|
Leszek Koltunski
|
highScores.setOnClickListener( new View.OnClickListener()
|
399 |
e03e0352
|
Leszek Koltunski
|
{
|
400 |
|
|
@Override
|
401 |
|
|
public void onClick(View v)
|
402 |
|
|
{
|
403 |
|
|
mMenuPopup.dismiss();
|
404 |
0b458a90
|
Leszek Koltunski
|
Bundle sBundle = new Bundle();
|
405 |
c02fa107
|
Leszek Koltunski
|
sBundle.putString("argument", "false");
|
406 |
0b458a90
|
Leszek Koltunski
|
RubikDialogScores scores = new RubikDialogScores();
|
407 |
|
|
scores.setArguments(sBundle);
|
408 |
|
|
scores.show(act.getSupportFragmentManager(), null);
|
409 |
e03e0352
|
Leszek Koltunski
|
}
|
410 |
|
|
});
|
411 |
|
|
|
412 |
0b458a90
|
Leszek Koltunski
|
Button prettyPatterns = layout.findViewById(R.id.menuPrettyPatterns);
|
413 |
369a0fce
|
Leszek Koltunski
|
prettyPatterns.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
|
414 |
0b458a90
|
Leszek Koltunski
|
prettyPatterns.setOnClickListener( new View.OnClickListener()
|
415 |
|
|
{
|
416 |
|
|
@Override
|
417 |
|
|
public void onClick(View v)
|
418 |
|
|
{
|
419 |
|
|
mMenuPopup.dismiss();
|
420 |
|
|
RubikDialogPattern pDiag = new RubikDialogPattern();
|
421 |
|
|
pDiag.show( act.getSupportFragmentManager(), RubikDialogPattern.getDialogTag() );
|
422 |
|
|
}
|
423 |
|
|
});
|
424 |
0254cfd7
|
Leszek Koltunski
|
|
425 |
0b458a90
|
Leszek Koltunski
|
Button tutorials = layout.findViewById(R.id.menuTutorials);
|
426 |
369a0fce
|
Leszek Koltunski
|
tutorials.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
|
427 |
0b458a90
|
Leszek Koltunski
|
tutorials.setOnClickListener( new View.OnClickListener()
|
428 |
|
|
{
|
429 |
|
|
@Override
|
430 |
|
|
public void onClick(View v)
|
431 |
|
|
{
|
432 |
|
|
mMenuPopup.dismiss();
|
433 |
|
|
RubikDialogTutorial tDiag = new RubikDialogTutorial();
|
434 |
|
|
tDiag.show( act.getSupportFragmentManager(), RubikDialogTutorial.getDialogTag() );
|
435 |
|
|
}
|
436 |
|
|
});
|
437 |
e03e0352
|
Leszek Koltunski
|
|
438 |
fad10885
|
Leszek Koltunski
|
Button bandaged = layout.findViewById(R.id.menuBandaged);
|
439 |
|
|
bandaged.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
|
440 |
|
|
bandaged.setOnClickListener( new View.OnClickListener()
|
441 |
|
|
{
|
442 |
|
|
@Override
|
443 |
|
|
public void onClick(View v)
|
444 |
|
|
{
|
445 |
|
|
mMenuPopup.dismiss();
|
446 |
|
|
act.switchToBandagedCreator();
|
447 |
|
|
}
|
448 |
|
|
});
|
449 |
|
|
|
450 |
34d6b123
|
Leszek Koltunski
|
Button whatsNew = layout.findViewById(R.id.menuNew);
|
451 |
|
|
whatsNew.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
|
452 |
|
|
whatsNew.setOnClickListener( new View.OnClickListener()
|
453 |
0b458a90
|
Leszek Koltunski
|
{
|
454 |
|
|
@Override
|
455 |
|
|
public void onClick(View v)
|
456 |
|
|
{
|
457 |
|
|
mMenuPopup.dismiss();
|
458 |
34d6b123
|
Leszek Koltunski
|
RubikDialogWhatsNew aDiag = new RubikDialogWhatsNew();
|
459 |
0b458a90
|
Leszek Koltunski
|
aDiag.show(act.getSupportFragmentManager(), null);
|
460 |
|
|
}
|
461 |
|
|
});
|
462 |
4f3e2d90
|
Leszek Koltunski
|
|
463 |
369a0fce
|
Leszek Koltunski
|
TextView levels = layout.findViewById(R.id.menuLevels);
|
464 |
|
|
levels.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
|
465 |
|
|
|
466 |
09bcbc45
|
Leszek Koltunski
|
setupLevelButtons(act,layout,padding/2);
|
467 |
4f3e2d90
|
Leszek Koltunski
|
}
|
468 |
|
|
|
469 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
470 |
|
|
|
471 |
09bcbc45
|
Leszek Koltunski
|
private void setupLevelButtons(RubikActivity act, View layout, int margin)
|
472 |
4f3e2d90
|
Leszek Koltunski
|
{
|
473 |
24cd23dd
|
Leszek Koltunski
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(mLevelWidth,mLevelHeight);
|
474 |
09bcbc45
|
Leszek Koltunski
|
params.setMargins(margin,margin,margin,margin);
|
475 |
4f3e2d90
|
Leszek Koltunski
|
|
476 |
79422ed8
|
Leszek Koltunski
|
mOldNumScramble = LEVELS_SHOWN+1;
|
477 |
|
|
|
478 |
1088a219
|
Leszek Koltunski
|
mLevel = new Button[LEVELS_SHOWN+1];
|
479 |
4f3e2d90
|
Leszek Koltunski
|
|
480 |
1088a219
|
Leszek Koltunski
|
mLevel[0] = layout.findViewById(R.id.level1);
|
481 |
|
|
mLevel[1] = layout.findViewById(R.id.level2);
|
482 |
|
|
mLevel[2] = layout.findViewById(R.id.level3);
|
483 |
|
|
mLevel[3] = layout.findViewById(R.id.level4);
|
484 |
|
|
mLevel[4] = layout.findViewById(R.id.level5);
|
485 |
|
|
mLevel[5] = layout.findViewById(R.id.level6);
|
486 |
|
|
mLevel[6] = layout.findViewById(R.id.level7);
|
487 |
|
|
mLevel[7] = layout.findViewById(R.id.level8);
|
488 |
|
|
mLevel[8] = layout.findViewById(R.id.levelM);
|
489 |
4f3e2d90
|
Leszek Koltunski
|
|
490 |
1088a219
|
Leszek Koltunski
|
for(int i=0; i<=LEVELS_SHOWN; i++)
|
491 |
|
|
{
|
492 |
|
|
final int ii = i;
|
493 |
|
|
mLevel[i].setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
|
494 |
|
|
mLevel[i].setLayoutParams(params);
|
495 |
|
|
mLevel[i].setOnClickListener( new View.OnClickListener()
|
496 |
4f3e2d90
|
Leszek Koltunski
|
{
|
497 |
|
|
@Override
|
498 |
|
|
public void onClick(View v)
|
499 |
|
|
{
|
500 |
|
|
ObjectControl control = act.getControl();
|
501 |
|
|
|
502 |
919b830e
|
Leszek Koltunski
|
if( control.isScramblingAndSolvingNotBlocked() )
|
503 |
4f3e2d90
|
Leszek Koltunski
|
{
|
504 |
|
|
if( mMenuPopup!=null ) mMenuPopup.dismiss();
|
505 |
|
|
|
506 |
|
|
int currObject = RubikObjectList.getCurrObject();
|
507 |
|
|
RubikObject object = RubikObjectList.getObject(currObject);
|
508 |
1088a219
|
Leszek Koltunski
|
final int scrambles = ii<LEVELS_SHOWN ? ii+1 : (object==null ? 0 : object.getNumScramble());
|
509 |
0c768d69
|
Leszek Koltunski
|
|
510 |
|
|
boolean success = control.scrambleObject(scrambles);
|
511 |
|
|
if( success )
|
512 |
|
|
{
|
513 |
|
|
mLevelValue = ii+1;
|
514 |
|
|
mShouldReactToEndOfScrambling = true;
|
515 |
|
|
}
|
516 |
4f3e2d90
|
Leszek Koltunski
|
}
|
517 |
|
|
}
|
518 |
|
|
});
|
519 |
1088a219
|
Leszek Koltunski
|
}
|
520 |
|
|
}
|
521 |
|
|
|
522 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
523 |
|
|
|
524 |
2011391d
|
Leszek Koltunski
|
private void setupLevelButtonVisibilityAndColor(RubikActivity act)
|
525 |
1088a219
|
Leszek Koltunski
|
{
|
526 |
|
|
int currObject = RubikObjectList.getCurrObject();
|
527 |
2011391d
|
Leszek Koltunski
|
RubikObject object = RubikObjectList.getObject(currObject);
|
528 |
|
|
int numScramble = object==null ? 1 : object.getNumScramble();
|
529 |
1088a219
|
Leszek Koltunski
|
RubikScores scores = RubikScores.getInstance();
|
530 |
8a47642f
|
Leszek Koltunski
|
Resources res = act.getResources();
|
531 |
be65535e
|
Leszek Koltunski
|
ColorStateList colorG = ColorStateList.valueOf(res.getColor(R.color.green));
|
532 |
|
|
ColorStateList colorD = ColorStateList.valueOf(res.getColor(R.color.dark_grey));
|
533 |
1088a219
|
Leszek Koltunski
|
|
534 |
83018ac4
|
Leszek Koltunski
|
for(int level=0; level<=LEVELS_SHOWN; level++)
|
535 |
1088a219
|
Leszek Koltunski
|
{
|
536 |
|
|
boolean isSolved = scores.isSolved(currObject,level);
|
537 |
83018ac4
|
Leszek Koltunski
|
mLevel[level].setBackgroundTintList( isSolved ? colorG : colorD);
|
538 |
1088a219
|
Leszek Koltunski
|
}
|
539 |
2011391d
|
Leszek Koltunski
|
|
540 |
|
|
if( numScramble<=LEVELS_SHOWN || mOldNumScramble<=LEVELS_SHOWN )
|
541 |
|
|
{
|
542 |
|
|
if( numScramble<mOldNumScramble )
|
543 |
|
|
{
|
544 |
|
|
int max = Math.min(LEVELS_SHOWN,mOldNumScramble-1);
|
545 |
|
|
for(int level=numScramble; level<=max; level++) mLevel[level].setVisibility(View.INVISIBLE);
|
546 |
|
|
mLevel[numScramble-1].setText(R.string.levelM);
|
547 |
|
|
}
|
548 |
|
|
if( numScramble>mOldNumScramble )
|
549 |
|
|
{
|
550 |
|
|
int max = Math.min(LEVELS_SHOWN,numScramble-1);
|
551 |
|
|
mLevel[mOldNumScramble-1].setText( String.valueOf(mOldNumScramble) );
|
552 |
|
|
|
553 |
|
|
for(int level=mOldNumScramble; level<=max; level++)
|
554 |
|
|
{
|
555 |
|
|
mLevel[level].setVisibility(View.VISIBLE);
|
556 |
|
|
if( level<max ) mLevel[level].setText( String.valueOf(level+1) );
|
557 |
|
|
else mLevel[level].setText( R.string.levelM );
|
558 |
|
|
}
|
559 |
|
|
}
|
560 |
|
|
}
|
561 |
|
|
|
562 |
|
|
mOldNumScramble = numScramble;
|
563 |
e03e0352
|
Leszek Koltunski
|
}
|
564 |
|
|
|
565 |
211b48f2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
566 |
3398a606
|
Leszek Koltunski
|
// This is necessary! Otherwise the ObjectPopup will not be re-created next time and we will still
|
567 |
|
|
// hold a reference to the old instance of the RubikActivity class (because setupObjectWindow is not
|
568 |
|
|
// going to be called)
|
569 |
|
|
// An reference to the old instance of RubikActivity will cause all sorts of strange issues.
|
570 |
211b48f2
|
Leszek Koltunski
|
|
571 |
|
|
public void savePreferences(SharedPreferences.Editor editor)
|
572 |
|
|
{
|
573 |
d38a302b
|
Leszek Koltunski
|
editor.putInt("play_LevelValue", mLevelValue );
|
574 |
|
|
|
575 |
3398a606
|
Leszek Koltunski
|
if( mObjectPopup!=null )
|
576 |
|
|
{
|
577 |
|
|
mObjectPopup.dismiss();
|
578 |
|
|
mObjectPopup = null;
|
579 |
|
|
}
|
580 |
87d86e5f
|
Leszek Koltunski
|
|
581 |
3398a606
|
Leszek Koltunski
|
if( mMenuPopup!=null )
|
582 |
|
|
{
|
583 |
|
|
mMenuPopup.dismiss();
|
584 |
|
|
mMenuPopup = null;
|
585 |
|
|
}
|
586 |
69b66386
|
Leszek Koltunski
|
}
|
587 |
|
|
|
588 |
211b48f2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
589 |
|
|
|
590 |
|
|
public void restorePreferences(SharedPreferences preferences)
|
591 |
|
|
{
|
592 |
1088a219
|
Leszek Koltunski
|
mLevelValue = preferences.getInt("play_LevelValue", 0);
|
593 |
7b7d65ce
|
Leszek Koltunski
|
}
|
594 |
|
|
|
595 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
596 |
255492a0
|
Leszek Koltunski
|
// work around lame bugs in Android's version <= 10 pop-up and split-screen modes
|
597 |
|
|
|
598 |
|
|
private void displayPopup(RubikActivity act, View view, PopupWindow window, int w, int h, int xoff, int yoff)
|
599 |
|
|
{
|
600 |
|
|
View topLayout = act.findViewById(R.id.relativeLayout);
|
601 |
7ac0ee88
|
Leszek Koltunski
|
boolean isFullScreen;
|
602 |
00aa398a
|
Leszek Koltunski
|
|
603 |
|
|
if( topLayout!=null )
|
604 |
|
|
{
|
605 |
|
|
topLayout.getLocationOnScreen(mLocation);
|
606 |
7ac0ee88
|
Leszek Koltunski
|
isFullScreen = (mLocation[1]==0);
|
607 |
00aa398a
|
Leszek Koltunski
|
}
|
608 |
|
|
else
|
609 |
|
|
{
|
610 |
7ac0ee88
|
Leszek Koltunski
|
isFullScreen = true;
|
611 |
00aa398a
|
Leszek Koltunski
|
}
|
612 |
255492a0
|
Leszek Koltunski
|
|
613 |
69a271f3
|
Leszek Koltunski
|
try
|
614 |
255492a0
|
Leszek Koltunski
|
{
|
615 |
69a271f3
|
Leszek Koltunski
|
// if on Android 11 or we are fullscreen
|
616 |
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R || isFullScreen )
|
617 |
|
|
{
|
618 |
|
|
window.showAsDropDown(view, xoff, yoff, Gravity.CENTER);
|
619 |
|
|
window.update(view, w, h);
|
620 |
|
|
}
|
621 |
|
|
else // Android 10 or below in pop-up mode or split-screen mode
|
622 |
|
|
{
|
623 |
|
|
view.getLocationOnScreen(mLocation);
|
624 |
|
|
int width = view.getWidth();
|
625 |
|
|
int height = view.getHeight();
|
626 |
|
|
int x = mLocation[0]+(width-w)/2;
|
627 |
|
|
int y = mLocation[1]+height+yoff;
|
628 |
|
|
|
629 |
|
|
window.showAsDropDown(view);
|
630 |
|
|
window.update(x,y,w,h);
|
631 |
|
|
}
|
632 |
255492a0
|
Leszek Koltunski
|
}
|
633 |
69a271f3
|
Leszek Koltunski
|
catch( IllegalArgumentException iae )
|
634 |
255492a0
|
Leszek Koltunski
|
{
|
635 |
69a271f3
|
Leszek Koltunski
|
// ignore, this means window is 'not attached to window manager' -
|
636 |
|
|
// which most probably is because we are already exiting the app.
|
637 |
255492a0
|
Leszek Koltunski
|
}
|
638 |
|
|
}
|
639 |
|
|
|
640 |
211b48f2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
641 |
|
|
|
642 |
dca3888a
|
Leszek Koltunski
|
public int getLevel()
|
643 |
211b48f2
|
Leszek Koltunski
|
{
|
644 |
85b09df4
|
Leszek Koltunski
|
return mLevelValue;
|
645 |
211b48f2
|
Leszek Koltunski
|
}
|
646 |
|
|
|
647 |
84d746d7
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
648 |
|
|
|
649 |
|
|
public void recreatePopup()
|
650 |
|
|
{
|
651 |
|
|
mObjectPopup = null;
|
652 |
|
|
}
|
653 |
|
|
|
654 |
dd874ae8
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
655 |
|
|
|
656 |
|
|
public boolean shouldReactToEndOfScrambling()
|
657 |
|
|
{
|
658 |
|
|
return mShouldReactToEndOfScrambling;
|
659 |
|
|
}
|
660 |
63dd19c4
|
Leszek Koltunski
|
|
661 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
662 |
|
|
|
663 |
|
|
public void receiveUpdate(RubikUpdates updates)
|
664 |
|
|
{
|
665 |
179f7189
|
Leszek Koltunski
|
Activity act = mWeakAct.get();
|
666 |
10373dc7
|
Leszek Koltunski
|
|
667 |
179f7189
|
Leszek Koltunski
|
if( act!=null )
|
668 |
903c7bbc
|
Leszek Koltunski
|
{
|
669 |
179f7189
|
Leszek Koltunski
|
act.runOnUiThread(new Runnable()
|
670 |
|
|
{
|
671 |
|
|
@Override
|
672 |
|
|
public void run()
|
673 |
|
|
{
|
674 |
2c9ab085
|
Leszek Koltunski
|
int num = updates.getCompletedNumber();
|
675 |
179f7189
|
Leszek Koltunski
|
|
676 |
|
|
if( num>0 )
|
677 |
|
|
{
|
678 |
|
|
String shownNum = String.valueOf(num);
|
679 |
|
|
mBubbleUpdates.setText(shownNum);
|
680 |
|
|
mBubbleUpdates.setVisibility(View.VISIBLE);
|
681 |
|
|
int height = (int)(0.05f*mScreenWidth);
|
682 |
|
|
mBubbleUpdates.setTextSize(TypedValue.COMPLEX_UNIT_PX,height);
|
683 |
|
|
}
|
684 |
|
|
else
|
685 |
|
|
{
|
686 |
|
|
mBubbleUpdates.setVisibility(View.INVISIBLE);
|
687 |
|
|
}
|
688 |
|
|
}
|
689 |
|
|
});
|
690 |
903c7bbc
|
Leszek Koltunski
|
}
|
691 |
63dd19c4
|
Leszek Koltunski
|
}
|
692 |
|
|
|
693 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
694 |
|
|
|
695 |
|
|
public void errorUpdate()
|
696 |
|
|
{
|
697 |
5305fdc8
|
Leszek Koltunski
|
android.util.Log.e("D", "RubikScreenPlay: Error receiving downloaded objects update");
|
698 |
63dd19c4
|
Leszek Koltunski
|
}
|
699 |
211b48f2
|
Leszek Koltunski
|
}
|