Revision dd874ae8
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/helpers/LockController.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
import android.app.Activity; |
26 | 26 |
import android.view.View; |
27 |
import android.widget.ImageButton; |
|
28 | 27 |
import android.widget.LinearLayout; |
29 | 28 |
|
30 | 29 |
import org.distorted.main.R; |
... | ... | |
37 | 36 |
{ |
38 | 37 |
private static final int LOCK_TIME = 300; |
39 | 38 |
|
40 |
private ImageButton mLockButton; |
|
39 |
private TransparentImageButton mLockButton;
|
|
41 | 40 |
private long mLockTime; |
42 | 41 |
private Timer mTimer; |
43 | 42 |
private boolean mTimerRunning; |
... | ... | |
57 | 56 |
{ |
58 | 57 |
control.toggleLock(); |
59 | 58 |
boolean locked = control.retLocked(); |
60 |
mLockButton.setImageResource(getLockIcon(locked,false));
|
|
59 |
mLockButton.setIconResource(getLockIcon(locked,false));
|
|
61 | 60 |
} |
62 | 61 |
|
63 | 62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
100 | 99 |
public void run() |
101 | 100 |
{ |
102 | 101 |
if( mLockButton!=null ) |
103 |
mLockButton.setImageResource(getLockIcon(locked,red));
|
|
102 |
mLockButton.setIconResource(getLockIcon(locked,red));
|
|
104 | 103 |
} |
105 | 104 |
}); |
106 | 105 |
} |
... | ... | |
151 | 150 |
|
152 | 151 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
153 | 152 |
|
154 |
public void setupButton(final Activity act, ObjectControl control, final float width)
|
|
153 |
public void setupButton(final Activity act, ObjectControl control) |
|
155 | 154 |
{ |
156 | 155 |
boolean locked = control.retLocked(); |
157 | 156 |
final int icon = getLockIcon(locked,false); |
158 |
mLockButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT);
|
|
157 |
mLockButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT,TransparentImageButton.GRAVITY_MIDDLE);
|
|
159 | 158 |
|
160 | 159 |
mLockButton.setOnClickListener( new View.OnClickListener() |
161 | 160 |
{ |
... | ... | |
177 | 176 |
public void run() |
178 | 177 |
{ |
179 | 178 |
if( mLockButton!=null ) |
180 |
mLockButton.setImageResource(getLockIcon(locked,false));
|
|
179 |
mLockButton.setIconResource(getLockIcon(locked,false));
|
|
181 | 180 |
} |
182 | 181 |
}); |
183 | 182 |
} |
184 | 183 |
|
185 | 184 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
186 | 185 |
|
187 |
public ImageButton getButton() |
|
186 |
public TransparentImageButton getButton()
|
|
188 | 187 |
{ |
189 | 188 |
return mLockButton; |
190 | 189 |
} |
src/main/java/org/distorted/helpers/MovesController.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import android.app.Activity; |
25 | 25 |
import android.view.View; |
26 |
import android.widget.ImageButton; |
|
27 | 26 |
import android.widget.LinearLayout; |
28 | 27 |
|
29 | 28 |
import org.distorted.objectlib.helpers.MovesFinished; |
... | ... | |
54 | 53 |
private final ArrayList<Move> mMoves; |
55 | 54 |
private boolean mCanPrevMove; |
56 | 55 |
private ObjectControl mControl; |
57 |
private ImageButton mPrevButton; |
|
56 |
private TransparentImageButton mPrevButton;
|
|
58 | 57 |
|
59 | 58 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
60 | 59 |
// PUBLIC API |
... | ... | |
126 | 125 |
public void run() |
127 | 126 |
{ |
128 | 127 |
if( mPrevButton!=null ) |
129 |
mPrevButton.setImageResource(getPrevIcon(on));
|
|
128 |
mPrevButton.setIconResource(getPrevIcon(on));
|
|
130 | 129 |
} |
131 | 130 |
}); |
132 | 131 |
} |
... | ... | |
164 | 163 |
|
165 | 164 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
166 | 165 |
|
167 |
public void setupButton(final Activity act, ObjectControl control, final float width)
|
|
166 |
public void setupButton(final Activity act, ObjectControl control) |
|
168 | 167 |
{ |
169 | 168 |
final int icon = getPrevIcon( !mMoves.isEmpty() ); |
170 |
mPrevButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT);
|
|
169 |
mPrevButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_MIDDLE);
|
|
171 | 170 |
|
172 | 171 |
mPrevButton.setOnClickListener( new View.OnClickListener() |
173 | 172 |
{ |
... | ... | |
181 | 180 |
|
182 | 181 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
183 | 182 |
|
184 |
public ImageButton getButton() |
|
183 |
public TransparentImageButton getButton()
|
|
185 | 184 |
{ |
186 | 185 |
return mPrevButton; |
187 | 186 |
} |
src/main/java/org/distorted/helpers/TransparentImageButton.java | ||
---|---|---|
24 | 24 |
import android.util.TypedValue; |
25 | 25 |
import android.widget.LinearLayout; |
26 | 26 |
|
27 |
import org.distorted.main.RubikActivity;
|
|
27 |
import com.google.android.material.button.MaterialButton;
|
|
28 | 28 |
|
29 | 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
30 | 30 |
|
31 | 31 |
@SuppressLint("ViewConstructor") |
32 |
public class TransparentImageButton extends androidx.appcompat.widget.AppCompatImageButton
|
|
32 |
public class TransparentImageButton extends MaterialButton
|
|
33 | 33 |
{ |
34 |
public TransparentImageButton(Context context, int icon, float scrWidth, int butWidth) |
|
34 |
public static final int GRAVITY_START = 0; |
|
35 |
public static final int GRAVITY_MIDDLE = 1; |
|
36 |
public static final int GRAVITY_END = 2; |
|
37 |
|
|
38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
39 |
|
|
40 |
public TransparentImageButton(Context context, int icon, int butWidth, int gravity) |
|
35 | 41 |
{ |
36 | 42 |
super(context); |
37 | 43 |
|
38 |
final int padding = (int)(scrWidth*RubikActivity.PADDING); |
|
39 |
final int margin = (int)(scrWidth*RubikActivity.MARGIN); |
|
40 |
|
|
41 | 44 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(butWidth,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
42 | 45 |
|
43 |
params.topMargin = margin; |
|
44 |
params.bottomMargin = margin; |
|
45 |
params.leftMargin = margin; |
|
46 |
params.rightMargin = margin; |
|
47 |
|
|
48 | 46 |
setLayoutParams(params); |
49 |
setPadding(padding,0,padding,0); |
|
50 |
setImageResource(icon); |
|
47 |
setPadding(0,0,0,0); |
|
48 |
setIconResource(icon); |
|
49 |
setIconTint(null); |
|
50 |
|
|
51 |
switch(gravity) |
|
52 |
{ |
|
53 |
case GRAVITY_START : setIconGravity(MaterialButton.ICON_GRAVITY_START ); break; |
|
54 |
case GRAVITY_MIDDLE: setIconGravity(MaterialButton.ICON_GRAVITY_TEXT_START); break; |
|
55 |
case GRAVITY_END : setIconGravity(MaterialButton.ICON_GRAVITY_END ); break; |
|
56 |
} |
|
51 | 57 |
|
52 | 58 |
TypedValue outValue = new TypedValue(); |
53 | 59 |
context.getTheme().resolveAttribute(android.R.attr.selectableItemBackgroundBorderless, outValue, true); |
src/main/java/org/distorted/main/RubikActivity.java | ||
---|---|---|
108 | 108 |
super.onCreate(savedState); |
109 | 109 |
DistortedLibrary.onCreate(0); |
110 | 110 |
|
111 |
setTheme(R.style.CustomActivityThemeNoActionBar);
|
|
111 |
setTheme(R.style.MaterialThemeNoActionBar);
|
|
112 | 112 |
setContentView(R.layout.main); |
113 | 113 |
|
114 | 114 |
mJustStarted = true; |
src/main/java/org/distorted/main/RubikObjectLibInterface.java | ||
---|---|---|
216 | 216 |
|
217 | 217 |
public void onScrambleEffectFinished() |
218 | 218 |
{ |
219 |
RubikActivity act = mAct.get(); |
|
220 |
RubikScores.getInstance().incrementNumPlays(); |
|
219 |
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass(); |
|
221 | 220 |
|
222 |
act.runOnUiThread(new Runnable()
|
|
221 |
if( play.shouldReactToEndOfScrambling() )
|
|
223 | 222 |
{ |
224 |
@Override |
|
225 |
public void run() |
|
223 |
RubikActivity act = mAct.get(); |
|
224 |
RubikScores.getInstance().incrementNumPlays(); |
|
225 |
|
|
226 |
act.runOnUiThread(new Runnable() |
|
227 |
{ |
|
228 |
@Override |
|
229 |
public void run() |
|
226 | 230 |
{ |
227 | 231 |
ScreenList.switchScreen( act, ScreenList.READ); |
228 | 232 |
} |
229 |
}); |
|
233 |
}); |
|
234 |
} |
|
230 | 235 |
} |
231 | 236 |
|
232 | 237 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/screens/RubikScreenBase.java | ||
---|---|---|
20 | 20 |
package org.distorted.screens; |
21 | 21 |
|
22 | 22 |
import android.app.Activity; |
23 |
import android.widget.ImageButton; |
|
24 | 23 |
import android.widget.LinearLayout; |
25 | 24 |
|
25 |
import org.distorted.helpers.TransparentImageButton; |
|
26 | 26 |
import org.distorted.main.RubikActivity; |
27 | 27 |
import org.distorted.objectlib.main.ObjectControl; |
28 | 28 |
|
... | ... | |
39 | 39 |
|
40 | 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
41 | 41 |
|
42 |
void createBottomPane(final RubikActivity act, float width, ImageButton button)
|
|
42 |
void createBottomPane(final RubikActivity act, TransparentImageButton left, TransparentImageButton right)
|
|
43 | 43 |
{ |
44 | 44 |
mMovesController.clearMoves(act); |
45 | 45 |
|
... | ... | |
56 | 56 |
layoutRight.setLayoutParams(params); |
57 | 57 |
|
58 | 58 |
ObjectControl control = act.getControl(); |
59 |
mMovesController.setupButton(act,control,width);
|
|
59 |
mMovesController.setupButton(act,control); |
|
60 | 60 |
layoutLeft.addView(mMovesController.getButton()); |
61 |
mLockController.setupButton(act,control,width);
|
|
61 |
mLockController.setupButton(act,control); |
|
62 | 62 |
layoutMid.addView(mLockController.getButton()); |
63 |
layoutRight.addView(button); |
|
63 |
|
|
64 |
if( left !=null ) layoutRight.addView(left); |
|
65 |
if( right!=null ) layoutRight.addView(right); |
|
64 | 66 |
|
65 | 67 |
layoutBot.addView(layoutLeft); |
66 | 68 |
layoutBot.addView(layoutMid); |
src/main/java/org/distorted/screens/RubikScreenDone.java | ||
---|---|---|
23 | 23 |
import android.util.TypedValue; |
24 | 24 |
import android.view.LayoutInflater; |
25 | 25 |
import android.view.View; |
26 |
import android.widget.ImageButton; |
|
27 | 26 |
import android.widget.LinearLayout; |
28 | 27 |
import android.widget.TextView; |
29 | 28 |
|
... | ... | |
39 | 38 |
|
40 | 39 |
public class RubikScreenDone extends RubikScreenAbstract |
41 | 40 |
{ |
42 |
private ImageButton mBackButton; |
|
41 |
private TransparentImageButton mBackButton;
|
|
43 | 42 |
|
44 | 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
45 | 44 |
|
... | ... | |
76 | 75 |
LinearLayout layoutRight = new LinearLayout(act); |
77 | 76 |
layoutRight.setLayoutParams(paramsR); |
78 | 77 |
|
79 |
setupBackButton(act,width);
|
|
78 |
setupBackButton(act); |
|
80 | 79 |
|
81 | 80 |
layoutRight.addView(mBackButton); |
82 | 81 |
layoutBot.addView(layoutLeft); |
... | ... | |
85 | 84 |
|
86 | 85 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
87 | 86 |
|
88 |
private void setupBackButton(final RubikActivity act, final float width)
|
|
87 |
private void setupBackButton(final RubikActivity act) |
|
89 | 88 |
{ |
90 | 89 |
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 |
mBackButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_MIDDLE);
|
|
92 | 91 |
|
93 | 92 |
mBackButton.setOnClickListener( new View.OnClickListener() |
94 | 93 |
{ |
src/main/java/org/distorted/screens/RubikScreenPattern.java | ||
---|---|---|
25 | 25 |
import android.view.Gravity; |
26 | 26 |
import android.view.LayoutInflater; |
27 | 27 |
import android.view.View; |
28 |
import android.widget.ImageButton; |
|
29 | 28 |
import android.widget.LinearLayout; |
30 | 29 |
import android.widget.TextView; |
31 | 30 |
|
... | ... | |
44 | 43 |
public class RubikScreenPattern extends RubikScreenAbstract |
45 | 44 |
{ |
46 | 45 |
private TextView mText; |
47 |
private ImageButton mPrevButton, mNextButton, mBackButton; |
|
46 |
private TransparentImageButton mPrevButton, mNextButton, mBackButton;
|
|
48 | 47 |
private TextView mMovesText; |
49 | 48 |
private int mNumMoves; |
50 | 49 |
private int mPatternOrdinal, mCategory, mPattern; |
... | ... | |
91 | 90 |
LinearLayout layoutBot = act.findViewById(R.id.lowerBar); |
92 | 91 |
layoutBot.removeAllViews(); |
93 | 92 |
|
94 |
setupPrevButton(act,width);
|
|
95 |
setupNextButton(act,width);
|
|
93 |
setupPrevButton(act); |
|
94 |
setupNextButton(act); |
|
96 | 95 |
setupTextView(act,width); |
97 | 96 |
|
98 | 97 |
setTrioState(false); |
... | ... | |
112 | 111 |
layoutLeft.addView(mMovesText); |
113 | 112 |
layoutLeft.addView(mNextButton); |
114 | 113 |
|
115 |
setupBackButton(act,width);
|
|
114 |
setupBackButton(act); |
|
116 | 115 |
|
117 | 116 |
layoutRight.addView(mBackButton); |
118 | 117 |
|
... | ... | |
142 | 141 |
|
143 | 142 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
144 | 143 |
|
145 |
private void setupBackButton(final RubikActivity act, final float width)
|
|
144 |
private void setupBackButton(final RubikActivity act) |
|
146 | 145 |
{ |
147 | 146 |
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); |
148 |
mBackButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT);
|
|
147 |
mBackButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_MIDDLE);
|
|
149 | 148 |
|
150 | 149 |
mBackButton.setOnClickListener( new View.OnClickListener() |
151 | 150 |
{ |
... | ... | |
161 | 160 |
|
162 | 161 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
163 | 162 |
|
164 |
private void setupPrevButton(final RubikActivity act, final float width)
|
|
163 |
private void setupPrevButton(final RubikActivity act) |
|
165 | 164 |
{ |
166 | 165 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_left,R.drawable.ui_medium_left, R.drawable.ui_big_left, R.drawable.ui_huge_left); |
167 |
mPrevButton = new TransparentImageButton(act,icon,width,0);
|
|
166 |
mPrevButton = new TransparentImageButton(act,icon,0,TransparentImageButton.GRAVITY_MIDDLE);
|
|
168 | 167 |
|
169 | 168 |
mPrevButton.setOnClickListener( new View.OnClickListener() |
170 | 169 |
{ |
... | ... | |
182 | 181 |
|
183 | 182 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
184 | 183 |
|
185 |
private void setupNextButton(final RubikActivity act, final float width)
|
|
184 |
private void setupNextButton(final RubikActivity act) |
|
186 | 185 |
{ |
187 | 186 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_right,R.drawable.ui_medium_right, R.drawable.ui_big_right, R.drawable.ui_huge_right); |
188 |
mNextButton = new TransparentImageButton(act,icon,width,0);
|
|
187 |
mNextButton = new TransparentImageButton(act,icon,0,TransparentImageButton.GRAVITY_MIDDLE);
|
|
189 | 188 |
|
190 | 189 |
mNextButton.setOnClickListener( new View.OnClickListener() |
191 | 190 |
{ |
src/main/java/org/distorted/screens/RubikScreenPlay.java | ||
---|---|---|
69 | 69 |
private static final float LAST_BUTTON = 1.5f; |
70 | 70 |
private static final int[] mLocation = new int[2]; |
71 | 71 |
|
72 |
private ImageButton mObjButton, mMenuButton, mSolveButton;
|
|
72 |
private TransparentImageButton mObjButton, mMenuButton, mSolveButton, mScrambleButton;
|
|
73 | 73 |
private Button mPlayButton; |
74 | 74 |
private PopupWindow mObjectPopup, mMenuPopup, mPlayPopup; |
75 | 75 |
private ObjectType mObject = DEF_OBJECT; |
... | ... | |
79 | 79 |
private int mColCount, mRowCount, mMaxRowCount; |
80 | 80 |
private LinearLayout mPlayLayout; |
81 | 81 |
private int mUpperBarHeight; |
82 |
private boolean mShouldReactToEndOfScrambling; |
|
82 | 83 |
|
83 | 84 |
static |
84 | 85 |
{ |
... | ... | |
128 | 129 |
setupPlayButton(act,width); |
129 | 130 |
layoutTop.addView(mPlayButton); |
130 | 131 |
|
131 |
setupSolveButton(act,width); |
|
132 |
createBottomPane(act,width,mSolveButton); |
|
132 |
setupSolveButton(act); |
|
133 |
setupScrambleButton(act); |
|
134 |
createBottomPane(act,mSolveButton,mScrambleButton); |
|
133 | 135 |
} |
134 | 136 |
|
135 | 137 |
////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
139 | 141 |
final int margin = (int)(width*RubikActivity.MARGIN); |
140 | 142 |
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); |
141 | 143 |
|
142 |
mObjButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT);
|
|
144 |
mObjButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_MIDDLE);
|
|
143 | 145 |
|
144 | 146 |
mObjButton.setOnClickListener( new View.OnClickListener() |
145 | 147 |
{ |
... | ... | |
206 | 208 |
final int margin = (int)(width*RubikActivity.MARGIN); |
207 | 209 |
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); |
208 | 210 |
|
209 |
mMenuButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT);
|
|
211 |
mMenuButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_MIDDLE);
|
|
210 | 212 |
|
211 | 213 |
mMenuButton.setOnClickListener( new View.OnClickListener() |
212 | 214 |
{ |
... | ... | |
398 | 400 |
|
399 | 401 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
400 | 402 |
|
401 |
void setupSolveButton(final RubikActivity act, final float width)
|
|
403 |
void setupSolveButton(final RubikActivity act) |
|
402 | 404 |
{ |
403 |
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);
|
|
404 |
mSolveButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT);
|
|
405 |
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);
|
|
405 | 407 |
|
406 | 408 |
mSolveButton.setOnClickListener( new View.OnClickListener() |
407 | 409 |
{ |
... | ... | |
414 | 416 |
}); |
415 | 417 |
} |
416 | 418 |
|
419 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
420 |
|
|
421 |
private void setupScrambleButton(final RubikActivity act) |
|
422 |
{ |
|
423 |
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); |
|
425 |
|
|
426 |
mScrambleButton.setOnClickListener( new View.OnClickListener() |
|
427 |
{ |
|
428 |
@Override |
|
429 |
public void onClick(View v) |
|
430 |
{ |
|
431 |
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass(); |
|
432 |
int numScrambles = play.getObject().getNumScramble(); |
|
433 |
mShouldReactToEndOfScrambling = false; |
|
434 |
act.getControl().scrambleObject(numScrambles); |
|
435 |
} |
|
436 |
}); |
|
437 |
} |
|
438 |
|
|
417 | 439 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
418 | 440 |
|
419 | 441 |
public void savePreferences(SharedPreferences.Editor editor) |
... | ... | |
590 | 612 |
{ |
591 | 613 |
if( mPlayPopup!=null ) mPlayPopup.dismiss(); |
592 | 614 |
mLevelValue = level; |
615 |
mShouldReactToEndOfScrambling = true; |
|
593 | 616 |
control.scrambleObject(scrambles); |
594 | 617 |
} |
595 | 618 |
} |
... | ... | |
633 | 656 |
return mLevelValue; |
634 | 657 |
} |
635 | 658 |
|
659 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
660 |
|
|
661 |
public boolean shouldReactToEndOfScrambling() |
|
662 |
{ |
|
663 |
return mShouldReactToEndOfScrambling; |
|
664 |
} |
|
665 |
|
|
636 | 666 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
637 | 667 |
|
638 | 668 |
public ObjectType getObject() |
src/main/java/org/distorted/screens/RubikScreenReady.java | ||
---|---|---|
23 | 23 |
import android.util.TypedValue; |
24 | 24 |
import android.view.LayoutInflater; |
25 | 25 |
import android.view.View; |
26 |
import android.widget.ImageButton; |
|
27 | 26 |
import android.widget.LinearLayout; |
28 | 27 |
import android.widget.TextView; |
29 | 28 |
|
... | ... | |
35 | 34 |
|
36 | 35 |
public class RubikScreenReady extends RubikScreenBase |
37 | 36 |
{ |
38 |
private ImageButton mBackButton; |
|
37 |
private TransparentImageButton mBackButton;
|
|
39 | 38 |
|
40 | 39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
41 | 40 |
|
... | ... | |
60 | 59 |
label.setText(R.string.ready); |
61 | 60 |
layoutTop.addView(label); |
62 | 61 |
|
63 |
setupBackButton(act,width);
|
|
64 |
createBottomPane(act,width,mBackButton);
|
|
62 |
setupBackButton(act); |
|
63 |
createBottomPane(act,mBackButton,null);
|
|
65 | 64 |
} |
66 | 65 |
|
67 | 66 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
68 | 67 |
|
69 |
private void setupBackButton(final RubikActivity act, final float width)
|
|
68 |
private void setupBackButton(final RubikActivity act) |
|
70 | 69 |
{ |
71 | 70 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_back,R.drawable.ui_medium_back, R.drawable.ui_big_back, R.drawable.ui_huge_back); |
72 |
mBackButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT);
|
|
71 |
mBackButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_MIDDLE);
|
|
73 | 72 |
|
74 | 73 |
mBackButton.setOnClickListener( new View.OnClickListener() |
75 | 74 |
{ |
src/main/java/org/distorted/screens/RubikScreenSolution.java | ||
---|---|---|
24 | 24 |
import android.view.Gravity; |
25 | 25 |
import android.view.LayoutInflater; |
26 | 26 |
import android.view.View; |
27 |
import android.widget.ImageButton; |
|
28 | 27 |
import android.widget.LinearLayout; |
29 | 28 |
import android.widget.TextView; |
30 | 29 |
|
... | ... | |
42 | 41 |
{ |
43 | 42 |
private static final int MILLIS_PER_DEGREE = 6; |
44 | 43 |
|
45 |
private ImageButton mPrevButton, mNextButton, mBackButton; |
|
44 |
private TransparentImageButton mPrevButton, mNextButton, mBackButton;
|
|
46 | 45 |
private TextView mMovesText; |
47 | 46 |
private int[][] mMoves; |
48 | 47 |
private int mCurrMove, mNumMoves; |
... | ... | |
91 | 90 |
LinearLayout layoutRight = new LinearLayout(act); |
92 | 91 |
layoutRight.setLayoutParams(paramsR); |
93 | 92 |
|
94 |
setupPrevButton(act,width);
|
|
95 |
setupNextButton(act,width);
|
|
93 |
setupPrevButton(act); |
|
94 |
setupNextButton(act); |
|
96 | 95 |
setupTextView(act,width); |
97 | 96 |
|
98 | 97 |
layoutLeft.addView(mPrevButton); |
99 | 98 |
layoutLeft.addView(mMovesText); |
100 | 99 |
layoutLeft.addView(mNextButton); |
101 | 100 |
|
102 |
setupBackButton(act,width);
|
|
101 |
setupBackButton(act); |
|
103 | 102 |
|
104 | 103 |
layoutRight.addView(mBackButton); |
105 | 104 |
|
... | ... | |
110 | 109 |
|
111 | 110 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
112 | 111 |
|
113 |
private void setupPrevButton(final RubikActivity act, final float width)
|
|
112 |
private void setupPrevButton(final RubikActivity act) |
|
114 | 113 |
{ |
115 | 114 |
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 |
mPrevButton = new TransparentImageButton(act,icon,width,0);
|
|
115 |
mPrevButton = new TransparentImageButton(act,icon,0,TransparentImageButton.GRAVITY_MIDDLE);
|
|
117 | 116 |
|
118 | 117 |
mPrevButton.setOnClickListener( new View.OnClickListener() |
119 | 118 |
{ |
... | ... | |
129 | 128 |
|
130 | 129 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
131 | 130 |
|
132 |
private void setupNextButton(final RubikActivity act, final float width)
|
|
131 |
private void setupNextButton(final RubikActivity act) |
|
133 | 132 |
{ |
134 | 133 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_right,R.drawable.ui_medium_right, R.drawable.ui_big_right, R.drawable.ui_huge_right); |
135 |
mNextButton = new TransparentImageButton(act,icon,width,0);
|
|
134 |
mNextButton = new TransparentImageButton(act,icon,0,TransparentImageButton.GRAVITY_MIDDLE);
|
|
136 | 135 |
|
137 | 136 |
mNextButton.setOnClickListener( new View.OnClickListener() |
138 | 137 |
{ |
... | ... | |
169 | 168 |
|
170 | 169 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
171 | 170 |
|
172 |
private void setupBackButton(final RubikActivity act, final float width)
|
|
171 |
private void setupBackButton(final RubikActivity act) |
|
173 | 172 |
{ |
174 | 173 |
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); |
175 |
mBackButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT);
|
|
174 |
mBackButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_MIDDLE);
|
|
176 | 175 |
|
177 | 176 |
mBackButton.setOnClickListener( new View.OnClickListener() |
178 | 177 |
{ |
src/main/java/org/distorted/screens/RubikScreenSolver.java | ||
---|---|---|
50 | 50 |
{ |
51 | 51 |
private static Bitmap[] mBitmap; |
52 | 52 |
private ImageButton[] mColorButton; |
53 |
private ImageButton mBackButton, mSolveButton; |
|
53 |
private TransparentImageButton mBackButton, mSolveButton;
|
|
54 | 54 |
private boolean mSolving; |
55 | 55 |
private int mCurrentColor; |
56 | 56 |
private int[] mFaceColors; |
... | ... | |
118 | 118 |
LinearLayout layoutBot = act.findViewById(R.id.lowerBar); |
119 | 119 |
layoutBot.removeAllViews(); |
120 | 120 |
|
121 |
setupSolveButton(act,width);
|
|
122 |
setupBackButton(act,width);
|
|
121 |
setupSolveButton(act); |
|
122 |
setupBackButton(act); |
|
123 | 123 |
|
124 | 124 |
layoutLeft.addView(mSolveButton); |
125 | 125 |
layoutRight.addView(mBackButton); |
... | ... | |
209 | 209 |
|
210 | 210 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
211 | 211 |
|
212 |
private void setupSolveButton(final RubikActivity act, final float width)
|
|
212 |
private void setupSolveButton(final RubikActivity act) |
|
213 | 213 |
{ |
214 | 214 |
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); |
215 |
mSolveButton = new TransparentImageButton(act,icon,width, LinearLayout.LayoutParams.MATCH_PARENT);
|
|
215 |
mSolveButton = new TransparentImageButton(act,icon,LinearLayout.LayoutParams.MATCH_PARENT,TransparentImageButton.GRAVITY_MIDDLE);
|
|
216 | 216 |
|
217 | 217 |
mSolveButton.setOnClickListener( new View.OnClickListener() |
218 | 218 |
{ |
... | ... | |
232 | 232 |
|
233 | 233 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
234 | 234 |
|
235 |
private void setupBackButton(final RubikActivity act, final float width)
|
|
235 |
private void setupBackButton(final RubikActivity act) |
|
236 | 236 |
{ |
237 | 237 |
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); |
238 |
mBackButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT);
|
|
238 |
mBackButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_MIDDLE);
|
|
239 | 239 |
|
240 | 240 |
mBackButton.setOnClickListener( new View.OnClickListener() |
241 | 241 |
{ |
src/main/java/org/distorted/screens/RubikScreenSolving.java | ||
---|---|---|
26 | 26 |
import android.util.TypedValue; |
27 | 27 |
import android.view.LayoutInflater; |
28 | 28 |
import android.view.View; |
29 |
import android.widget.ImageButton; |
|
30 | 29 |
import android.widget.LinearLayout; |
31 | 30 |
import android.widget.TextView; |
32 | 31 |
|
... | ... | |
49 | 48 |
private boolean mRunning; |
50 | 49 |
private final RubikScores mScores; |
51 | 50 |
private long mElapsed; |
52 |
private ImageButton mBackButton; |
|
51 |
private TransparentImageButton mBackButton;
|
|
53 | 52 |
|
54 | 53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
55 | 54 |
|
... | ... | |
85 | 84 |
mTime.setText(act.getString(R.string.tm_placeholder,elapsed/60,elapsed%60)); |
86 | 85 |
layoutTop.addView(mTime); |
87 | 86 |
|
88 |
setupBackButton(act,width);
|
|
89 |
createBottomPane(act,width,mBackButton);
|
|
87 |
setupBackButton(act); |
|
88 |
createBottomPane(act,mBackButton,null);
|
|
90 | 89 |
} |
91 | 90 |
|
92 | 91 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
93 | 92 |
|
94 |
private void setupBackButton(final RubikActivity act, final float width)
|
|
93 |
private void setupBackButton(final RubikActivity act) |
|
95 | 94 |
{ |
96 | 95 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_back,R.drawable.ui_medium_back, R.drawable.ui_big_back, R.drawable.ui_huge_back); |
97 |
mBackButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT);
|
|
96 |
mBackButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_MIDDLE);
|
|
98 | 97 |
|
99 | 98 |
mBackButton.setOnClickListener( new View.OnClickListener() |
100 | 99 |
{ |
src/main/java/org/distorted/tutorials/TutorialActivity.java | ||
---|---|---|
75 | 75 |
{ |
76 | 76 |
super.onCreate(savedState); |
77 | 77 |
DistortedLibrary.onCreate(1); |
78 |
setTheme(R.style.CustomActivityThemeNoActionBar);
|
|
78 |
setTheme(R.style.MaterialThemeNoActionBar);
|
|
79 | 79 |
setContentView(R.layout.tutorial); |
80 | 80 |
|
81 | 81 |
Bundle b = getIntent().getExtras(); |
... | ... | |
139 | 139 |
|
140 | 140 |
if( mState==null ) mState = new TutorialScreen(); |
141 | 141 |
|
142 |
mState.createRightPane(this,width);
|
|
142 |
mState.createRightPane(this); |
|
143 | 143 |
|
144 | 144 |
WebView videoView = findViewById(R.id.tutorialVideoView); |
145 | 145 |
mWebView = new TutorialWebView(videoView); |
src/main/java/org/distorted/tutorials/TutorialScreen.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import android.app.Activity; |
23 | 23 |
import android.view.View; |
24 |
import android.widget.ImageButton; |
|
25 | 24 |
import android.widget.LinearLayout; |
26 | 25 |
|
27 | 26 |
import org.distorted.helpers.MovesController; |
28 | 27 |
import org.distorted.objectlib.main.ObjectControl; |
29 |
import org.distorted.objectlib.main.ObjectType; |
|
30 | 28 |
|
31 | 29 |
import org.distorted.helpers.LockController; |
32 | 30 |
import org.distorted.main.R; |
... | ... | |
39 | 37 |
|
40 | 38 |
public class TutorialScreen |
41 | 39 |
{ |
42 |
private ImageButton mSolveButton, mScrambleButton, mBackButton; |
|
40 |
private TransparentImageButton mSolveButton, mScrambleButton, mBackButton;
|
|
43 | 41 |
private final LockController mLockController; |
44 | 42 |
private final MovesController mMovesController; |
45 | 43 |
|
46 | 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
47 | 45 |
|
48 |
private void setupSolveButton(final TutorialActivity act, final float width)
|
|
46 |
private void setupSolveButton(final TutorialActivity act) |
|
49 | 47 |
{ |
50 | 48 |
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); |
51 |
mSolveButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT);
|
|
49 |
mSolveButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_MIDDLE);
|
|
52 | 50 |
|
53 | 51 |
mSolveButton.setOnClickListener( new View.OnClickListener() |
54 | 52 |
{ |
... | ... | |
63 | 61 |
|
64 | 62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
65 | 63 |
|
66 |
private void setupScrambleButton(final TutorialActivity act, final float width)
|
|
64 |
private void setupScrambleButton(final TutorialActivity act) |
|
67 | 65 |
{ |
68 | 66 |
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); |
69 |
mScrambleButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT);
|
|
67 |
mScrambleButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_MIDDLE);
|
|
70 | 68 |
|
71 | 69 |
mScrambleButton.setOnClickListener( new View.OnClickListener() |
72 | 70 |
{ |
... | ... | |
82 | 80 |
|
83 | 81 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
84 | 82 |
|
85 |
private void setupBackButton(final TutorialActivity act, final float width)
|
|
83 |
private void setupBackButton(final TutorialActivity act) |
|
86 | 84 |
{ |
87 | 85 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_smallback,R.drawable.ui_medium_smallback, R.drawable.ui_big_smallback, R.drawable.ui_huge_smallback); |
88 |
mBackButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT);
|
|
86 |
mBackButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_MIDDLE);
|
|
89 | 87 |
|
90 | 88 |
mBackButton.setOnClickListener( new View.OnClickListener() |
91 | 89 |
{ |
... | ... | |
101 | 99 |
|
102 | 100 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
103 | 101 |
|
104 |
void createRightPane(final TutorialActivity act, float width)
|
|
102 |
void createRightPane(final TutorialActivity act) |
|
105 | 103 |
{ |
106 | 104 |
LinearLayout layout = act.findViewById(R.id.tutorialRightBar); |
107 | 105 |
layout.removeAllViews(); |
108 | 106 |
|
109 | 107 |
ObjectControl control = act.getControl(); |
110 |
mMovesController.setupButton(act,control, width);
|
|
111 |
mLockController.setupButton(act,control,width);
|
|
112 |
setupSolveButton(act,width);
|
|
113 |
setupScrambleButton(act,width);
|
|
114 |
setupBackButton(act,width);
|
|
108 |
mMovesController.setupButton(act,control); |
|
109 |
mLockController.setupButton(act,control); |
|
110 |
setupSolveButton(act); |
|
111 |
setupScrambleButton(act); |
|
112 |
setupBackButton(act); |
|
115 | 113 |
|
116 | 114 |
layout.addView(mSolveButton); |
117 |
layout.addView(mMovesController.getButton()); |
|
118 | 115 |
layout.addView(mScrambleButton); |
116 |
layout.addView(mMovesController.getButton()); |
|
119 | 117 |
layout.addView(mLockController.getButton()); |
120 | 118 |
layout.addView(mBackButton); |
121 | 119 |
} |
src/main/res/values/styles.xml | ||
---|---|---|
15 | 15 |
<item name="android:windowContentOverlay">@null</item> |
16 | 16 |
</style> |
17 | 17 |
|
18 |
<style name="MaterialThemeNoActionBar" parent="@style/Theme.MaterialComponents.NoActionBar"> |
|
19 |
<item name="android:windowNoTitle">true</item> |
|
20 |
<item name="android:windowActionBar">false</item> |
|
21 |
<item name="android:windowFullscreen">true</item> |
|
22 |
<item name="android:windowContentOverlay">@null</item> |
|
23 |
</style> |
|
24 |
|
|
18 | 25 |
</resources> |
Also available in: Unified diff
Convert the theme to be a MaterialTheme and the TransparentImageButton to be a MaterialButton - the first forced by the second, and the second because a MaterialButton gives us control over the location of the icon in top of it. We need that because of the new 'solve/scramble' split-button in the lower right of the Play screen.