Revision 298f3977
Added by Leszek Koltunski about 2 years ago
src/main/java/org/distorted/bandaged/BandagedCreatorRenderer.java | ||
---|---|---|
445 | 445 |
try |
446 | 446 |
{ |
447 | 447 |
JsonWriter writer = JsonWriter.getInstance(); |
448 |
String json = writer.createObjectString(object,24); |
|
448 |
String json = writer.createObjectString(object,24,true);
|
|
449 | 449 |
writer.write(filename,json); |
450 | 450 |
return true; |
451 | 451 |
} |
src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java | ||
---|---|---|
194 | 194 |
try |
195 | 195 |
{ |
196 | 196 |
JsonReader reader = JsonReader.getInstance(); |
197 |
mInfo.mNumScrambles = reader.readNumScrambles(act,objectName); |
|
198 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Read from JSON numScrambles="+mInfo.mNumScrambles); |
|
197 |
reader.readNumScramblesAndIsFree(act,objectName); |
|
198 |
mInfo.mNumScrambles = reader.getNumScrambles(); |
|
199 |
mInfo.mIsFree = reader.isFree(); |
|
200 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Read from JSON numScrambles="+mInfo.mNumScrambles+" isFree="+mInfo.mIsFree); |
|
199 | 201 |
|
200 | 202 |
if( mInfo.mExtrasStream!=null ) |
201 | 203 |
{ |
... | ... | |
211 | 213 |
|
212 | 214 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "1"); |
213 | 215 |
|
214 |
boolean success = RubikObjectList.addDownloadedObject(act, mInfo.mObjectShortName,mInfo.mNumScrambles, mInfo.mObjectMinorVersion,
|
|
215 |
mInfo.mExtrasMinorVersion, mIconSaved, oSuccess, eSuccess); |
|
216 |
boolean success = RubikObjectList.addDownloadedObject(act, mInfo.mObjectShortName, mInfo.mNumScrambles, mInfo.mIsFree,
|
|
217 |
mInfo.mObjectMinorVersion, mInfo.mExtrasMinorVersion, mIconSaved, oSuccess, eSuccess);
|
|
216 | 218 |
if( success ) |
217 | 219 |
{ |
218 | 220 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "2"); |
src/main/java/org/distorted/external/RubikUpdates.java | ||
---|---|---|
36 | 36 |
public final boolean mUpdateExtras; |
37 | 37 |
|
38 | 38 |
public int mNumScrambles; |
39 |
public boolean mIsFree; |
|
39 | 40 |
public Bitmap mIcon; |
40 | 41 |
public InputStream mObjectStream; |
41 | 42 |
public InputStream mExtrasStream; |
src/main/java/org/distorted/objects/RubikObject.java | ||
---|---|---|
40 | 40 |
private final String mLowerName, mUpperName; |
41 | 41 |
private final int mIconID; |
42 | 42 |
private final String[][] mPatterns; |
43 |
private final boolean mIsFree; |
|
43 | 44 |
|
44 | 45 |
private int mJsonID, mMeshID, mExtrasID; |
45 | 46 |
private int mObjectMinor, mExtrasMinor; |
... | ... | |
57 | 58 |
mUpperName = type.name(); |
58 | 59 |
mLowerName = type.name().toLowerCase(Locale.ENGLISH); |
59 | 60 |
mNumScramble = type.getNumScramble(); |
61 |
mIsFree = type.isFree(); |
|
60 | 62 |
|
61 | 63 |
mIconID = type.getIconID(); |
62 | 64 |
mJsonID = ObjectJson.getObjectJsonID(ordinal); |
... | ... | |
87 | 89 |
mNumScramble = object.numScrambles; |
88 | 90 |
mObjectMinor = object.objectMinor; |
89 | 91 |
mExtrasMinor = object.extrasMinor; |
92 |
mIsFree = object.free; |
|
90 | 93 |
|
91 | 94 |
mPatterns = null; |
92 | 95 |
mMeshState = MESH_NICE; |
... | ... | |
211 | 214 |
return mNumScramble; |
212 | 215 |
} |
213 | 216 |
|
217 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
218 |
|
|
219 |
public boolean isFree() |
|
220 |
{ |
|
221 |
return mIsFree; |
|
222 |
} |
|
223 |
|
|
214 | 224 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
215 | 225 |
|
216 | 226 |
public int getObjectMinor() |
src/main/java/org/distorted/objects/RubikObjectList.java | ||
---|---|---|
38 | 38 |
public static class DownloadedObject |
39 | 39 |
{ |
40 | 40 |
String shortName; |
41 |
boolean icon,object,extras; |
|
41 |
boolean icon,object,extras,free;
|
|
42 | 42 |
int numScrambles, objectMinor, extrasMinor; |
43 | 43 |
|
44 |
DownloadedObject(String sName, int scrambles, int oMinor, int eMinor, boolean i, boolean o, boolean e) |
|
44 |
DownloadedObject(String sName, int scrambles, boolean isFree, int oMinor, int eMinor, boolean i, boolean o, boolean e)
|
|
45 | 45 |
{ |
46 | 46 |
shortName = sName; |
47 | 47 |
|
48 | 48 |
numScrambles= scrambles; |
49 |
free = isFree; |
|
49 | 50 |
objectMinor = oMinor; |
50 | 51 |
extrasMinor = eMinor; |
51 | 52 |
|
... | ... | |
133 | 134 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
134 | 135 |
// PUBLIC API |
135 | 136 |
|
136 |
public static boolean addDownloadedObject(Context context, String shortName, int numScrambles, int objectMinor, |
|
137 |
public static boolean addDownloadedObject(Context context, String shortName, int numScrambles, boolean isFree, int objectMinor,
|
|
137 | 138 |
int extrasMinor, boolean icon, boolean object, boolean extras) |
138 | 139 |
{ |
139 | 140 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "New downloaded object "+shortName+" icon="+icon+" object="+object+" extras="+extras); |
... | ... | |
171 | 172 |
if( !object ) objectMinor=-1; |
172 | 173 |
if( !extras ) extrasMinor=-1; |
173 | 174 |
|
174 |
DownloadedObject obj = new DownloadedObject(shortName,numScrambles,objectMinor,extrasMinor,icon,object,extras); |
|
175 |
DownloadedObject obj = new DownloadedObject(shortName,numScrambles,isFree,objectMinor,extrasMinor,icon,object,extras);
|
|
175 | 176 |
if ( internalAddDownloadedObject(obj) ) |
176 | 177 |
{ |
177 | 178 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Adding new downloaded object "+shortName+" icon="+obj.icon+" object="+obj.object+" extras="+obj.extras); |
... | ... | |
234 | 235 |
downloadedObjects.append(object.object ? "1":"0"); |
235 | 236 |
downloadedObjects.append(' '); |
236 | 237 |
downloadedObjects.append(object.extras ? "1":"0"); |
238 |
downloadedObjects.append(' '); |
|
239 |
downloadedObjects.append(object.free ? "true":"false"); |
|
237 | 240 |
} |
238 | 241 |
|
239 | 242 |
String objects = downloadedObjects.toString(); |
... | ... | |
279 | 282 |
for(String dObj : dObjects) |
280 | 283 |
{ |
281 | 284 |
String[] parts = dObj.split(" "); |
285 |
int length = parts.length; |
|
282 | 286 |
|
283 |
if( parts.length==7 )
|
|
287 |
if( length==7 || length==8 )
|
|
284 | 288 |
{ |
285 | 289 |
String name = parts[0]; |
286 | 290 |
String scra = parts[1]; |
... | ... | |
289 | 293 |
String icon = parts[4]; |
290 | 294 |
String obje = parts[5]; |
291 | 295 |
String extr = parts[6]; |
296 |
boolean isFree = (length==7 || Boolean.parseBoolean(parts[7])); |
|
292 | 297 |
|
293 | 298 |
int scrambles = Integer.parseInt(scra); |
294 | 299 |
int oMinor = Integer.parseInt(objM); |
... | ... | |
298 | 303 |
boolean bObje = obje.equals("1"); |
299 | 304 |
boolean bExtr = extr.equals("1"); |
300 | 305 |
|
301 |
addDownloadedObject(context,name,scrambles,oMinor,eMinor,bIcon,bObje,bExtr); |
|
306 |
addDownloadedObject(context,name,scrambles,isFree,oMinor,eMinor,bIcon,bObje,bExtr);
|
|
302 | 307 |
} |
303 | 308 |
} |
304 | 309 |
} |
Also available in: Unified diff
Partly merge the 'iap' branch.