Skip to content
Permalink
Browse files

Merge pull request #477 from fzurita/fzurita_sidebar_integration

In-game sidebar re-integration
  • Loading branch information
xperia64 committed Oct 5, 2015
2 parents 86a8241 + 107ea48 commit 74c393440d4c1b31c45e156588a28feaedf35888
@@ -1,21 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
<paulscode.android.mupen64plusae.game.GameDrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
android:id="@+id/drawerLayout"
android:fitsSystemWindows="true" >

<paulscode.android.mupen64plusae.game.GameSurface
android:id="@+id/gameSurface"
<!-- activity view -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="false"
android:focusableInTouchMode="false" />
android:orientation="vertical" >

<paulscode.android.mupen64plusae.game.GameOverlay
android:id="@+id/gameOverlay"
android:layout_width="match_parent"
<paulscode.android.mupen64plusae.game.GameSurface
android:id="@+id/gameSurface"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="false"
android:focusableInTouchMode="false" />

<paulscode.android.mupen64plusae.game.GameOverlay
android:id="@+id/gameOverlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true" />

</FrameLayout>

<!-- navigation drawer -->
<RelativeLayout
android:layout_gravity="start"
android:layout_width="280dip"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true" />
android:fitsSystemWindows="true" >

<paulscode.android.mupen64plusae.GameSidebar
android:id="@+id/gameSidebar"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>

</merge>
</paulscode.android.mupen64plusae.game.GameDrawerLayout>
@@ -37,7 +37,7 @@
<string name="menuItem_enableFramelimiter">Sync audio</string>
<string name="menuItem_disableFramelimiter">Desync audio</string>
<string name="menuItem_paks">Controller Paks</string> <!-- capitalize since trademark -->
<string name="menuItem_pak1_empty">Player 1: Empty</string>
<string name="menuItem_pak1_empty">Player 1: Empty</string> <!-- capitalize since trademark -->
<string name="menuItem_pak1_mem">Player 1: Memory Pak</string> <!-- capitalize since trademark -->
<string name="menuItem_pak1_rumble">Player 1: Rumble Pak</string> <!-- capitalize since trademark -->
<string name="menuItem_pak2_empty">Player 2: Empty</string>
@@ -60,6 +60,8 @@
public static final String ROM_CRC = NAMESPACE + "ROM_CRC";
public static final String ROM_HEADER_NAME = NAMESPACE + "ROM_HEADER_NAME";
public static final String ROM_COUNTRY_CODE = NAMESPACE + "ROM_COUNTRY_CODE";
public static final String ROM_GOOD_NAME = NAMESPACE + "ROM_GOOD_NAME";
public static final String ROM_ART_PATH = NAMESPACE + "ROM_ART_PATH";
public static final String DO_RESTART = NAMESPACE + "DO_RESTART";
public static final String PROFILE_NAME = NAMESPACE + "PROFILE_NAME";
public static final String MENU_DISPLAY_MODE = NAMESPACE + "MENU_DISPLAY_MODE";
@@ -129,7 +131,8 @@ public static void startGalleryActivity( Context context, String romPath )
}

public static void startGameActivity( Context context, String romPath, String romMd5, String romCrc,
String romHeaderName, byte romCountryCode, boolean doRestart, boolean isXperiaPlay )
String romHeaderName, byte romCountryCode, String romArtPath, String romGoodName,
boolean doRestart, boolean isXperiaPlay )
{
Intent intent = isXperiaPlay
? new Intent( context, GameActivityXperiaPlay.class )
@@ -139,6 +142,8 @@ public static void startGameActivity( Context context, String romPath, String ro
intent.putExtra( ActivityHelper.Keys.ROM_CRC, romCrc );
intent.putExtra( ActivityHelper.Keys.ROM_HEADER_NAME, romHeaderName );
intent.putExtra( ActivityHelper.Keys.ROM_COUNTRY_CODE, romCountryCode );
intent.putExtra( ActivityHelper.Keys.ROM_ART_PATH, romArtPath );
intent.putExtra( ActivityHelper.Keys.ROM_GOOD_NAME, romGoodName );
intent.putExtra( ActivityHelper.Keys.DO_RESTART, doRestart );
context.startActivity( intent );
}
@@ -21,13 +21,7 @@

package paulscode.android.mupen64plusae;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.zip.ZipEntry;

import org.mupen64plusae.v3.alpha.R;

@@ -39,7 +33,6 @@
import paulscode.android.mupen64plusae.task.CacheRomInfoService.LocalBinder;
import android.app.Activity;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.Bundle;
@@ -235,63 +228,4 @@ public boolean IsInProgress()
{
return mInProgress;
}


public static File extractRomFile( File destDir, ZipEntry zipEntry, InputStream inStream )
{
// Read the first 4 bytes of the entry
byte[] buffer = new byte[1024];
try
{
if( inStream.read( buffer, 0, 4 ) != 4 )
return null;
}
catch( IOException e )
{
Log.w( "GalleryActivity", e );
return null;
}

// This entry appears to be a valid ROM, extract it
Log.i( "CacheRomInfoFragment", "Found zip entry " + zipEntry.getName() );

String entryName = new File( zipEntry.getName() ).getName();
File extractedFile = new File( destDir, entryName );
try
{
// Open the output stream (throws exceptions)
OutputStream outStream = new FileOutputStream( extractedFile );
try
{
// Buffer the stream
outStream = new BufferedOutputStream( outStream );

// Write the first four bytes we already peeked at (throws exceptions)
outStream.write( buffer, 0, 4 );

// Read/write the remainder of the zip entry (throws exceptions)
int n;
while( ( n = inStream.read( buffer ) ) >= 0 )
{
outStream.write( buffer, 0, n );
}
return extractedFile;
}
catch( IOException e )
{
Log.w( "GalleryActivity", e );
return null;
}
finally
{
// Flush output stream and guarantee no memory leaks
outStream.close();
}
}
catch( IOException e )
{
Log.w( "GalleryActivity", e );
return null;
}
}
}
@@ -45,8 +45,11 @@
import paulscode.android.mupen64plusae.persistent.GlobalPrefs;
import paulscode.android.mupen64plusae.task.ComputeMd5Task;
import paulscode.android.mupen64plusae.task.ComputeMd5Task.ComputeMd5Listener;
import paulscode.android.mupen64plusae.util.FileUtil;
import paulscode.android.mupen64plusae.util.Notifier;
import paulscode.android.mupen64plusae.util.RomDatabase;
import paulscode.android.mupen64plusae.util.RomHeader;
import paulscode.android.mupen64plusae.util.RomDatabase.RomDetail;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
@@ -164,7 +167,11 @@ protected void onCreate( Bundle savedInstanceState )
public void onComputeMd5Finished( File file, String md5 )
{
RomHeader header = new RomHeader(file);
launchGameActivity( file.getAbsolutePath(), null, true, md5, header.crc, header.name, header.countryCode, false );

final RomDatabase database = new RomDatabase( mAppData.mupen64plus_ini );
RomDetail detail = database.lookupByMd5WithFallback( md5, file, header.crc );
launchGameActivity( file.getAbsolutePath(), null, true, md5, header.crc, header.name,
header.countryCode, null, detail.goodName, false );
}
} );
task.execute();
@@ -472,7 +479,7 @@ public void onAction()
launchGameActivity( finalItem.romFile.getAbsolutePath(),
finalItem.zipFile == null ? null : finalItem.zipFile.getAbsolutePath(),
finalItem.isExtracted, finalItem.md5, finalItem.crc, finalItem.headerName,
finalItem.countryCode, false );
finalItem.countryCode, finalItem.artPath, finalItem.goodName, false );
}
} );

@@ -492,7 +499,9 @@ public void onConfirm()
{
launchGameActivity( finalItem.romFile.getAbsolutePath(),
finalItem.zipFile == null ? null : finalItem.zipFile.getAbsolutePath(),
finalItem.isExtracted, finalItem.md5, finalItem.crc, finalItem.headerName, finalItem.countryCode, true );
finalItem.isExtracted, finalItem.md5, finalItem.crc,
finalItem.headerName, finalItem.countryCode, finalItem.artPath,
finalItem.goodName, true );
}
} );
}
@@ -536,8 +545,8 @@ public boolean onGalleryItemLongClick( GalleryItem item )
{
launchGameActivity( item.romFile.getAbsolutePath(),
item.zipFile == null ? null : item.zipFile.getAbsolutePath(),
item.isExtracted,
item.md5, item.crc, item.headerName, item.countryCode, false );
item.isExtracted, item.md5, item.crc, item.headerName, item.countryCode,
item.artPath, item.goodName, false );
return true;
}

@@ -772,7 +781,7 @@ private void refreshViews()
}

public void launchGameActivity( String romPath, String zipPath, boolean extracted, String romMd5, String romCrc,
String romGoodName, byte romCountryCode, boolean isRestarting )
String romHeaderName, byte romCountryCode, String romArtPath, String romGoodName, boolean isRestarting )
{
// Make sure that the storage is accessible
if( !mAppData.isSdCardAccessible() )
@@ -801,8 +810,8 @@ public void launchGameActivity( String romPath, String zipPath, boolean extracte
}

// Launch the game activity
ActivityHelper.startGameActivity( this, romPath, romMd5, romCrc, romGoodName, romCountryCode,
isRestarting, mGlobalPrefs.isTouchpadEnabled );
ActivityHelper.startGameActivity( this, romPath, romMd5, romCrc, romHeaderName, romCountryCode,
romArtPath, romGoodName, isRestarting, mGlobalPrefs.isTouchpadEnabled );
}

private void ExtractFileIfNeeded(String md5, ConfigFile config, String romPath, String zipPath, boolean isExtracted)
@@ -835,7 +844,7 @@ private void ExtractFileIfNeeded(String md5, ConfigFile config, String romPath,

if( !fileExisted )
{
tempRomPath = CacheRomInfoFragment.extractRomFile( destDir, zipEntry, zipStream );
tempRomPath = FileUtil.extractRomFile( destDir, zipEntry, zipStream );
}

String computedMd5 = ComputeMd5Task.computeMd5( tempRomPath );
@@ -877,4 +886,3 @@ private void ExtractFileIfNeeded(String md5, ConfigFile config, String romPath,
}
}


@@ -66,6 +66,7 @@ public void onWindowFocusChanged( boolean hasFocus )
@Override
protected void onCreate( Bundle savedInstanceState )
{
super.setTheme( android.support.v7.appcompat.R.style.Theme_AppCompat_NoActionBar );
mMenuHandler = new GameMenuHandler( this );
CoreInterface.addOnStateCallbackListener( mMenuHandler );

@@ -73,6 +73,7 @@ public void onWindowFocusChanged( boolean hasFocus )
@Override
protected void onCreate( Bundle savedInstanceState )
{
super.setTheme( android.support.v7.appcompat.R.style.Theme_AppCompat_NoActionBar );
mMenuHandler = new GameMenuHandler( this );
CoreInterface.addOnStateCallbackListener( mMenuHandler );

0 comments on commit 74c3934

Please sign in to comment.
You can’t perform that action at this time.