Revision 0effd5a9
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/external/RubikNetwork.java | ||
---|---|---|
465 | 465 |
String country = scores.getCountry(); |
466 | 466 |
String renderer = DistortedLibrary.getDriverRenderer(); |
467 | 467 |
String version = DistortedLibrary.getDriverVersion(); |
468 |
int objectAPI = JsonWriter.VERSION_OBJECT_MAJOR;
|
|
469 |
int tutorialAPI = JsonWriter.VERSION_EXTRAS_MAJOR;
|
|
468 |
int objectAPI = JsonWriter.VERSION_OBJECT_APP;
|
|
469 |
int tutorialAPI = JsonWriter.VERSION_EXTRAS_APP;
|
|
470 | 470 |
int numStars = scores.getNumStars(); |
471 | 471 |
|
472 | 472 |
renderer = URLencode(renderer); |
src/main/java/org/distorted/external/RubikUpdates.java | ||
---|---|---|
96 | 96 |
String iconPresent = elements[4].trim(); |
97 | 97 |
String longName = elements[5]; |
98 | 98 |
String description = elements[6]; |
99 |
int oMinor, eMinor, oPercent, oIcon;
|
|
99 |
int oVersion, eVersion, oPercent, oIcon;
|
|
100 | 100 |
|
101 |
try { oMinor = Integer.parseInt(objMinor); }
|
|
102 |
catch (NumberFormatException ex) { oMinor = -1; }
|
|
103 |
try { eMinor = Integer.parseInt(extMinor); }
|
|
104 |
catch (NumberFormatException ex) { eMinor = -1; }
|
|
101 |
try { oVersion = Integer.parseInt(objMinor); }
|
|
102 |
catch (NumberFormatException ex) { oVersion = -1; }
|
|
103 |
try { eVersion = Integer.parseInt(extMinor); }
|
|
104 |
catch (NumberFormatException ex) { eVersion = -1; }
|
|
105 | 105 |
try { oPercent = Integer.parseInt(percent); } |
106 | 106 |
catch (NumberFormatException ex) { oPercent = -1; } |
107 | 107 |
try { oIcon = Integer.parseInt(iconPresent); } |
108 | 108 |
catch (NumberFormatException ex) { oIcon = 0; } |
109 | 109 |
|
110 |
if( oMinor>=0 && eMinor>=0 && oPercent>=0 )
|
|
110 |
if( oVersion>=0 && eVersion>=0 && oPercent>=0 )
|
|
111 | 111 |
{ |
112 | 112 |
String upperName = shortName.toUpperCase(Locale.ENGLISH); |
113 | 113 |
int objOrdinal = RubikObjectList.getOrdinal(upperName); |
114 | 114 |
boolean updateO=true, updateE=true; |
115 | 115 |
|
116 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "downloaded object "+shortName+" oMinor="+oMinor+" eMinor="+eMinor);
|
|
116 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "downloaded object "+shortName+" oVer="+oVersion+" eVer="+eVersion);
|
|
117 | 117 |
|
118 | 118 |
if( objOrdinal>=0 ) |
119 | 119 |
{ |
120 |
int localObjectMinor = RubikObjectList.getLocalObjectMinor(objOrdinal);
|
|
121 |
int localExtrasMinor = RubikObjectList.getLocalExtrasMinor(objOrdinal);
|
|
122 |
updateO = localObjectMinor<oMinor;
|
|
123 |
updateE = localExtrasMinor<eMinor;
|
|
120 |
int localObjectVer = RubikObjectList.getLocalObjectVersion(objOrdinal);
|
|
121 |
int localExtrasVer = RubikObjectList.getLocalExtrasVersion(objOrdinal);
|
|
122 |
updateO = localObjectVer<oVersion;
|
|
123 |
updateE = localExtrasVer<eVersion;
|
|
124 | 124 |
|
125 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "object exists locally, localObjectMinor="+localObjectMinor+" localExtrasMinor="+localExtrasMinor);
|
|
125 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "object exists locally, localObjectVer="+localObjectVer+" localExtrasVer="+localExtrasVer);
|
|
126 | 126 |
} |
127 | 127 |
if( updateO || updateE ) |
128 | 128 |
{ |
129 |
UpdateInfo info = new UpdateInfo(shortName,longName,description,oMinor,eMinor,oPercent,oIcon,updateO,updateE);
|
|
129 |
UpdateInfo info = new UpdateInfo(shortName,longName,description,oVersion,eVersion,oPercent,oIcon,updateO,updateE);
|
|
130 | 130 |
if(oPercent>=100) |
131 | 131 |
{ |
132 | 132 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "object added to completed"); |
src/main/java/org/distorted/main/RubikActivity.java | ||
---|---|---|
273 | 273 |
int object = RubikObjectList.getCurrObject(); |
274 | 274 |
changeIfDifferent(object,view.getObjectControl()); |
275 | 275 |
|
276 |
if( mIsChinese && !mPolicyAccepted ) privacyPolicy(); |
|
277 |
else |
|
276 |
// switch this off - we are not present in China anymore. |
|
277 |
// if( mIsChinese && !mPolicyAccepted ) privacyPolicy(); |
|
278 |
// else |
|
278 | 279 |
{ |
279 | 280 |
if( !mOldVersion.equals(mCurrVersion) ) |
280 | 281 |
{ |
src/main/java/org/distorted/objects/RubikObject.java | ||
---|---|---|
27 | 27 |
import org.distorted.jsons.ObjectJson; |
28 | 28 |
import org.distorted.main.R; |
29 | 29 |
import org.distorted.main.RubikActivity; |
30 |
import org.distorted.objectlib.json.JsonWriter; |
|
31 | 30 |
import org.distorted.objectlib.main.ObjectType; |
32 | 31 |
import org.distorted.objectlib.patterns.RubikPatternList; |
33 | 32 |
|
... | ... | |
47 | 46 |
|
48 | 47 |
private boolean mIsFree; |
49 | 48 |
private int mJsonID, mMeshID, mExtrasID; |
50 |
private int mObjectMinor, mExtrasMinor;
|
|
49 |
private int mObjectVersion, mExtrasVersion;
|
|
51 | 50 |
private int mNumScramble; |
52 | 51 |
private int mMeshState; |
53 | 52 |
private int mExtrasOrdinal; |
... | ... | |
64 | 63 |
mNumScramble = type.getNumScramble(); |
65 | 64 |
mPrice = type.getPrice(); |
66 | 65 |
mIsFree = mPrice==0; |
67 |
|
|
68 | 66 |
mIconID = type.getIconID(); |
69 | 67 |
mJsonID = ObjectJson.getObjectJsonID(ordinal); |
70 | 68 |
mMeshID = ObjectMesh.getMeshID(ordinal); |
... | ... | |
76 | 74 |
mMeshState = MESH_NICE; |
77 | 75 |
mExtrasOrdinal = -1; |
78 | 76 |
|
79 |
mObjectMinor = JsonWriter.VERSION_OBJECT_MINOR;
|
|
80 |
mExtrasMinor = JsonWriter.VERSION_EXTRAS_MINOR;
|
|
77 |
mObjectVersion = ObjectType.getObjectVersion(ordinal);
|
|
78 |
mExtrasVersion = ObjectType.getExtrasVersion(ordinal);
|
|
81 | 79 |
|
82 | 80 |
mStaticIconD = null; |
83 | 81 |
mRescaledIconD= null; |
... | ... | |
94 | 92 |
mNumScramble = object.numScrambles; |
95 | 93 |
mPrice = object.price; |
96 | 94 |
mIsFree = mPrice==0; |
97 |
mObjectMinor = object.objectMinor;
|
|
98 |
mExtrasMinor = object.extrasMinor;
|
|
95 |
mObjectVersion = object.objectVersion;
|
|
96 |
mExtrasVersion = object.extrasVersion;
|
|
99 | 97 |
|
100 | 98 |
mPatterns = null; |
101 | 99 |
mMeshState = MESH_NICE; |
... | ... | |
113 | 111 |
{ |
114 | 112 |
boolean changed = false; |
115 | 113 |
|
116 |
if( object.objectMinor>JsonWriter.VERSION_OBJECT_MINOR )
|
|
114 |
if( object.objectVersion>mObjectVersion )
|
|
117 | 115 |
{ |
118 | 116 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Updating RubikObject's "+object.shortName+" main JSON"); |
119 | 117 |
|
120 |
mObjectMinor = object.objectMinor;
|
|
121 |
mNumScramble = object.numScrambles; |
|
118 |
mObjectVersion= object.objectVersion;
|
|
119 |
mNumScramble = object.numScrambles;
|
|
122 | 120 |
mMeshID = 0; |
123 | 121 |
mJsonID = -1; |
124 | 122 |
changed = true; |
125 | 123 |
} |
126 | 124 |
|
127 |
if( object.extrasMinor>JsonWriter.VERSION_EXTRAS_MINOR )
|
|
125 |
if( object.extrasVersion>mExtrasVersion )
|
|
128 | 126 |
{ |
129 | 127 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Updating RubikObject's "+object.shortName+" extras JSON"); |
130 | 128 |
|
131 |
mExtrasMinor = object.extrasMinor;
|
|
129 |
mExtrasVersion = object.extrasVersion;
|
|
132 | 130 |
mExtrasID = -1; |
133 | 131 |
changed = true; |
134 | 132 |
} |
... | ... | |
243 | 241 |
|
244 | 242 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
245 | 243 |
|
246 |
public int getObjectMinor()
|
|
244 |
public int getObjectVersion()
|
|
247 | 245 |
{ |
248 |
return mObjectMinor;
|
|
246 |
return mObjectVersion;
|
|
249 | 247 |
} |
250 | 248 |
|
251 | 249 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
252 | 250 |
|
253 |
public int getExtrasMinor()
|
|
251 |
public int getExtrasVersion()
|
|
254 | 252 |
{ |
255 |
return mExtrasMinor;
|
|
253 |
return mExtrasVersion;
|
|
256 | 254 |
} |
257 | 255 |
|
258 | 256 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/RubikObjectList.java | ||
---|---|---|
43 | 43 |
{ |
44 | 44 |
String shortName; |
45 | 45 |
boolean icon,object,extras; |
46 |
int numScrambles, objectMinor, extrasMinor, price;
|
|
46 |
int numScrambles, objectVersion, extrasVersion, price;
|
|
47 | 47 |
|
48 |
DownloadedObject(String sName, int scrambles, int pr, int oMinor, int eMinor, boolean i, boolean o, boolean e)
|
|
48 |
DownloadedObject(String sName, int scrambles, int pr, int oVersion, int eVersion, boolean i, boolean o, boolean e)
|
|
49 | 49 |
{ |
50 |
shortName = sName; |
|
51 |
numScrambles= scrambles; |
|
52 |
price = pr; |
|
53 |
objectMinor = oMinor;
|
|
54 |
extrasMinor = eMinor;
|
|
50 |
shortName = sName;
|
|
51 |
numScrambles = scrambles;
|
|
52 |
price = pr;
|
|
53 |
objectVersion = oVersion;
|
|
54 |
extrasVersion = eVersion;
|
|
55 | 55 |
|
56 | 56 |
icon = i; |
57 | 57 |
object = o; |
... | ... | |
187 | 187 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
188 | 188 |
// PUBLIC API |
189 | 189 |
|
190 |
public static boolean addDownloadedObject(Context context, String shortName, int numScrambles, int price, int objectMinor,
|
|
191 |
int extrasMinor, boolean icon, boolean object, boolean extras)
|
|
190 |
public static boolean addDownloadedObject(Context context, String shortName, int numScrambles, int price, int objectVersion,
|
|
191 |
int extrasVersion, boolean icon, boolean object, boolean extras)
|
|
192 | 192 |
{ |
193 | 193 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "New downloaded object "+shortName+" icon="+icon+" object="+object+" extras="+extras); |
194 | 194 |
|
... | ... | |
200 | 200 |
obj.object|= object; |
201 | 201 |
obj.extras|= extras; |
202 | 202 |
|
203 |
if( !obj.object ) objectMinor=-1;
|
|
204 |
if( !obj.extras ) extrasMinor=-1;
|
|
203 |
if( !obj.object ) objectVersion=-1;
|
|
204 |
if( !obj.extras ) extrasVersion=-1;
|
|
205 | 205 |
|
206 |
obj.objectMinor = objectMinor;
|
|
207 |
obj.extrasMinor = extrasMinor;
|
|
206 |
obj.objectVersion = objectVersion;
|
|
207 |
obj.extrasVersion = extrasVersion;
|
|
208 | 208 |
|
209 | 209 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Updating downloaded object "+shortName+" icon="+obj.icon+" object="+obj.object+" extras="+obj.extras); |
210 | 210 |
|
... | ... | |
222 | 222 |
} |
223 | 223 |
} |
224 | 224 |
|
225 |
if( !object ) objectMinor=-1;
|
|
226 |
if( !extras ) extrasMinor=-1;
|
|
225 |
if( !object ) objectVersion=-1;
|
|
226 |
if( !extras ) extrasVersion=-1;
|
|
227 | 227 |
|
228 |
DownloadedObject obj = new DownloadedObject(shortName,numScrambles,price,objectMinor,extrasMinor,icon,object,extras);
|
|
228 |
DownloadedObject obj = new DownloadedObject(shortName,numScrambles,price,objectVersion,extrasVersion,icon,object,extras);
|
|
229 | 229 |
if ( internalAddDownloadedObject(obj) ) |
230 | 230 |
{ |
231 | 231 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Adding new downloaded object "+shortName+" icon="+obj.icon+" object="+obj.object+" extras="+obj.extras); |
... | ... | |
345 | 345 |
downloadedObjects.append(' '); |
346 | 346 |
downloadedObjects.append(object.numScrambles); |
347 | 347 |
downloadedObjects.append(' '); |
348 |
downloadedObjects.append(object.objectMinor);
|
|
348 |
downloadedObjects.append(object.objectVersion);
|
|
349 | 349 |
downloadedObjects.append(' '); |
350 |
downloadedObjects.append(object.extrasMinor);
|
|
350 |
downloadedObjects.append(object.extrasVersion);
|
|
351 | 351 |
downloadedObjects.append(' '); |
352 | 352 |
downloadedObjects.append(object.icon ? "1":"0"); |
353 | 353 |
downloadedObjects.append(' '); |
... | ... | |
409 | 409 |
{ |
410 | 410 |
String name = parts[0]; |
411 | 411 |
String scra = parts[1]; |
412 |
String objM = parts[2];
|
|
413 |
String extM = parts[3];
|
|
412 |
String objV = parts[2];
|
|
413 |
String extV = parts[3];
|
|
414 | 414 |
String icon = parts[4]; |
415 | 415 |
String obje = parts[5]; |
416 | 416 |
String extr = parts[6]; |
... | ... | |
427 | 427 |
} |
428 | 428 |
|
429 | 429 |
int scrambles = Integer.parseInt(scra); |
430 |
int oMinor = Integer.parseInt(objM);
|
|
431 |
int eMinor = Integer.parseInt(extM);
|
|
430 |
int oVersion = Integer.parseInt(objV);
|
|
431 |
int eVersion = Integer.parseInt(extV);
|
|
432 | 432 |
|
433 | 433 |
boolean bIcon = icon.equals("1"); |
434 | 434 |
boolean bObje = obje.equals("1"); |
435 | 435 |
boolean bExtr = extr.equals("1"); |
436 | 436 |
|
437 |
addDownloadedObject(context,name,scrambles,price,oMinor,eMinor,bIcon,bObje,bExtr);
|
|
437 |
addDownloadedObject(context,name,scrambles,price,oVersion,eVersion,bIcon,bObje,bExtr);
|
|
438 | 438 |
} |
439 | 439 |
} |
440 | 440 |
} |
... | ... | |
657 | 657 |
|
658 | 658 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
659 | 659 |
|
660 |
public static int getLocalObjectMinor(int objectOrdinal)
|
|
660 |
public static int getLocalObjectVersion(int objectOrdinal)
|
|
661 | 661 |
{ |
662 | 662 |
RubikObject object = getObject(objectOrdinal); |
663 |
return object!=null ? object.getObjectMinor() : -1;
|
|
663 |
return object!=null ? object.getObjectVersion() : -1;
|
|
664 | 664 |
} |
665 | 665 |
|
666 | 666 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
667 | 667 |
|
668 |
public static int getLocalExtrasMinor(int objectOrdinal)
|
|
668 |
public static int getLocalExtrasVersion(int objectOrdinal)
|
|
669 | 669 |
{ |
670 | 670 |
RubikObject object = getObject(objectOrdinal); |
671 |
return object!=null ? object.getExtrasMinor() : -1;
|
|
671 |
return object!=null ? object.getExtrasVersion() : -1;
|
|
672 | 672 |
} |
673 | 673 |
} |
Also available in: Unified diff
Remove the generic 'MINOR' object and extras versions from JsonWriter, and replace them with per-ObjectType values. This was the reason why objects which had their 'minor' (really: version) updated to '1' in the server then never updated the jsons with locally stored versions.