Revision da768c35
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/states/RubikStateAbstract.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.states; |
21 | 21 |
|
22 |
import android.annotation.SuppressLint; |
|
22 | 23 |
import android.content.SharedPreferences; |
24 |
import android.util.TypedValue; |
|
25 |
import android.widget.LinearLayout; |
|
26 |
|
|
23 | 27 |
import org.distorted.main.RubikActivity; |
24 | 28 |
|
25 | 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
26 | 30 |
|
27 | 31 |
public abstract class RubikStateAbstract |
28 | 32 |
{ |
33 |
@SuppressLint("ViewConstructor") |
|
34 |
static class TransparentImageButton extends androidx.appcompat.widget.AppCompatImageButton |
|
35 |
{ |
|
36 |
public TransparentImageButton(RubikActivity act, int icon, float scrWidth, int butWidth) |
|
37 |
{ |
|
38 |
super(act); |
|
39 |
|
|
40 |
final int padding = (int)(scrWidth*RubikActivity.PADDING); |
|
41 |
final int margin = (int)(scrWidth*RubikActivity.MARGIN); |
|
42 |
|
|
43 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(butWidth,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
|
44 |
|
|
45 |
params.topMargin = margin; |
|
46 |
params.bottomMargin = margin; |
|
47 |
params.leftMargin = margin; |
|
48 |
params.rightMargin = margin; |
|
49 |
|
|
50 |
setLayoutParams(params); |
|
51 |
setPadding(padding,0,padding,0); |
|
52 |
setImageResource(icon); |
|
53 |
|
|
54 |
TypedValue outValue = new TypedValue(); |
|
55 |
act.getTheme().resolveAttribute(android.R.attr.selectableItemBackgroundBorderless, outValue, true); |
|
56 |
setBackgroundResource(outValue.resourceId); |
|
57 |
} |
|
58 |
} |
|
59 |
|
|
60 |
@SuppressLint("ViewConstructor") |
|
61 |
static class TransparentButton extends androidx.appcompat.widget.AppCompatButton |
|
62 |
{ |
|
63 |
public TransparentButton(RubikActivity act, int resId, float size, float scrWidth) |
|
64 |
{ |
|
65 |
super(act); |
|
66 |
|
|
67 |
final int padding = (int)(scrWidth*RubikActivity.PADDING); |
|
68 |
final int margin = (int)(scrWidth*RubikActivity.MARGIN); |
|
69 |
|
|
70 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT, 1.0f); |
|
71 |
params.topMargin = margin; |
|
72 |
params.bottomMargin = margin; |
|
73 |
params.leftMargin = margin; |
|
74 |
params.rightMargin = margin; |
|
75 |
|
|
76 |
setLayoutParams(params); |
|
77 |
setPadding(padding,0,padding,0); |
|
78 |
setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
79 |
setText(resId); |
|
80 |
|
|
81 |
TypedValue outValue = new TypedValue(); |
|
82 |
act.getTheme().resolveAttribute(android.R.attr.selectableItemBackgroundBorderless, outValue, true); |
|
83 |
setBackgroundResource(outValue.resourceId); |
|
84 |
} |
|
85 |
} |
|
86 |
|
|
29 | 87 |
abstract void enterState(RubikActivity act); |
30 | 88 |
abstract void leaveState(RubikActivity act); |
31 | 89 |
public abstract void savePreferences(SharedPreferences.Editor editor); |
src/main/java/org/distorted/states/RubikStateDone.java | ||
---|---|---|
38 | 38 |
|
39 | 39 |
public class RubikStateDone extends RubikStateAbstract |
40 | 40 |
{ |
41 |
private ImageButton mBackButton; |
|
42 |
|
|
43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
44 |
|
|
41 | 45 |
void leaveState(RubikActivity act) |
42 | 46 |
{ |
43 | 47 |
|
... | ... | |
72 | 76 |
LinearLayout layoutRight = new LinearLayout(act); |
73 | 77 |
layoutRight.setLayoutParams(paramsR); |
74 | 78 |
|
75 |
int padding = (int)(width*RubikActivity.PADDING); |
|
76 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
79 |
setupBackButton(act,width); |
|
77 | 80 |
|
78 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
|
79 |
params.topMargin = margin; |
|
80 |
params.bottomMargin = margin; |
|
81 |
params.leftMargin = margin; |
|
82 |
params.rightMargin = margin; |
|
81 |
layoutRight.addView(mBackButton); |
|
82 |
layoutBot.addView(layoutLeft); |
|
83 |
layoutBot.addView(layoutRight); |
|
84 |
} |
|
83 | 85 |
|
84 |
final int icon = RubikActivity.getDrawable(R.drawable.ui_small_back,R.drawable.ui_medium_back, R.drawable.ui_big_back, R.drawable.ui_huge_back);
|
|
86 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
85 | 87 |
|
86 |
ImageButton back = new ImageButton(act);
|
|
87 |
back.setLayoutParams(params);
|
|
88 |
back.setPadding(padding,0,padding,0);
|
|
89 |
back.setImageResource(icon);
|
|
88 |
private void setupBackButton(final RubikActivity act, final float width)
|
|
89 |
{
|
|
90 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_back,R.drawable.ui_medium_back, R.drawable.ui_big_back, R.drawable.ui_huge_back);
|
|
91 |
mBackButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT);
|
|
90 | 92 |
|
91 |
back.setOnClickListener( new View.OnClickListener()
|
|
93 |
mBackButton.setOnClickListener( new View.OnClickListener()
|
|
92 | 94 |
{ |
93 | 95 |
@Override |
94 | 96 |
public void onClick(View v) |
95 | 97 |
{ |
96 | 98 |
StateList.goBack(act); |
97 |
dismissDialogs(act); |
|
99 |
|
|
100 |
FragmentManager mana = act.getSupportFragmentManager(); |
|
101 |
RubikDialogNewRecord diag1 = (RubikDialogNewRecord) mana.findFragmentByTag(RubikDialogNewRecord.getDialogTag()); |
|
102 |
RubikDialogSolved diag2 = (RubikDialogSolved ) mana.findFragmentByTag(RubikDialogSolved.getDialogTag()); |
|
103 |
|
|
104 |
if( diag1 !=null ) diag1.dismiss(); |
|
105 |
if( diag2 !=null ) diag2.dismiss(); |
|
98 | 106 |
} |
99 | 107 |
}); |
100 |
|
|
101 |
layoutRight.addView(back); |
|
102 |
layoutBot.addView(layoutLeft); |
|
103 |
layoutBot.addView(layoutRight); |
|
104 | 108 |
} |
105 | 109 |
|
106 | 110 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
116 | 120 |
{ |
117 | 121 |
|
118 | 122 |
} |
119 |
|
|
120 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
121 |
|
|
122 |
private void dismissDialogs(RubikActivity act) |
|
123 |
{ |
|
124 |
FragmentManager mana = act.getSupportFragmentManager(); |
|
125 |
RubikDialogNewRecord diag1 = (RubikDialogNewRecord) mana.findFragmentByTag(RubikDialogNewRecord.getDialogTag()); |
|
126 |
RubikDialogSolved diag2 = (RubikDialogSolved ) mana.findFragmentByTag(RubikDialogSolved.getDialogTag()); |
|
127 |
|
|
128 |
if( diag1 !=null ) diag1.dismiss(); |
|
129 |
if( diag2 !=null ) diag2.dismiss(); |
|
130 |
} |
|
131 | 123 |
} |
src/main/java/org/distorted/states/RubikStatePattern.java | ||
---|---|---|
47 | 47 |
private TextView mMovesText; |
48 | 48 |
private int mNumMoves; |
49 | 49 |
private int mPatternOrdinal, mCategory, mPattern; |
50 |
private float mButtonSize, mTitleSize;
|
|
50 |
private float mButtonSize; |
|
51 | 51 |
|
52 | 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
53 | 53 |
|
... | ... | |
80 | 80 |
{ |
81 | 81 |
float width = act.getScreenWidthInPixels(); |
82 | 82 |
mButtonSize = width*RubikActivity.BUTTON_TEXT_SIZE; |
83 |
mTitleSize = width*RubikActivity.TITLE_TEXT_SIZE;
|
|
83 |
float titleSize = width*RubikActivity.TITLE_TEXT_SIZE;
|
|
84 | 84 |
|
85 | 85 |
RubikStatePlay play = (RubikStatePlay) StateList.PLAY.getStateClass(); |
86 | 86 |
int obj = play.getObject(); |
... | ... | |
104 | 104 |
LinearLayout layoutTop = act.findViewById(R.id.upperBar); |
105 | 105 |
layoutTop.removeAllViews(); |
106 | 106 |
mText = (TextView)inflater.inflate(R.layout.upper_pattern_text, null); |
107 |
mText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTitleSize);
|
|
107 |
mText.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
|
|
108 | 108 |
mText.setText(R.string.patterns); |
109 | 109 |
layoutTop.addView(mText); |
110 | 110 |
|
... | ... | |
168 | 168 |
|
169 | 169 |
private void setupBackButton(final RubikActivity act, final float width) |
170 | 170 |
{ |
171 |
int padding = (int)(width*RubikActivity.PADDING); |
|
172 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
173 |
|
|
174 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
|
175 |
params.topMargin = margin; |
|
176 |
params.bottomMargin = margin; |
|
177 |
params.leftMargin = margin; |
|
178 |
params.rightMargin = margin; |
|
179 |
|
|
180 | 171 |
final int icon = RubikActivity.getDrawable(R.drawable.ui_small_back,R.drawable.ui_medium_back, R.drawable.ui_big_back, R.drawable.ui_huge_back); |
181 |
|
|
182 |
mBackButton = new ImageButton(act); |
|
183 |
mBackButton.setLayoutParams(params); |
|
184 |
mBackButton.setPadding(padding,0,padding,0); |
|
185 |
mBackButton.setImageResource(icon); |
|
172 |
mBackButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT); |
|
186 | 173 |
|
187 | 174 |
mBackButton.setOnClickListener( new View.OnClickListener() |
188 | 175 |
{ |
... | ... | |
211 | 198 |
|
212 | 199 |
private void setupPrevButton(final RubikActivity act, final float width) |
213 | 200 |
{ |
214 |
int padding = (int)(width*RubikActivity.PADDING); |
|
215 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
216 | 201 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_left,R.drawable.ui_medium_left, R.drawable.ui_big_left, R.drawable.ui_huge_left); |
217 |
|
|
218 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
|
219 |
params.topMargin = margin; |
|
220 |
params.bottomMargin = margin; |
|
221 |
params.leftMargin = margin; |
|
222 |
params.rightMargin = margin; |
|
223 |
|
|
224 |
mPrevButton = new ImageButton(act); |
|
225 |
mPrevButton.setLayoutParams(params); |
|
226 |
mPrevButton.setPadding(padding,0,padding,0); |
|
227 |
mPrevButton.setImageResource(icon); |
|
202 |
mPrevButton = new TransparentImageButton(act,icon,width,0); |
|
228 | 203 |
|
229 | 204 |
mPrevButton.setOnClickListener( new View.OnClickListener() |
230 | 205 |
{ |
... | ... | |
244 | 219 |
|
245 | 220 |
private void setupNextButton(final RubikActivity act, final float width) |
246 | 221 |
{ |
247 |
int padding = (int)(width*RubikActivity.PADDING); |
|
248 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
249 | 222 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_right,R.drawable.ui_medium_right, R.drawable.ui_big_right, R.drawable.ui_huge_right); |
250 |
|
|
251 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT, 1.0f); |
|
252 |
params.topMargin = margin; |
|
253 |
params.bottomMargin = margin; |
|
254 |
params.leftMargin = margin; |
|
255 |
params.rightMargin = margin; |
|
256 |
|
|
257 |
mNextButton = new ImageButton(act); |
|
258 |
mNextButton.setLayoutParams(params); |
|
259 |
mNextButton.setPadding(padding,0,padding,0); |
|
260 |
mNextButton.setImageResource(icon); |
|
223 |
mNextButton = new TransparentImageButton(act,icon,width,0); |
|
261 | 224 |
|
262 | 225 |
mNextButton.setOnClickListener( new View.OnClickListener() |
263 | 226 |
{ |
src/main/java/org/distorted/states/RubikStatePlay.java | ||
---|---|---|
151 | 151 |
|
152 | 152 |
private void setupObjectButton(final RubikActivity act, final float width) |
153 | 153 |
{ |
154 |
final int padding = (int)(width*RubikActivity.PADDING); |
|
155 | 154 |
final int margin = (int)(width*RubikActivity.MARGIN); |
156 | 155 |
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); |
157 |
|
|
158 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT, 1.2f); |
|
159 |
params.topMargin = margin; |
|
160 |
params.bottomMargin = margin; |
|
161 |
params.leftMargin = margin; |
|
162 |
params.rightMargin = margin; |
|
163 |
|
|
164 |
mObjButton = new ImageButton(act); |
|
165 |
mObjButton.setLayoutParams(params); |
|
166 |
mObjButton.setPadding(padding,0,padding,0); |
|
167 |
mObjButton.setImageResource(icon); |
|
156 |
mObjButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT); |
|
168 | 157 |
|
169 | 158 |
mObjButton.setOnClickListener( new View.OnClickListener() |
170 | 159 |
{ |
... | ... | |
184 | 173 |
|
185 | 174 |
mObjectPopup.setFocusable(true); |
186 | 175 |
mObjectPopup.update(); |
187 |
|
|
188 | 176 |
} |
189 | 177 |
} |
190 | 178 |
}); |
... | ... | |
194 | 182 |
|
195 | 183 |
private void setupPlayButton(final RubikActivity act, final float width) |
196 | 184 |
{ |
197 |
final int padding = (int)(width*RubikActivity.PADDING); |
|
198 | 185 |
final int margin = (int)(width*RubikActivity.MARGIN); |
199 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT, 1.2f); |
|
200 |
params.topMargin = margin; |
|
201 |
params.bottomMargin = margin; |
|
202 |
params.leftMargin = margin; |
|
203 |
params.rightMargin = margin; |
|
204 |
|
|
205 |
mPlayButton = new Button(act); |
|
206 |
mPlayButton.setLayoutParams(params); |
|
207 |
mPlayButton.setPadding(padding,0,padding,0); |
|
208 |
mPlayButton.setTextSize(TypedValue.COMPLEX_UNIT_PX, mButtonSize); |
|
209 |
mPlayButton.setText(R.string.play); |
|
186 |
mPlayButton = new TransparentButton(act, R.string.play, mButtonSize, width); |
|
210 | 187 |
|
211 | 188 |
mPlayButton.setOnClickListener( new View.OnClickListener() |
212 | 189 |
{ |
... | ... | |
236 | 213 |
|
237 | 214 |
private void setupMenuButton(final RubikActivity act, final float width) |
238 | 215 |
{ |
239 |
final int padding = (int)(width*RubikActivity.PADDING); |
|
240 | 216 |
final int margin = (int)(width*RubikActivity.MARGIN); |
241 | 217 |
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); |
242 |
|
|
243 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1.2f); |
|
244 |
params.topMargin = margin; |
|
245 |
params.bottomMargin = margin; |
|
246 |
params.leftMargin = margin; |
|
247 |
params.rightMargin = margin; |
|
248 |
|
|
249 |
mMenuButton = new ImageButton(act); |
|
250 |
mMenuButton.setLayoutParams(params); |
|
251 |
mMenuButton.setPadding(padding,0,padding,0); |
|
252 |
mMenuButton.setImageResource(icon); |
|
218 |
mMenuButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT); |
|
253 | 219 |
|
254 | 220 |
mMenuButton.setOnClickListener( new View.OnClickListener() |
255 | 221 |
{ |
... | ... | |
278 | 244 |
|
279 | 245 |
private void setupSolveButton(final RubikActivity act, final float width) |
280 | 246 |
{ |
281 |
int padding = (int)(width*RubikActivity.PADDING); |
|
282 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
283 | 247 |
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); |
284 |
|
|
285 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); |
|
286 |
params.topMargin = margin; |
|
287 |
params.bottomMargin = margin; |
|
288 |
params.leftMargin = margin; |
|
289 |
params.rightMargin = margin; |
|
290 |
|
|
291 |
mSolveButton = new ImageButton(act); |
|
292 |
mSolveButton.setLayoutParams(params); |
|
293 |
mSolveButton.setPadding(padding,0,padding,0); |
|
294 |
mSolveButton.setImageResource(icon); |
|
248 |
mSolveButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT); |
|
295 | 249 |
|
296 | 250 |
mSolveButton.setOnClickListener( new View.OnClickListener() |
297 | 251 |
{ |
... | ... | |
308 | 262 |
|
309 | 263 |
private void setupLockButton(final RubikActivity act, final float width) |
310 | 264 |
{ |
311 |
int padding = (int)(width*RubikActivity.PADDING); |
|
312 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
313 |
|
|
314 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); |
|
315 |
params.topMargin = margin; |
|
316 |
params.bottomMargin = margin; |
|
317 |
params.leftMargin = margin; |
|
318 |
params.rightMargin = margin; |
|
319 |
|
|
320 |
mLockButton = new ImageButton(act); |
|
321 |
mLockButton.setLayoutParams(params); |
|
322 |
mLockButton.setPadding(padding,0,padding,0); |
|
323 |
mLockButton.setImageResource(getLockIcon(act)); |
|
265 |
final int icon = getLockIcon(act); |
|
266 |
mLockButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT); |
|
324 | 267 |
|
325 | 268 |
mLockButton.setOnClickListener( new View.OnClickListener() |
326 | 269 |
{ |
... | ... | |
336 | 279 |
|
337 | 280 |
private void setupPrevButton(final RubikActivity act, final float width) |
338 | 281 |
{ |
339 |
int padding = (int)(width*RubikActivity.PADDING); |
|
340 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
341 | 282 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_back,R.drawable.ui_medium_cube_back, R.drawable.ui_big_cube_back, R.drawable.ui_huge_cube_back); |
342 |
|
|
343 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); |
|
344 |
params.topMargin = margin; |
|
345 |
params.bottomMargin = margin; |
|
346 |
params.leftMargin = margin; |
|
347 |
params.rightMargin = margin; |
|
348 |
|
|
349 |
mPrevButton = new ImageButton(act); |
|
350 |
mPrevButton.setLayoutParams(params); |
|
351 |
mPrevButton.setPadding(padding,0,padding,0); |
|
352 |
mPrevButton.setImageResource(icon); |
|
283 |
mPrevButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT); |
|
353 | 284 |
|
354 | 285 |
mPrevButton.setOnClickListener( new View.OnClickListener() |
355 | 286 |
{ |
src/main/java/org/distorted/states/RubikStateReady.java | ||
---|---|---|
89 | 89 |
|
90 | 90 |
private void setupBackButton(final RubikActivity act, float width) |
91 | 91 |
{ |
92 |
int padding = (int)(width*RubikActivity.PADDING); |
|
93 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
94 | 92 |
final int icon = RubikActivity.getDrawable(R.drawable.ui_small_back,R.drawable.ui_medium_back, R.drawable.ui_big_back, R.drawable.ui_huge_back); |
95 |
|
|
96 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
|
97 |
params.topMargin = margin; |
|
98 |
params.bottomMargin = margin; |
|
99 |
params.leftMargin = margin; |
|
100 |
params.rightMargin = margin; |
|
101 |
|
|
102 |
mBackButton = new ImageButton(act); |
|
103 |
mBackButton.setLayoutParams(params); |
|
104 |
mBackButton.setPadding(padding,0,padding,0); |
|
105 |
mBackButton.setImageResource(icon); |
|
93 |
mBackButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT); |
|
106 | 94 |
|
107 | 95 |
mBackButton.setOnClickListener( new View.OnClickListener() |
108 | 96 |
{ |
... | ... | |
118 | 106 |
|
119 | 107 |
private void setupLockButton(final RubikActivity act, final float width) |
120 | 108 |
{ |
121 |
int padding = (int)(width*RubikActivity.PADDING); |
|
122 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
123 |
|
|
124 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); |
|
125 |
params.topMargin = margin; |
|
126 |
params.bottomMargin = margin; |
|
127 |
params.leftMargin = margin; |
|
128 |
params.rightMargin = margin; |
|
129 |
|
|
130 |
mLockButton = new ImageButton(act); |
|
131 |
mLockButton.setLayoutParams(params); |
|
132 |
mLockButton.setPadding(padding,0,padding,0); |
|
133 |
mLockButton.setImageResource(getLockIcon(act)); |
|
109 |
final int icon = getLockIcon(act); |
|
110 |
mLockButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT); |
|
134 | 111 |
|
135 | 112 |
mLockButton.setOnClickListener( new View.OnClickListener() |
136 | 113 |
{ |
... | ... | |
146 | 123 |
|
147 | 124 |
private void setupPrevButtom(final RubikActivity act, float width) |
148 | 125 |
{ |
149 |
int padding = (int)(width*RubikActivity.PADDING); |
|
150 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
151 | 126 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_back,R.drawable.ui_medium_cube_back, R.drawable.ui_big_cube_back, R.drawable.ui_huge_cube_back); |
152 |
|
|
153 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
|
154 |
params.topMargin = margin; |
|
155 |
params.bottomMargin = margin; |
|
156 |
params.leftMargin = margin; |
|
157 |
params.rightMargin = margin; |
|
158 |
|
|
159 |
mPrevButton = new ImageButton(act); |
|
160 |
mPrevButton.setLayoutParams(params); |
|
161 |
mPrevButton.setPadding(padding,0,padding,0); |
|
162 |
mPrevButton.setImageResource(icon); |
|
127 |
mPrevButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT); |
|
163 | 128 |
|
164 | 129 |
mPrevButton.setOnClickListener( new View.OnClickListener() |
165 | 130 |
{ |
src/main/java/org/distorted/states/RubikStateSolution.java | ||
---|---|---|
45 | 45 |
private int[][] mMoves; |
46 | 46 |
private int mCurrMove, mNumMoves; |
47 | 47 |
private boolean mCanRotate; |
48 |
private float mButtonSize, mTitleSize;
|
|
48 |
private float mButtonSize; |
|
49 | 49 |
|
50 | 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
51 | 51 |
|
... | ... | |
61 | 61 |
{ |
62 | 62 |
float width = act.getScreenWidthInPixels(); |
63 | 63 |
mButtonSize = width*RubikActivity.BUTTON_TEXT_SIZE; |
64 |
mTitleSize = width*RubikActivity.TITLE_TEXT_SIZE;
|
|
64 |
float titleSize = width*RubikActivity.TITLE_TEXT_SIZE;
|
|
65 | 65 |
|
66 | 66 |
LayoutInflater inflater = act.getLayoutInflater(); |
67 | 67 |
|
... | ... | |
70 | 70 |
layoutTop.removeAllViews(); |
71 | 71 |
|
72 | 72 |
final TextView text = (TextView)inflater.inflate(R.layout.upper_text, null); |
73 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTitleSize);
|
|
73 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
|
|
74 | 74 |
text.setText(R.string.solution); |
75 | 75 |
layoutTop.addView(text); |
76 | 76 |
|
... | ... | |
110 | 110 |
|
111 | 111 |
private void setupPrevButton(final RubikActivity act, final float width) |
112 | 112 |
{ |
113 |
int padding = (int)(width*RubikActivity.PADDING); |
|
114 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
115 | 113 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_left,R.drawable.ui_medium_left, R.drawable.ui_big_left, R.drawable.ui_huge_left); |
116 |
|
|
117 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
|
118 |
params.topMargin = margin; |
|
119 |
params.bottomMargin = margin; |
|
120 |
params.leftMargin = margin; |
|
121 |
params.rightMargin = margin; |
|
122 |
|
|
123 |
mPrevButton = new ImageButton(act); |
|
124 |
mPrevButton.setLayoutParams(params); |
|
125 |
mPrevButton.setPadding(padding,0,padding,0); |
|
126 |
mPrevButton.setImageResource(icon); |
|
114 |
mPrevButton = new TransparentImageButton(act,icon,width,0); |
|
127 | 115 |
|
128 | 116 |
mPrevButton.setOnClickListener( new View.OnClickListener() |
129 | 117 |
{ |
... | ... | |
141 | 129 |
|
142 | 130 |
private void setupNextButton(final RubikActivity act, final float width) |
143 | 131 |
{ |
144 |
int padding = (int)(width*RubikActivity.PADDING); |
|
145 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
146 | 132 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_right,R.drawable.ui_medium_right, R.drawable.ui_big_right, R.drawable.ui_huge_right); |
147 |
|
|
148 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT, 1.0f); |
|
149 |
params.topMargin = margin; |
|
150 |
params.bottomMargin = margin; |
|
151 |
params.leftMargin = margin; |
|
152 |
params.rightMargin = margin; |
|
153 |
|
|
154 |
mNextButton = new ImageButton(act); |
|
155 |
mNextButton.setLayoutParams(params); |
|
156 |
mNextButton.setPadding(padding,0,padding,0); |
|
157 |
mNextButton.setImageResource(icon); |
|
133 |
mNextButton = new TransparentImageButton(act,icon,width,0); |
|
158 | 134 |
|
159 | 135 |
mNextButton.setOnClickListener( new View.OnClickListener() |
160 | 136 |
{ |
... | ... | |
193 | 169 |
|
194 | 170 |
private void setupBackButton(final RubikActivity act, final float width) |
195 | 171 |
{ |
196 |
int padding = (int)(width*RubikActivity.PADDING); |
|
197 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
198 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
|
199 |
params.topMargin = margin; |
|
200 |
params.bottomMargin = margin; |
|
201 |
params.leftMargin = margin; |
|
202 |
params.rightMargin = margin; |
|
203 |
|
|
204 | 172 |
final int icon = RubikActivity.getDrawable(R.drawable.ui_small_back,R.drawable.ui_medium_back, R.drawable.ui_big_back, R.drawable.ui_huge_back); |
205 |
|
|
206 |
mBackButton = new ImageButton(act); |
|
207 |
mBackButton.setLayoutParams(params); |
|
208 |
mBackButton.setPadding(padding,0,padding,0); |
|
209 |
mBackButton.setImageResource(icon); |
|
173 |
mBackButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT); |
|
210 | 174 |
|
211 | 175 |
mBackButton.setOnClickListener( new View.OnClickListener() |
212 | 176 |
{ |
src/main/java/org/distorted/states/RubikStateSolver.java | ||
---|---|---|
199 | 199 |
|
200 | 200 |
private void setupSolveButton(final RubikActivity act, final float width) |
201 | 201 |
{ |
202 |
int padding = (int)(width*RubikActivity.PADDING); |
|
203 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
204 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1); |
|
205 |
params.topMargin = margin; |
|
206 |
params.bottomMargin = margin; |
|
207 |
params.leftMargin = margin; |
|
208 |
params.rightMargin = margin; |
|
209 |
|
|
210 | 202 |
final int icon = RubikActivity.getDrawable(R.drawable.ui_small_solve,R.drawable.ui_medium_solve, R.drawable.ui_big_solve, R.drawable.ui_huge_solve); |
211 |
|
|
212 |
mSolveButton = new ImageButton(act); |
|
213 |
mSolveButton.setLayoutParams(params); |
|
214 |
mSolveButton.setPadding(padding,0,padding,0); |
|
215 |
mSolveButton.setImageResource(icon); |
|
203 |
mSolveButton = new TransparentImageButton(act,icon,width, LinearLayout.LayoutParams.MATCH_PARENT); |
|
216 | 204 |
|
217 | 205 |
mSolveButton.setOnClickListener( new View.OnClickListener() |
218 | 206 |
{ |
... | ... | |
235 | 223 |
|
236 | 224 |
private void setupBackButton(final RubikActivity act, final float width) |
237 | 225 |
{ |
238 |
int padding = (int)(width*RubikActivity.PADDING); |
|
239 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
240 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1); |
|
241 |
params.topMargin = margin; |
|
242 |
params.bottomMargin = margin; |
|
243 |
params.leftMargin = margin; |
|
244 |
params.rightMargin = margin; |
|
245 |
|
|
246 | 226 |
final int icon = RubikActivity.getDrawable(R.drawable.ui_small_back,R.drawable.ui_medium_back, R.drawable.ui_big_back, R.drawable.ui_huge_back); |
247 |
|
|
248 |
mBackButton = new ImageButton(act); |
|
249 |
mBackButton.setLayoutParams(params); |
|
250 |
mBackButton.setPadding(padding,0,padding,0); |
|
251 |
mBackButton.setImageResource(icon); |
|
227 |
mBackButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT); |
|
252 | 228 |
|
253 | 229 |
mBackButton.setOnClickListener( new View.OnClickListener() |
254 | 230 |
{ |
src/main/java/org/distorted/states/RubikStateSolving.java | ||
---|---|---|
135 | 135 |
|
136 | 136 |
private void setupBackButtom(final RubikActivity act, float width) |
137 | 137 |
{ |
138 |
int padding = (int)(width*RubikActivity.PADDING); |
|
139 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
140 | 138 |
final int icon = RubikActivity.getDrawable(R.drawable.ui_small_back,R.drawable.ui_medium_back, R.drawable.ui_big_back, R.drawable.ui_huge_back); |
141 |
|
|
142 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
|
143 |
params.topMargin = margin; |
|
144 |
params.bottomMargin = margin; |
|
145 |
params.leftMargin = margin; |
|
146 |
params.rightMargin = margin; |
|
147 |
|
|
148 |
mBackButton = new ImageButton(act); |
|
149 |
mBackButton.setLayoutParams(params); |
|
150 |
mBackButton.setPadding(padding,0,padding,0); |
|
151 |
mBackButton.setImageResource(icon); |
|
139 |
mBackButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT); |
|
152 | 140 |
|
153 | 141 |
mBackButton.setOnClickListener( new View.OnClickListener() |
154 | 142 |
{ |
... | ... | |
164 | 152 |
|
165 | 153 |
private void setupLockButton(final RubikActivity act, final float width) |
166 | 154 |
{ |
167 |
int padding = (int)(width*RubikActivity.PADDING); |
|
168 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
169 |
|
|
170 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); |
|
171 |
params.topMargin = margin; |
|
172 |
params.bottomMargin = margin; |
|
173 |
params.leftMargin = margin; |
|
174 |
params.rightMargin = margin; |
|
175 |
|
|
176 |
mLockButton = new ImageButton(act); |
|
177 |
mLockButton.setLayoutParams(params); |
|
178 |
mLockButton.setPadding(padding,0,padding,0); |
|
179 |
mLockButton.setImageResource(getLockIcon(act)); |
|
155 |
final int icon = getLockIcon(act); |
|
156 |
mLockButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT); |
|
180 | 157 |
|
181 | 158 |
mLockButton.setOnClickListener( new View.OnClickListener() |
182 | 159 |
{ |
... | ... | |
192 | 169 |
|
193 | 170 |
private void setupPrevButtom(final RubikActivity act, float width) |
194 | 171 |
{ |
195 |
int padding = (int)(width*RubikActivity.PADDING); |
|
196 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
197 | 172 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_back,R.drawable.ui_medium_cube_back, R.drawable.ui_big_cube_back, R.drawable.ui_huge_cube_back); |
198 |
|
|
199 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
|
200 |
params.topMargin = margin; |
|
201 |
params.bottomMargin = margin; |
|
202 |
params.leftMargin = margin; |
|
203 |
params.rightMargin = margin; |
|
204 |
|
|
205 |
mPrevButton = new ImageButton(act); |
|
206 |
mPrevButton.setLayoutParams(params); |
|
207 |
mPrevButton.setPadding(padding,0,padding,0); |
|
208 |
mPrevButton.setImageResource(icon); |
|
173 |
mPrevButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT); |
|
209 | 174 |
|
210 | 175 |
mPrevButton.setOnClickListener( new View.OnClickListener() |
211 | 176 |
{ |
Also available in: Unified diff
Transparent Buttons.