Skip to content

Commit

Permalink
bugfix: User notified and cannot proceed when asset extraction fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
littleguy77 committed Jan 21, 2013
1 parent d019572 commit b50ea80
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
1 change: 1 addition & 0 deletions res/values/strings-no-translate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<string name="actionHelp_uriBug" translatable="false">http://github.com/paulscode/mupen64plus-ae/issues</string>
<string name="actionAbout_uriCredits" translatable="false">http://www.paulscode.com/forum/index.php?topic=836.msg7873#msg7873</string>
<string name="actionAbout_uriChangelog" translatable="false">http://www.paulscode.com/forum/index.php?topic=96.msg2243#msg2243</string>
<string name="assetExtractor_help" translatable="false">tinyurl.com/bfbb4jc</string>

<!-- Encoded values -->
<string name="inputMap_defaultOn" translatable="false">true/0:22,0:-31,1:21,1:-32,2:20,2:-33,3:19,3:-34,4:108,6:99,7:96,7:23,12:103,13:102,16:-1,17:-2,18:-3,19:-4</string>
Expand Down
1 change: 1 addition & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@
<string name="assetExtractor_initializing">Initializing</string>
<string name="assetExtractor_progress">%1$.0f%% done: %2$s</string>
<string name="assetExtractor_finished">Finished</string>
<string name="assetExtractor_failed">Error extracting app data.\nPlease unplug USB cable, reboot device, and re-launch app.\nFor help, please visit %1$s.</string>

<!-- Cheats Configuration -->
<string name="cheats_titleFor">Cheats for %1$s</string>
Expand Down
28 changes: 19 additions & 9 deletions src/paulscode/android/mupen64plusae/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,34 @@ public void run()
{
// This runs on non-UI thread and ensures that the app is responsive during the lengthy
// extraction process
boolean success = true;

// Extract the assets if they are out of date
if( mAppData.getAssetVersion() != ASSET_VERSION )
{
FileUtil.deleteFolder( new File( mAppData.dataDir ) );
mAssetsExtracted = 0;
AssetExtractor.extractAssets( getAssets(), SOURCE_DIR, mAppData.dataDir,
success = AssetExtractor.extractAssets( getAssets(), SOURCE_DIR, mAppData.dataDir,
MainActivity.this );
mAppData.putAssetVersion( ASSET_VERSION );
}

updateText( R.string.assetExtractor_finished );

// Launch the MenuActivity
startActivity( new Intent( MainActivity.this, MenuActivity.class ) );

// We never want to come back to this activity, so finish it
finish();
// Launch menu activity if successful; post failure notice otherwise
if( success )
{
mAppData.putAssetVersion( ASSET_VERSION );
updateText( R.string.assetExtractor_finished );

// Launch the MenuActivity
startActivity( new Intent( MainActivity.this, MenuActivity.class ) );

// We never want to come back to this activity, so finish it
finish();
}
else
{
String weblink = getResources().getString( R.string.assetExtractor_help );
updateText( R.string.assetExtractor_failed, weblink );
}
}
};

Expand Down
7 changes: 6 additions & 1 deletion src/paulscode/android/mupen64plusae/util/AssetExtractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ public interface OnExtractionProgressListener
public void onExtractionProgress( String nextFileExtracted );
}

public static void extractAssets( AssetManager assetManager, String srcPath, String dstPath,
public static boolean extractAssets( AssetManager assetManager, String srcPath, String dstPath,
OnExtractionProgressListener onProgress )
{
boolean result = true;

if( srcPath.startsWith( "/" ) )
srcPath = srcPath.substring( 1 );

Expand Down Expand Up @@ -89,8 +91,11 @@ public static void extractAssets( AssetManager assetManager, String srcPath, Str
catch( IOException e )
{
Log.w( "AssetExtractor", "Failed to extract asset file: " + srcPath );
result = false;
}
}

return result;
}

public static int countAssets( AssetManager assetManager, String srcPath )
Expand Down

0 comments on commit b50ea80

Please sign in to comment.