Skip to content
Permalink
Browse files
front: Move intent extras keys inside ActivityHelper.
  • Loading branch information
littleguy77 committed May 2, 2015
1 parent a93482d commit 5d1165f
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 92 deletions.
@@ -43,6 +43,25 @@
*/
public class ActivityHelper
{
/**
* Keys used to pass data to activities via the intent extras bundle. It's good practice to
* namespace the keys to avoid conflicts with other apps. By convention this is usually the
* package name but it's not a strict requirement. We'll use the fully qualified name of this
* class since it's easy to get.
*/
public static class Keys
{
private static final String NAMESPACE = Keys.class.getCanonicalName() + ".";
//@formatter:off
public static final String ROM_PATH = NAMESPACE + "ROM_PATH";
public static final String ROM_MD5 = NAMESPACE + "ROM_MD5";
public static final String CHEAT_ARGS = NAMESPACE + "CHEAT_ARGS";
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";
//@formatter:on
}

public static void launchUri( Context context, int resId )
{
launchUri( context, context.getString( resId ) );
@@ -91,7 +110,7 @@ public static void startGalleryActivity( Context context, String romPath )
{
Intent intent = new Intent( context, GalleryActivity.class );
if( !TextUtils.isEmpty( romPath ) )
intent.putExtra( Keys.Extras.ROM_PATH, romPath );
intent.putExtra( ActivityHelper.Keys.ROM_PATH, romPath );
context.startActivity( intent );
}

@@ -101,10 +120,10 @@ public static void startGameActivity( Context context, String romPath, String ro
Intent intent = isXperiaPlay
? new Intent( context, GameActivityXperiaPlay.class )
: new Intent( context, GameActivity.class );
intent.putExtra( Keys.Extras.ROM_PATH, romPath );
intent.putExtra( Keys.Extras.ROM_MD5, romMd5 );
intent.putExtra( Keys.Extras.CHEAT_ARGS, cheatArgs );
intent.putExtra( Keys.Extras.DO_RESTART, doRestart );
intent.putExtra( ActivityHelper.Keys.ROM_PATH, romPath );
intent.putExtra( ActivityHelper.Keys.ROM_MD5, romMd5 );
intent.putExtra( ActivityHelper.Keys.CHEAT_ARGS, cheatArgs );
intent.putExtra( ActivityHelper.Keys.DO_RESTART, doRestart );
context.startActivity( intent );
}

@@ -116,15 +135,15 @@ public static void startGlobalPrefsActivity( Context context )
public static void startGlobalPrefsActivity( Context context, int menuDisplayMode )
{
Intent intent = new Intent( context, GlobalPrefsActivity.class );
intent.putExtra( Keys.Extras.MENU_DISPLAY_MODE, menuDisplayMode );
intent.putExtra( ActivityHelper.Keys.MENU_DISPLAY_MODE, menuDisplayMode );
context.startActivity( intent );
}

public static void startGamePrefsActivity( Context context, String romPath, String romMd5 )
{
Intent intent = new Intent( context, GamePrefsActivity.class );
intent.putExtra( Keys.Extras.ROM_PATH, romPath );
intent.putExtra( Keys.Extras.ROM_MD5, romMd5 );
intent.putExtra( ActivityHelper.Keys.ROM_PATH, romPath );
intent.putExtra( ActivityHelper.Keys.ROM_MD5, romMd5 );
context.startActivity( intent );
}

@@ -146,21 +165,21 @@ public static void startManageControllerProfilesActivity( Context context )
public static void startEmulationProfileActivity( Context context, String profileName )
{
Intent intent = new Intent( context, EmulationProfileActivity.class );
intent.putExtra( Keys.Extras.PROFILE_NAME, profileName );
intent.putExtra( ActivityHelper.Keys.PROFILE_NAME, profileName );
context.startActivity( intent );
}

public static void startTouchscreenProfileActivity( Context context, String profileName )
{
Intent intent = new Intent( context, TouchscreenProfileActivity.class );
intent.putExtra( Keys.Extras.PROFILE_NAME, profileName );
intent.putExtra( ActivityHelper.Keys.PROFILE_NAME, profileName );
context.startActivity( intent );
}

public static void startControllerProfileActivity( Context context, String profileName )
{
Intent intent = new Intent( context, ControllerProfileActivity.class );
intent.putExtra( Keys.Extras.PROFILE_NAME, profileName );
intent.putExtra( ActivityHelper.Keys.PROFILE_NAME, profileName );
context.startActivity( intent );
}

@@ -155,7 +155,7 @@ protected void onCreate( Bundle savedInstanceState )
Bundle extras = getIntent().getExtras();
if( extras != null )
{
String givenRomPath = extras.getString( Keys.Extras.ROM_PATH );
String givenRomPath = extras.getString( ActivityHelper.Keys.ROM_PATH );
if( !TextUtils.isEmpty( givenRomPath ) )
launchPlayMenuActivity( givenRomPath );
}

This file was deleted.

@@ -27,7 +27,7 @@

import org.mupen64plusae.v3.alpha.R;

import paulscode.android.mupen64plusae.Keys;
import paulscode.android.mupen64plusae.ActivityHelper;
import paulscode.android.mupen64plusae.cheat.CheatUtils.Cheat;
import paulscode.android.mupen64plusae.dialog.Prompt;
import paulscode.android.mupen64plusae.dialog.Prompt.PromptTextListener;
@@ -111,7 +111,7 @@ protected void onCreate( Bundle savedInstanceState )
Bundle extras = getIntent().getExtras();
if( extras == null )
throw new Error( "ROM path must be passed via the extras bundle when starting CheatEditorActivity" );
String romPath = extras.getString( Keys.Extras.ROM_PATH );
String romPath = extras.getString( ActivityHelper.Keys.ROM_PATH );
if( TextUtils.isEmpty( romPath ) )
throw new Error( "ROM path must be passed via the extras bundle when starting CheatEditorActivity" );
mRomHeader = new RomHeader( new File( romPath ) );
@@ -24,7 +24,7 @@

import org.mupen64plusae.v3.alpha.R;

import paulscode.android.mupen64plusae.Keys;
import paulscode.android.mupen64plusae.ActivityHelper;
import paulscode.android.mupen64plusae.hack.MogaHack;
import paulscode.android.mupen64plusae.input.AbstractController;
import paulscode.android.mupen64plusae.input.PeripheralController;
@@ -147,10 +147,10 @@ public GameLifecycleHandler( Activity activity )
Bundle extras = mActivity.getIntent().getExtras();
if( extras == null )
throw new Error( "ROM path and MD5 must be passed via the extras bundle when starting GameActivity" );
mRomPath = extras.getString( Keys.Extras.ROM_PATH );
mRomMd5 = extras.getString( Keys.Extras.ROM_MD5 );
mCheatArgs = extras.getString( Keys.Extras.CHEAT_ARGS );
mDoRestart = extras.getBoolean( Keys.Extras.DO_RESTART, false );
mRomPath = extras.getString( ActivityHelper.Keys.ROM_PATH );
mRomMd5 = extras.getString( ActivityHelper.Keys.ROM_MD5 );
mCheatArgs = extras.getString( ActivityHelper.Keys.CHEAT_ARGS );
mDoRestart = extras.getBoolean( ActivityHelper.Keys.DO_RESTART, false );
if( TextUtils.isEmpty( mRomPath ) || TextUtils.isEmpty( mRomMd5 ) )
throw new Error( "ROM path and MD5 must be passed via the extras bundle when starting GameActivity" );
}
@@ -22,7 +22,7 @@

import org.mupen64plusae.v3.alpha.R;

import paulscode.android.mupen64plusae.Keys;
import paulscode.android.mupen64plusae.ActivityHelper;
import paulscode.android.mupen64plusae.jni.CoreInterface;
import paulscode.android.mupen64plusae.jni.CoreInterface.OnStateCallbackListener;
import paulscode.android.mupen64plusae.jni.NativeConstants;
@@ -60,8 +60,8 @@ public GameMenuHandler( Activity activity )
Bundle extras = mActivity.getIntent().getExtras();
if( extras == null )
throw new Error( "ROM path and MD5 must be passed via the extras bundle when starting GameActivity" );
String romPath = extras.getString( Keys.Extras.ROM_PATH );
mRomMd5 = extras.getString( Keys.Extras.ROM_MD5 );
String romPath = extras.getString( ActivityHelper.Keys.ROM_PATH );
mRomMd5 = extras.getString( ActivityHelper.Keys.ROM_MD5 );
if( TextUtils.isEmpty( romPath ) || TextUtils.isEmpty( mRomMd5 ) )
throw new Error( "ROM path and MD5 must be passed via the extras bundle when starting GameActivity" );
mRomHeader = new RomHeader( romPath );
@@ -27,7 +27,6 @@
import org.mupen64plusae.v3.alpha.R;

import paulscode.android.mupen64plusae.ActivityHelper;
import paulscode.android.mupen64plusae.Keys;
import paulscode.android.mupen64plusae.cheat.CheatEditorActivity;
import paulscode.android.mupen64plusae.cheat.CheatFile;
import paulscode.android.mupen64plusae.cheat.CheatFile.CheatSection;
@@ -122,8 +121,8 @@ protected void onCreate( Bundle savedInstanceState )
Bundle extras = getIntent().getExtras();
if( extras == null )
throw new Error( "ROM path and MD5 must be passed via the extras bundle" );
mRomPath = extras.getString( Keys.Extras.ROM_PATH );
mRomMd5 = extras.getString( Keys.Extras.ROM_MD5 );
mRomPath = extras.getString( ActivityHelper.Keys.ROM_PATH );
mRomMd5 = extras.getString( ActivityHelper.Keys.ROM_MD5 );
if( TextUtils.isEmpty( mRomPath ) || TextUtils.isEmpty( mRomMd5 ) )
throw new Error( "ROM path and MD5 must be passed via the extras bundle" );

@@ -330,7 +329,7 @@ public boolean onPreferenceClick( Preference preference )
if( key.equals( ACTION_CHEAT_EDITOR ) )
{
Intent intent = new Intent( this, CheatEditorActivity.class );
intent.putExtra( Keys.Extras.ROM_PATH, mRomPath );
intent.putExtra( ActivityHelper.Keys.ROM_PATH, mRomPath );
startActivityForResult( intent, 111 );
}
else if( key.equals( ACTION_WIKI ) )
@@ -23,7 +23,6 @@
import org.mupen64plusae.v3.alpha.R;

import paulscode.android.mupen64plusae.ActivityHelper;
import paulscode.android.mupen64plusae.Keys;
import paulscode.android.mupen64plusae.dialog.Prompt;
import paulscode.android.mupen64plusae.dialog.Prompt.PromptConfirmListener;
import paulscode.android.mupen64plusae.preference.PrefUtil;
@@ -111,7 +110,7 @@ protected void onCreate( Bundle savedInstanceState )
Bundle extras = getIntent().getExtras();
if( extras != null )
{
int mode = extras.getInt( Keys.Extras.MENU_DISPLAY_MODE, 0 );
int mode = extras.getInt( ActivityHelper.Keys.MENU_DISPLAY_MODE, 0 );
if( mode == 1 )
{
// Remove distractions if this was launched from TouchscreenProfileActivity
@@ -25,7 +25,7 @@

import org.mupen64plusae.v3.alpha.R;

import paulscode.android.mupen64plusae.Keys;
import paulscode.android.mupen64plusae.ActivityHelper;
import paulscode.android.mupen64plusae.dialog.Prompt;
import paulscode.android.mupen64plusae.dialog.Prompt.ListItemTwoTextIconPopulator;
import paulscode.android.mupen64plusae.dialog.Prompt.PromptConfirmListener;
@@ -133,7 +133,7 @@ public void onCreate( Bundle savedInstanceState )
Bundle extras = getIntent().getExtras();
if( extras == null )
throw new Error( "Invalid usage: bundle must indicate profile name" );
String name = extras.getString( Keys.Extras.PROFILE_NAME );
String name = extras.getString( ActivityHelper.Keys.PROFILE_NAME );
if( TextUtils.isEmpty( name ) )
throw new Error( "Invalid usage: profile name cannot be null or empty" );
mConfigFile = new ConfigFile( mGlobalPrefs.controllerProfiles_cfg );
@@ -20,7 +20,7 @@
*/
package paulscode.android.mupen64plusae.profile;

import paulscode.android.mupen64plusae.Keys;
import paulscode.android.mupen64plusae.ActivityHelper;
import paulscode.android.mupen64plusae.persistent.ConfigFile;
import paulscode.android.mupen64plusae.persistent.ConfigFile.ConfigSection;
import paulscode.android.mupen64plusae.persistent.GlobalPrefs;
@@ -117,7 +117,7 @@ protected void onCreate( Bundle savedInstanceState )
Bundle extras = getIntent().getExtras();
if( extras == null )
throw new Error( "Invalid usage: bundle must indicate profile name" );
mProfileName = extras.getString( Keys.Extras.PROFILE_NAME );
mProfileName = extras.getString( ActivityHelper.Keys.PROFILE_NAME );
if( TextUtils.isEmpty( mProfileName ) )
throw new Error( "Invalid usage: profile name cannot be null or empty" );

@@ -24,7 +24,6 @@
import org.mupen64plusae.v3.alpha.R;

import paulscode.android.mupen64plusae.ActivityHelper;
import paulscode.android.mupen64plusae.Keys;
import paulscode.android.mupen64plusae.dialog.SeekBarGroup;
import paulscode.android.mupen64plusae.game.GameOverlay;
import paulscode.android.mupen64plusae.input.AbstractController;
@@ -127,7 +126,7 @@ protected void onCreate( Bundle savedInstanceState )
Bundle extras = getIntent().getExtras();
if( extras == null )
throw new Error( "Invalid usage: bundle must indicate profile name" );
String name = extras.getString( Keys.Extras.PROFILE_NAME );
String name = extras.getString( ActivityHelper.Keys.PROFILE_NAME );
if( TextUtils.isEmpty( name ) )
throw new Error( "Invalid usage: profile name cannot be null or empty" );
mConfigFile = new ConfigFile( mGlobalPrefs.touchscreenProfiles_cfg );

0 comments on commit 5d1165f

Please sign in to comment.