Revision 81493402
Added by Leszek Koltunski over 3 years ago
| src/main/java/org/distorted/bandaged/BandagedCreatorActivity.java | ||
|---|---|---|
| 34 | 34 |
import com.google.firebase.analytics.FirebaseAnalytics; |
| 35 | 35 |
|
| 36 | 36 |
import org.distorted.dialogs.RubikDialogError; |
| 37 |
import org.distorted.external.RubikFiles; |
|
| 37 | 38 |
import org.distorted.library.main.DistortedLibrary; |
| 38 | 39 |
import org.distorted.main.R; |
| 39 | 40 |
import org.distorted.main.RubikActivity; |
| ... | ... | |
| 266 | 267 |
public void deleteObject(String name) |
| 267 | 268 |
{
|
| 268 | 269 |
mScreen.deleteObject(this,name); |
| 270 |
|
|
| 271 |
RubikFiles files = RubikFiles.getInstance(); |
|
| 272 |
files.deleteIcon(this,name); |
|
| 273 |
files.deleteJsonObject(this,name); |
|
| 269 | 274 |
} |
| 270 | 275 |
|
| 271 | 276 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java | ||
|---|---|---|
| 222 | 222 |
|
| 223 | 223 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "1");
|
| 224 | 224 |
|
| 225 |
RubikObjectList.addDownloadedObject(mInfo.mObjectShortName,mInfo.mNumScrambles, mInfo.mObjectMinorVersion, |
|
| 225 |
Activity act = mAct.get(); |
|
| 226 |
RubikObjectList.addDownloadedObject(act, mInfo.mObjectShortName,mInfo.mNumScrambles, mInfo.mObjectMinorVersion, |
|
| 226 | 227 |
mInfo.mExtrasMinorVersion, mIconSaved, oSuccess, eSuccess); |
| 227 | 228 |
|
| 228 | 229 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "2");
|
| src/main/java/org/distorted/external/RubikFiles.java | ||
|---|---|---|
| 133 | 133 |
return false; |
| 134 | 134 |
} |
| 135 | 135 |
} |
| 136 |
|
|
| 137 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 138 |
|
|
| 139 |
public void deleteIcon(Context context, String name) |
|
| 140 |
{
|
|
| 141 |
String filename = name.toLowerCase() + ".png"; |
|
| 142 |
boolean success = context.deleteFile(filename); |
|
| 143 |
if( !success ) android.util.Log.e("D", "failed to delete "+filename);
|
|
| 144 |
else android.util.Log.e("D", "successfully deleted "+filename);
|
|
| 145 |
} |
|
| 146 |
|
|
| 147 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 148 |
|
|
| 149 |
public void deleteJsonObject(Context context, String name) |
|
| 150 |
{
|
|
| 151 |
String filename = name.toLowerCase() + "_object.json"; |
|
| 152 |
boolean success = context.deleteFile(filename); |
|
| 153 |
if( !success ) android.util.Log.e("D", "failed to delete "+filename);
|
|
| 154 |
else android.util.Log.e("D", "successfully deleted "+filename);
|
|
| 155 |
} |
|
| 156 |
|
|
| 157 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 158 |
|
|
| 159 |
public void deleteJsonExtras(Context context, String name) |
|
| 160 |
{
|
|
| 161 |
String filename = name.toLowerCase() + "_extras.json"; |
|
| 162 |
boolean success = context.deleteFile(filename); |
|
| 163 |
if( !success ) android.util.Log.e("D", "failed to delete "+filename);
|
|
| 164 |
else android.util.Log.e("D", "successfully deleted "+filename);
|
|
| 165 |
} |
|
| 136 | 166 |
} |
| src/main/java/org/distorted/main/RubikActivity.java | ||
|---|---|---|
| 329 | 329 |
mPolicyAccepted = preferences.getBoolean("policyAccepted", false);
|
| 330 | 330 |
String oldVersion = preferences.getString("appVersion","");
|
| 331 | 331 |
|
| 332 |
RubikObjectList.restorePreferences(preferences); |
|
| 332 |
RubikObjectList.restorePreferences(this,preferences);
|
|
| 333 | 333 |
|
| 334 | 334 |
for (int i=0; i< BaseEffect.Type.LENGTH; i++) |
| 335 | 335 |
{
|
| src/main/java/org/distorted/objects/RubikObjectList.java | ||
|---|---|---|
| 21 | 21 |
|
| 22 | 22 |
import java.util.ArrayList; |
| 23 | 23 |
|
| 24 |
import android.content.Context; |
|
| 24 | 25 |
import android.content.SharedPreferences; |
| 25 | 26 |
|
| 27 |
import org.distorted.external.RubikFiles; |
|
| 26 | 28 |
import org.distorted.main.RubikActivity; |
| 27 | 29 |
import org.distorted.objectlib.main.ObjectSignatures; |
| 28 | 30 |
import org.distorted.objectlib.main.ObjectType; |
| ... | ... | |
| 196 | 198 |
|
| 197 | 199 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 198 | 200 |
|
| 199 |
public static void addDownloadedObject(String shortName, int numScrambles, int objectMinor, int extrasMinor,
|
|
| 200 |
boolean icon, boolean object, boolean extras) |
|
| 201 |
public static void addDownloadedObject(Context context, String shortName, int numScrambles, int objectMinor,
|
|
| 202 |
int extrasMinor, boolean icon, boolean object, boolean extras)
|
|
| 201 | 203 |
{
|
| 202 | 204 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "New downloaded object "+shortName+" icon="+icon+" object="+object+" extras="+extras);
|
| 203 | 205 |
|
| ... | ... | |
| 230 | 232 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Adding new downloaded object "+shortName+" icon="+obj.icon+" object="+obj.object+" extras="+obj.extras);
|
| 231 | 233 |
mDownloadedObjects.add(obj); |
| 232 | 234 |
} |
| 235 |
else |
|
| 236 |
{
|
|
| 237 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "New downloaded object "+shortName+" is already built-in, deleting");
|
|
| 238 |
|
|
| 239 |
RubikFiles files = RubikFiles.getInstance(); |
|
| 240 |
files.deleteIcon(context,shortName); |
|
| 241 |
files.deleteJsonObject(context,shortName); |
|
| 242 |
files.deleteJsonExtras(context,shortName); |
|
| 243 |
} |
|
| 233 | 244 |
} |
| 234 | 245 |
|
| 235 | 246 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 304 | 315 |
|
| 305 | 316 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 306 | 317 |
|
| 307 |
public static void restorePreferences(SharedPreferences preferences) |
|
| 318 |
public static void restorePreferences(Context context, SharedPreferences preferences)
|
|
| 308 | 319 |
{
|
| 309 | 320 |
if( mThis==null ) mThis = new RubikObjectList(); |
| 310 | 321 |
|
| ... | ... | |
| 338 | 349 |
boolean bObje = obje.equals("1");
|
| 339 | 350 |
boolean bExtr = extr.equals("1");
|
| 340 | 351 |
|
| 341 |
addDownloadedObject(name,scrambles,oMinor,eMinor,bIcon,bObje,bExtr); |
|
| 352 |
addDownloadedObject(context,name,scrambles,oMinor,eMinor,bIcon,bObje,bExtr);
|
|
| 342 | 353 |
} |
| 343 | 354 |
} |
| 344 | 355 |
} |
Also available in: Unified diff
delete icon, object and extras files from local storage when:
1) we delete a locally produced bandaged 3x3
2) it turns out that a downloaded object is already built-in (which can happen if we download an object and then upgrade to app version which builts it in)