26 |
26 |
import android.graphics.PorterDuff;
|
27 |
27 |
import android.graphics.drawable.Drawable;
|
28 |
28 |
import android.opengl.GLSurfaceView;
|
|
29 |
import android.support.v4.app.FragmentManager;
|
29 |
30 |
import android.support.v4.content.ContextCompat;
|
30 |
31 |
import android.util.AttributeSet;
|
31 |
32 |
import android.util.DisplayMetrics;
|
... | ... | |
70 |
71 |
private int mScreenWidth, mScreenHeight, mScreenMin;
|
71 |
72 |
|
72 |
73 |
private HorizontalNumberPicker mPicker;
|
73 |
|
private int mScrambleValue;
|
|
74 |
private int mPickerValue;
|
|
75 |
private RubikState mCurrentState;
|
74 |
76 |
|
75 |
77 |
private static int mButton = RubikSize.SIZE3.ordinal();
|
76 |
78 |
private static Static4D mQuatCurrent = new Static4D(0,0,0,1);
|
... | ... | |
90 |
92 |
|
91 |
93 |
void savePreferences(SharedPreferences.Editor editor)
|
92 |
94 |
{
|
93 |
|
editor.putInt("scramble", mScrambleValue );
|
|
95 |
if( mPicker!=null )
|
|
96 |
{
|
|
97 |
editor.putInt("scramble", mPicker.getValue() );
|
|
98 |
}
|
94 |
99 |
}
|
95 |
100 |
|
96 |
101 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
97 |
102 |
|
98 |
103 |
void restorePreferences(SharedPreferences preferences)
|
99 |
104 |
{
|
100 |
|
mScrambleValue= preferences.getInt("scramble", DEF_SCRAMBLE);
|
|
105 |
mPickerValue= preferences.getInt("scramble", DEF_SCRAMBLE);
|
101 |
106 |
}
|
102 |
107 |
|
103 |
108 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
260 |
265 |
|
261 |
266 |
void enterState(RubikActivity act, RubikState state)
|
262 |
267 |
{
|
263 |
|
switch(state)
|
|
268 |
if( mCurrentState!=state )
|
|
269 |
{
|
|
270 |
switch(state)
|
|
271 |
{
|
|
272 |
case MAIN: enterMainState(act); break;
|
|
273 |
case PLAY: enterPlayState(act); break;
|
|
274 |
}
|
|
275 |
|
|
276 |
if( mCurrentState==RubikState.PLAY )
|
|
277 |
{
|
|
278 |
mPickerValue = mPicker.getValue();
|
|
279 |
}
|
|
280 |
if( mCurrentState==RubikState.MAIN )
|
|
281 |
{
|
|
282 |
FragmentManager mana = act.getSupportFragmentManager();
|
|
283 |
RubikDialogMain diag = (RubikDialogMain) mana.findFragmentByTag(RubikDialogMain.getDialogTag());
|
|
284 |
|
|
285 |
if( diag!=null )
|
|
286 |
{
|
|
287 |
diag.dismiss();
|
|
288 |
}
|
|
289 |
else
|
|
290 |
{
|
|
291 |
android.util.Log.e("act", "cannot find main dialog!");
|
|
292 |
}
|
|
293 |
}
|
|
294 |
if( state==RubikState.MAIN )
|
|
295 |
{
|
|
296 |
FragmentManager mana = act.getSupportFragmentManager();
|
|
297 |
RubikDialogMain diag = (RubikDialogMain) mana.findFragmentByTag(RubikDialogMain.getDialogTag());
|
|
298 |
|
|
299 |
if( diag==null )
|
|
300 |
{
|
|
301 |
RubikDialogMain diag2 = new RubikDialogMain();
|
|
302 |
diag2.show( mana, RubikDialogMain.getDialogTag() );
|
|
303 |
}
|
|
304 |
}
|
|
305 |
|
|
306 |
mCurrentState = state;
|
|
307 |
}
|
|
308 |
else
|
264 |
309 |
{
|
265 |
|
case MAIN: enterMainState(act); break;
|
266 |
|
case PLAY: enterPlayState(act); break;
|
|
310 |
android.util.Log.e("act", "trying to change into same state "+state);
|
267 |
311 |
}
|
268 |
312 |
}
|
269 |
313 |
|
... | ... | |
361 |
405 |
{
|
362 |
406 |
mPicker.setMin(MIN_SCRAMBLE);
|
363 |
407 |
mPicker.setMax(MAX_SCRAMBLE);
|
364 |
|
mPicker.setValue(mScrambleValue);
|
|
408 |
mPicker.setValue(mPickerValue);
|
365 |
409 |
}
|
366 |
410 |
}
|
367 |
411 |
|
... | ... | |
378 |
422 |
mRenderer = new RubikRenderer(this);
|
379 |
423 |
mMovement = new RubikCubeMovement();
|
380 |
424 |
|
|
425 |
mCurrentState = null;
|
|
426 |
|
381 |
427 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
382 |
428 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
|
383 |
429 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
|
Major rearrangement of the UI.