30 |
30 |
import org.distorted.helpers.TransparentImageButton;
|
31 |
31 |
import org.distorted.main.R;
|
32 |
32 |
import org.distorted.main.RubikActivity;
|
33 |
|
|
34 |
|
import static org.distorted.objectlib.scrambling.ScrambleStateLocallyBandaged.MAX_SUPPORTED_SIZE;
|
|
33 |
import org.distorted.objectlib.bandaged.LocallyBandagedList;
|
35 |
34 |
|
36 |
35 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
37 |
36 |
|
... | ... | |
45 |
44 |
private Spinner mSpinnerX, mSpinnerY, mSpinnerZ;
|
46 |
45 |
private boolean mSpinnersReady;
|
47 |
46 |
private float mTextSize;
|
|
47 |
private final int mOrdinal;
|
|
48 |
private final int mDimension;
|
|
49 |
private final int mMaxSupported;
|
48 |
50 |
|
49 |
51 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
50 |
52 |
|
51 |
|
public BandagedCreatorScreen()
|
|
53 |
public BandagedCreatorScreen(int ordinal)
|
52 |
54 |
{
|
53 |
|
mSpinnersReady = false;
|
|
55 |
mOrdinal = ordinal;
|
|
56 |
mMaxSupported = LocallyBandagedList.getMaxSupported(ordinal);
|
|
57 |
mDimension = LocallyBandagedList.getDimension(ordinal);
|
|
58 |
mSpinnersReady= false;
|
54 |
59 |
mNumObjects = 0;
|
55 |
60 |
mViews = new ArrayList<>();
|
56 |
61 |
}
|
... | ... | |
115 |
120 |
|
116 |
121 |
private String[] createSizes(String mark)
|
117 |
122 |
{
|
118 |
|
String[] ret = new String[MAX_SUPPORTED_SIZE];
|
|
123 |
String[] ret = new String[mMaxSupported];
|
119 |
124 |
|
120 |
|
for(int i=1; i<=MAX_SUPPORTED_SIZE; i++)
|
|
125 |
for(int i=1; i<=mMaxSupported; i++)
|
121 |
126 |
{
|
122 |
127 |
ret[i-1] = mark+" : "+i;
|
123 |
128 |
}
|
... | ... | |
173 |
178 |
layout.addView(layoutRight);
|
174 |
179 |
|
175 |
180 |
mSpinnerX = act.findViewById(R.id.bandagedCreatorX);
|
176 |
|
mSpinnerX.setOnItemSelectedListener(this);
|
177 |
|
ArrayAdapter<String> adX = new ArrayAdapter<>(act, R.layout.spinner_item, createSizes("X") );
|
178 |
|
mSpinnerX.setAdapter(adX);
|
179 |
|
|
180 |
181 |
mSpinnerY = act.findViewById(R.id.bandagedCreatorY);
|
181 |
|
mSpinnerY.setOnItemSelectedListener(this);
|
182 |
|
ArrayAdapter<String> adY = new ArrayAdapter<>(act, R.layout.spinner_item, createSizes("Y") );
|
183 |
|
mSpinnerY.setAdapter(adY);
|
184 |
|
|
185 |
182 |
mSpinnerZ = act.findViewById(R.id.bandagedCreatorZ);
|
186 |
|
mSpinnerZ.setOnItemSelectedListener(this);
|
187 |
|
ArrayAdapter<String> adZ = new ArrayAdapter<>(act, R.layout.spinner_item, createSizes("Z") );
|
188 |
|
mSpinnerZ.setAdapter(adZ);
|
189 |
|
|
190 |
|
ViewGroup.MarginLayoutParams paramsX = (ViewGroup.MarginLayoutParams) mSpinnerX.getLayoutParams();
|
191 |
|
paramsX.setMargins(0,0,2*padding,0);
|
192 |
|
ViewGroup.MarginLayoutParams paramsY = (ViewGroup.MarginLayoutParams) mSpinnerY.getLayoutParams();
|
193 |
|
paramsY.setMargins(padding,0,padding,0);
|
194 |
|
ViewGroup.MarginLayoutParams paramsZ = (ViewGroup.MarginLayoutParams) mSpinnerZ.getLayoutParams();
|
195 |
|
paramsZ.setMargins(2*padding,0,0,0);
|
|
183 |
|
|
184 |
if( mDimension>=1 )
|
|
185 |
{
|
|
186 |
mSpinnerX.setOnItemSelectedListener(this);
|
|
187 |
ArrayAdapter<String> adX=new ArrayAdapter<>(act, R.layout.spinner_item, createSizes("X"));
|
|
188 |
mSpinnerX.setAdapter(adX);
|
|
189 |
ViewGroup.MarginLayoutParams paramsX=(ViewGroup.MarginLayoutParams) mSpinnerX.getLayoutParams();
|
|
190 |
paramsX.setMargins(0, 0, 2*padding, 0);
|
|
191 |
}
|
|
192 |
else
|
|
193 |
{
|
|
194 |
mSpinnerX.setVisibility(View.INVISIBLE);
|
|
195 |
}
|
|
196 |
|
|
197 |
if( mDimension>=2 )
|
|
198 |
{
|
|
199 |
mSpinnerY.setOnItemSelectedListener(this);
|
|
200 |
ArrayAdapter<String> adY=new ArrayAdapter<>(act, R.layout.spinner_item, createSizes("Y"));
|
|
201 |
mSpinnerY.setAdapter(adY);
|
|
202 |
ViewGroup.MarginLayoutParams paramsY=(ViewGroup.MarginLayoutParams) mSpinnerY.getLayoutParams();
|
|
203 |
paramsY.setMargins(padding, 0, padding, 0);
|
|
204 |
}
|
|
205 |
else
|
|
206 |
{
|
|
207 |
mSpinnerY.setVisibility(View.INVISIBLE);
|
|
208 |
}
|
|
209 |
|
|
210 |
if( mDimension>=3 )
|
|
211 |
{
|
|
212 |
mSpinnerZ.setOnItemSelectedListener(this);
|
|
213 |
ArrayAdapter<String> adZ=new ArrayAdapter<>(act, R.layout.spinner_item, createSizes("Z"));
|
|
214 |
mSpinnerZ.setAdapter(adZ);
|
|
215 |
ViewGroup.MarginLayoutParams paramsZ=(ViewGroup.MarginLayoutParams) mSpinnerZ.getLayoutParams();
|
|
216 |
paramsZ.setMargins(2*padding, 0, 0, 0);
|
|
217 |
}
|
|
218 |
else
|
|
219 |
{
|
|
220 |
mSpinnerZ.setVisibility(View.INVISIBLE);
|
|
221 |
}
|
196 |
222 |
}
|
197 |
223 |
|
198 |
224 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
339 |
365 |
@Override
|
340 |
366 |
public void onNothingSelected(AdapterView<?> parent) { }
|
341 |
367 |
|
|
368 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
369 |
|
|
370 |
private String generateObjectKey()
|
|
371 |
{
|
|
372 |
return mOrdinal==0 ? "bandagedObjects" : "bandagedObjects"+mOrdinal;
|
|
373 |
}
|
|
374 |
|
342 |
375 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
343 |
376 |
|
344 |
377 |
public void savePreferences(SharedPreferences.Editor editor)
|
345 |
378 |
{
|
346 |
379 |
String objects = generateObjectStrings();
|
347 |
|
editor.putString("bandagedObjects", objects );
|
|
380 |
editor.putString(generateObjectKey(), objects );
|
348 |
381 |
|
349 |
|
editor.putInt("bandagedX", mX);
|
350 |
|
editor.putInt("bandagedY", mY);
|
351 |
|
editor.putInt("bandagedZ", mZ);
|
|
382 |
editor.putInt("bandagedX"+mOrdinal, mX);
|
|
383 |
editor.putInt("bandagedY"+mOrdinal, mY);
|
|
384 |
editor.putInt("bandagedZ"+mOrdinal, mZ);
|
352 |
385 |
}
|
353 |
386 |
|
354 |
387 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
355 |
388 |
|
356 |
389 |
public void restorePreferences(BandagedCreatorActivity act, SharedPreferences preferences)
|
357 |
390 |
{
|
358 |
|
String objects = preferences.getString("bandagedObjects","");
|
|
391 |
String objects = preferences.getString(generateObjectKey(),"");
|
359 |
392 |
addObjects(act,objects);
|
360 |
393 |
|
361 |
|
mX = preferences.getInt("bandagedX", 2);
|
362 |
|
mY = preferences.getInt("bandagedY", 2);
|
363 |
|
mZ = preferences.getInt("bandagedZ", 2);
|
|
394 |
mX = preferences.getInt("bandagedX"+mOrdinal, 2);
|
|
395 |
mY = preferences.getInt("bandagedY"+mOrdinal, 2);
|
|
396 |
mZ = preferences.getInt("bandagedZ"+mOrdinal, 2);
|
364 |
397 |
|
365 |
398 |
mSpinnerX.setSelection(mX);
|
366 |
399 |
mSpinnerY.setSelection(mY);
|
initial support for Bandaged UI.