Revision 988e3d33
Added by Leszek Koltunski 9 months ago
src/main/java/org/distorted/config/ConfigActivity.java | ||
---|---|---|
47 | 47 |
private ConfigScreenPane mPane; |
48 | 48 |
private int mCurrentApiVersion; |
49 | 49 |
private int mObjectOrdinal; |
50 |
private boolean mSupportsAdjColors; |
|
50 | 51 |
|
51 | 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
52 | 53 |
|
... | ... | |
156 | 157 |
ConfigSurfaceView view = findViewById(R.id.configSurfaceView); |
157 | 158 |
view.onResume(); |
158 | 159 |
String key =""; |
160 |
mSupportsAdjColors = false; |
|
159 | 161 |
|
160 | 162 |
if( mObjectOrdinal>=0 && mObjectOrdinal< RubikObjectList.getNumObjects() ) |
161 | 163 |
{ |
162 | 164 |
RubikObject object = RubikObjectList.getObject(mObjectOrdinal); |
163 | 165 |
changeIfDifferent(object,mObjectOrdinal,view.getObjectControl()); |
164 |
if( object!=null ) key = object.getUpperName(); |
|
166 |
|
|
167 |
if( object!=null ) |
|
168 |
{ |
|
169 |
key = object.getUpperName(); |
|
170 |
mSupportsAdjColors = object.supportsAdjustableColors(); |
|
171 |
} |
|
165 | 172 |
} |
166 | 173 |
|
167 | 174 |
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); |
168 |
restorePreferences(preferences); |
|
175 |
OSInterface os = view.getInterface(); |
|
176 |
os.setPreferences(preferences); |
|
177 |
|
|
178 |
restorePreferences(); |
|
169 | 179 |
|
170 | 180 |
if( mScreen==null ) mScreen = new ConfigScreen(); |
171 | 181 |
mScreen.onAttachedToWindow(this,mObjectOrdinal); |
172 | 182 |
|
173 |
ObjectControl control = view.getObjectControl(); |
|
174 |
OSInterface os = view.getInterface(); |
|
175 |
TwistyObject obj = control.getObject(); |
|
176 |
|
|
177 |
mPane = new ConfigScreenPane(this,key,os); |
|
183 |
mPane = new ConfigScreenPane(this,key,os,mSupportsAdjColors); |
|
178 | 184 |
} |
179 | 185 |
|
180 | 186 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
181 | 187 |
|
182 | 188 |
void repaintPuzzleFace(int cubit, int face) |
183 | 189 |
{ |
184 |
if( mPane!=null ) |
|
190 |
if( mPane!=null && mSupportsAdjColors )
|
|
185 | 191 |
{ |
186 | 192 |
int color = mPane.getCurrentColor(); |
187 | 193 |
ConfigSurfaceView view = findViewById(R.id.configSurfaceView); |
... | ... | |
239 | 245 |
|
240 | 246 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
241 | 247 |
|
242 |
private void restorePreferences(SharedPreferences preferences)
|
|
248 |
private void restorePreferences() |
|
243 | 249 |
{ |
244 | 250 |
ConfigSurfaceView view = findViewById(R.id.configSurfaceView); |
245 |
OSInterface os = view.getInterface(); |
|
246 |
os.setPreferences(preferences); |
|
247 | 251 |
view.getObjectControl().restoreStickers(); |
248 | 252 |
} |
249 | 253 |
|
src/main/java/org/distorted/config/ConfigScreenPane.java | ||
---|---|---|
117 | 117 |
markButton(mRow,mCol); |
118 | 118 |
} |
119 | 119 |
|
120 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
121 |
|
|
122 |
private View createColorSection(final ConfigActivity act, int width, int height, boolean supports) |
|
123 |
{ |
|
124 |
if( supports ) |
|
125 |
{ |
|
126 |
createColorGrid(act,width,height); |
|
127 |
return mGrid; |
|
128 |
} |
|
129 |
else |
|
130 |
{ |
|
131 |
float textSize = height*TEXT_RATIO; |
|
132 |
TextView text = new TextView(act); |
|
133 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
134 |
text.setText(R.string.config_no_support); |
|
135 |
return text; |
|
136 |
} |
|
137 |
} |
|
138 |
|
|
120 | 139 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
121 | 140 |
|
122 | 141 |
private View createView(final Activity act, final int row, final int col) |
... | ... | |
144 | 163 |
|
145 | 164 |
private void markButton(int row, int col) |
146 | 165 |
{ |
147 |
int index = mRow*COLORS[0].length + mCol; |
|
148 |
ImageButton button = (ImageButton)mGrid.getChildAt(index); |
|
149 |
button.setImageResource(0); |
|
166 |
if( mGrid!=null ) |
|
167 |
{ |
|
168 |
int index = mRow*COLORS[0].length + mCol; |
|
169 |
ImageButton button = (ImageButton)mGrid.getChildAt(index); |
|
170 |
button.setImageResource(0); |
|
150 | 171 |
|
151 |
mRow = row; |
|
152 |
mCol = col; |
|
172 |
mRow = row;
|
|
173 |
mCol = col;
|
|
153 | 174 |
|
154 |
index = mRow*COLORS[0].length + mCol; |
|
155 |
button = (ImageButton)mGrid.getChildAt(index); |
|
156 |
button.setImageResource(R.drawable.check); |
|
175 |
index = mRow*COLORS[0].length + mCol; |
|
176 |
button = (ImageButton)mGrid.getChildAt(index); |
|
177 |
button.setImageResource(R.drawable.check); |
|
178 |
} |
|
157 | 179 |
} |
158 | 180 |
|
159 | 181 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
177 | 199 |
|
178 | 200 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
179 | 201 |
|
180 |
ConfigScreenPane(final ConfigActivity act, String key, OSInterface os) |
|
202 |
ConfigScreenPane(final ConfigActivity act, String key, OSInterface os, boolean supportsAdjColors)
|
|
181 | 203 |
{ |
182 | 204 |
mRow = 0; |
183 | 205 |
mCol = 0; |
... | ... | |
268 | 290 |
|
269 | 291 |
configLayoutL.setLayoutParams(paramsLayoutL); |
270 | 292 |
|
271 |
createColorGrid(act, width, height);
|
|
293 |
View view = createColorSection(act, width, height, supportsAdjColors);
|
|
272 | 294 |
configLayoutL.removeAllViews(); |
273 |
configLayoutL.addView(mGrid);
|
|
295 |
configLayoutL.addView(view);
|
|
274 | 296 |
} |
275 | 297 |
} |
src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java | ||
---|---|---|
206 | 206 |
int category = reader.getCategory(); |
207 | 207 |
int year = reader.getYearOfInvention(); |
208 | 208 |
String author = reader.getAuthor(); |
209 |
boolean adjColors = reader.getAdjustableColors(); |
|
209 | 210 |
|
210 | 211 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Read from JSON numScrambles="+mInfo.mNumScrambles+" price="+mInfo.mPrice); |
211 | 212 |
|
... | ... | |
224 | 225 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "1"); |
225 | 226 |
|
226 | 227 |
boolean success = RubikObjectList.addDownloadedObject(act, mInfo.mObjectShortName, mInfo.mNumScrambles, mInfo.mPrice, mInfo.mObjectMinorVersion, |
227 |
mInfo.mExtrasMinorVersion, mIconSaved, oSuccess, eSuccess, diff, category, year, author); |
|
228 |
mInfo.mExtrasMinorVersion, mIconSaved, oSuccess, eSuccess, diff, category, year, author,adjColors);
|
|
228 | 229 |
if( success ) |
229 | 230 |
{ |
230 | 231 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "2"); |
src/main/java/org/distorted/objects/RubikObject.java | ||
---|---|---|
45 | 45 |
private final int mCategory, mYear; |
46 | 46 |
private final float mDifficulty; |
47 | 47 |
private final String mAuthor; |
48 |
private final boolean mAdjColors; |
|
48 | 49 |
|
49 | 50 |
private boolean mIsFree; |
50 | 51 |
private int mJsonID, mMeshID, mExtrasID; |
... | ... | |
73 | 74 |
mYear = meta.getYearOfInvention(); |
74 | 75 |
mAuthor = meta.getAuthor(); |
75 | 76 |
mIsLocal = false; |
77 |
mAdjColors = meta.supportsAdjustableStickerColors(); |
|
76 | 78 |
|
77 | 79 |
int patternOrdinal = RubikPatternList.getOrdinal(mObjectOrdinal); |
78 | 80 |
mPatterns = RubikPatternList.getPatterns(patternOrdinal); |
... | ... | |
101 | 103 |
mCategory = object.category; |
102 | 104 |
mYear = object.year; |
103 | 105 |
mAuthor = object.author; |
106 |
mAdjColors = object.adjColors; |
|
104 | 107 |
|
105 | 108 |
mPatterns = null; |
106 | 109 |
mExtrasOrdinal = -1; |
... | ... | |
231 | 234 |
return mExtrasVersion; |
232 | 235 |
} |
233 | 236 |
|
237 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
238 |
|
|
239 |
public boolean supportsAdjustableColors() |
|
240 |
{ |
|
241 |
return mAdjColors; |
|
242 |
} |
|
243 |
|
|
234 | 244 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
235 | 245 |
|
236 | 246 |
public void setIconTo(Activity act,ImageButton button) |
src/main/java/org/distorted/objects/RubikObjectList.java | ||
---|---|---|
37 | 37 |
public static class DownloadedObject |
38 | 38 |
{ |
39 | 39 |
String shortName; |
40 |
boolean icon,object,extras; |
|
40 |
boolean icon,object,extras,adjColors;
|
|
41 | 41 |
int numScrambles, objectVersion, extrasVersion, price; |
42 | 42 |
int category, year; |
43 | 43 |
float difficulty; |
44 | 44 |
String author; |
45 | 45 |
|
46 | 46 |
DownloadedObject(String sName, int scrambles, int pr, int oVersion, int eVersion, boolean i, |
47 |
boolean o, boolean e, float diff, int cat, int y, String a) |
|
47 |
boolean o, boolean e, float diff, int cat, int y, String a, boolean c)
|
|
48 | 48 |
{ |
49 | 49 |
shortName = sName; |
50 | 50 |
numScrambles = scrambles; |
... | ... | |
55 | 55 |
category = cat; |
56 | 56 |
year = y; |
57 | 57 |
author = a; |
58 |
adjColors = c; |
|
58 | 59 |
|
59 | 60 |
icon = i; |
60 | 61 |
object = o; |
... | ... | |
194 | 195 |
// PUBLIC API |
195 | 196 |
|
196 | 197 |
public static boolean addDownloadedObject(Context context, String shortName, int numScrambles, int price, int objectVersion, |
197 |
int extrasVersion, boolean icon, boolean object, boolean extras, float diff, int category, int year, String author) |
|
198 |
int extrasVersion, boolean icon, boolean object, boolean extras, float diff, |
|
199 |
int category, int year, String author, boolean adjColors) |
|
198 | 200 |
{ |
199 | 201 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "New downloaded object "+shortName+" icon="+icon+" object="+object+" extras="+extras); |
200 | 202 |
|
... | ... | |
221 | 223 |
if( !object ) objectVersion=-1; |
222 | 224 |
if( !extras ) extrasVersion=-1; |
223 | 225 |
|
224 |
DownloadedObject obj = new DownloadedObject(shortName,numScrambles,price,objectVersion,extrasVersion,icon,object,extras,diff,category,year,author); |
|
226 |
DownloadedObject obj = new DownloadedObject(shortName,numScrambles,price,objectVersion,extrasVersion,icon,object,extras,diff,category,year,author,adjColors);
|
|
225 | 227 |
if ( internalAddDownloadedObject(obj) ) |
226 | 228 |
{ |
227 | 229 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Adding new downloaded object "+shortName+" icon="+obj.icon+" object="+obj.object+" extras="+obj.extras); |
... | ... | |
327 | 329 |
downloadedObjects.append(object.author.replace(' ','_')); |
328 | 330 |
downloadedObjects.append(' '); |
329 | 331 |
downloadedObjects.append(object.price); |
332 |
downloadedObjects.append(' '); |
|
333 |
downloadedObjects.append(object.adjColors ? "1":"0"); |
|
330 | 334 |
} |
331 | 335 |
|
332 | 336 |
String objects = downloadedObjects.toString(); |
... | ... | |
379 | 383 |
String extr = parts[6]; |
380 | 384 |
|
381 | 385 |
int price=0,category=0,year=0; |
386 |
boolean supportsAdjColors=true; |
|
382 | 387 |
float diff=0.0f; |
383 | 388 |
String author=""; |
384 | 389 |
|
... | ... | |
396 | 401 |
else if( c=='f' ) price = ListObjects.DEFAULT_PRICE_OF_OLD_OBJECTS; |
397 | 402 |
else price = Integer.parseInt(parts[11]); |
398 | 403 |
} |
404 |
if( length>=13 ) |
|
405 |
{ |
|
406 |
char s = parts[12].charAt(0); |
|
407 |
supportsAdjColors = (s=='1'); |
|
408 |
} |
|
399 | 409 |
|
400 | 410 |
int scrambles = Integer.parseInt(scra); |
401 | 411 |
int oVersion = Integer.parseInt(objV); |
... | ... | |
405 | 415 |
boolean bObje = obje.equals("1"); |
406 | 416 |
boolean bExtr = extr.equals("1"); |
407 | 417 |
|
408 |
addDownloadedObject(context,name,scrambles,price,oVersion,eVersion,bIcon,bObje,bExtr,diff,category,year,author); |
|
418 |
addDownloadedObject(context,name,scrambles,price,oVersion,eVersion,bIcon,bObje,bExtr,diff,category,year,author,supportsAdjColors);
|
|
409 | 419 |
} |
410 | 420 |
} |
411 | 421 |
} |
src/main/res/values-de/strings.xml | ||
---|---|---|
88 | 88 |
<string name="config_stickers">Aufkleber</string> |
89 | 89 |
<string name="config_border">Ränder</string> |
90 | 90 |
<string name="config_corner">Ecken</string> |
91 |
<string name="config_no_support">Das aktuelle Puzzle unterstützt keine Farbanpassung.</string> |
|
91 | 92 |
|
92 | 93 |
<string name="sort_classic">klassisch</string> |
93 | 94 |
<string name="sort_shape">form</string> |
src/main/res/values-es/strings.xml | ||
---|---|---|
88 | 88 |
<string name="config_stickers">Pegatinas</string> |
89 | 89 |
<string name="config_border">Bordes</string> |
90 | 90 |
<string name="config_corner">Esquinas</string> |
91 |
<string name="config_no_support">El cubo actual no admite el ajuste de colores.</string> |
|
91 | 92 |
|
92 | 93 |
<string name="sort_classic">clásico</string> |
93 | 94 |
<string name="sort_shape">forma</string> |
src/main/res/values-fr/strings.xml | ||
---|---|---|
88 | 88 |
<string name="config_stickers">Autocollants</string> |
89 | 89 |
<string name="config_border">Bordures</string> |
90 | 90 |
<string name="config_corner">Coins</string> |
91 |
<string name="config_no_support">Le cube actuel ne prend pas en charge le réglage des couleurs.</string> |
|
91 | 92 |
|
92 | 93 |
<string name="sort_classic">classique</string> |
93 | 94 |
<string name="sort_shape">forme</string> |
src/main/res/values-ja/strings.xml | ||
---|---|---|
88 | 88 |
<string name="config_stickers">ステッカー</string> |
89 | 89 |
<string name="config_border">枠線</string> |
90 | 90 |
<string name="config_corner">角</string> |
91 |
<string name="config_no_support">現在のキューブは色の調整をサポートしていません。</string> |
|
91 | 92 |
|
92 | 93 |
<string name="sort_classic">古典学</string> |
93 | 94 |
<string name="sort_shape">形</string> |
src/main/res/values-ko/strings.xml | ||
---|---|---|
88 | 88 |
<string name="config_stickers">스티커</string> |
89 | 89 |
<string name="config_border">테두리</string> |
90 | 90 |
<string name="config_corner">모서리</string> |
91 |
<string name="config_no_support">현재 큐브는 색상 조정을 지원하지 않습니다.</string> |
|
91 | 92 |
|
92 | 93 |
<string name="sort_classic">전통적인</string> |
93 | 94 |
<string name="sort_shape">모양</string> |
src/main/res/values-pl/strings.xml | ||
---|---|---|
88 | 88 |
<string name="config_stickers">Naklejki</string> |
89 | 89 |
<string name="config_border">Brzegi</string> |
90 | 90 |
<string name="config_corner">Rogi</string> |
91 |
<string name="config_no_support">Bieżąca kostka nie wspomaga zmieniania kolorów.</string> |
|
91 | 92 |
|
92 | 93 |
<string name="sort_classic">klasycznie</string> |
93 | 94 |
<string name="sort_shape">kształt</string> |
src/main/res/values-ru/strings.xml | ||
---|---|---|
88 | 88 |
<string name="config_stickers">Наклейки</string> |
89 | 89 |
<string name="config_border">Границы</string> |
90 | 90 |
<string name="config_corner">Углы</string> |
91 |
<string name="config_no_support">Текущий куб не поддерживает настройку цветов.</string> |
|
91 | 92 |
|
92 | 93 |
<string name="sort_classic">классик</string> |
93 | 94 |
<string name="sort_shape">форма</string> |
src/main/res/values-zh-rCN/strings.xml | ||
---|---|---|
88 | 88 |
<string name="config_stickers">贴纸</string> |
89 | 89 |
<string name="config_border">边框</string> |
90 | 90 |
<string name="config_corner">角</string> |
91 |
<string name="config_no_support">目前拼图不支持调整颜色。</string> |
|
91 | 92 |
|
92 | 93 |
<string name="sort_classic">經典的</string> |
93 | 94 |
<string name="sort_shape">形狀</string> |
src/main/res/values-zh-rTW/strings.xml | ||
---|---|---|
88 | 88 |
<string name="config_stickers">貼紙</string> |
89 | 89 |
<string name="config_border">邊框</string> |
90 | 90 |
<string name="config_corner">角</string> |
91 |
<string name="config_no_support">目前拼圖不支援調整顏色。</string> |
|
91 | 92 |
|
92 | 93 |
<string name="sort_classic">经典的</string> |
93 | 94 |
<string name="sort_shape">形状</string> |
src/main/res/values/strings.xml | ||
---|---|---|
112 | 112 |
<string name="config_stickers">Stickers</string> |
113 | 113 |
<string name="config_border">Borders</string> |
114 | 114 |
<string name="config_corner">Corners</string> |
115 |
<string name="config_no_support">Current puzzle does not support adjusting colors.</string> |
|
115 | 116 |
|
116 | 117 |
<string name="sort_classic">classic</string> |
117 | 118 |
<string name="sort_shape">shape</string> |
Also available in: Unified diff
Objects can support or not changing colors of their stickers.