Permalink
Browse files

Front: Added prompt on exit

  • Loading branch information...
Gillou68310 committed Oct 16, 2015
1 parent 756a840 commit 293ca58f5a122e7aec3627ad7fde06c606ad7bf0
View
@@ -418,6 +418,7 @@
<!-- Confirmation Dialogs -->
<string name="confirm_title">Confirmation</string>
<string name="confirmResetGame_message">Reset game? All progress since your last save will be lost.</string>
+ <string name="confirmExitGame_message">Exit game? All progress since your last save will be lost.</string>

This comment has been minimized.

Show comment
Hide comment
@fzurita

fzurita Oct 16, 2015

Member

This may not be accurate, it doesn't look like we got rid of the auto save functionality on exit.

@fzurita

fzurita Oct 16, 2015

Member

This may not be accurate, it doesn't look like we got rid of the auto save functionality on exit.

This comment has been minimized.

Show comment
Hide comment
@Gillou68310

Gillou68310 Oct 16, 2015

Contributor

You're right I picked up this commit from on old branch which obviously had autosave disabled.

@Gillou68310

Gillou68310 Oct 16, 2015

Contributor

You're right I picked up this commit from on old branch which obviously had autosave disabled.

<string name="confirmOverwriteFile_message">Overwrite %1$s?</string>
<string name="confirmUnmapAll_message">Unmap all inputs for %1$s?</string>
<string name="confirmDeleteProfile_message">Delete profile \"%1$s\"?</string>
@@ -52,6 +52,7 @@
import paulscode.android.mupen64plusae.util.RomDatabase.RomDetail;
import android.annotation.TargetApi;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
@@ -498,13 +499,16 @@ public void onAction()
new PromptConfirmListener()
{
@Override
- public void onConfirm()
+ public void onDialogClosed( int which )
{
- launchGameActivity( finalItem.romFile.getAbsolutePath(),
- finalItem.zipFile == null ? null : finalItem.zipFile.getAbsolutePath(),
- finalItem.isExtracted, finalItem.md5, finalItem.crc,
- finalItem.headerName, finalItem.countryCode, finalItem.artPath,
- finalItem.goodName, true );
+ if( which == DialogInterface.BUTTON_POSITIVE )
+ {
+ launchGameActivity( finalItem.romFile.getAbsolutePath(),
+ finalItem.zipFile == null ? null : finalItem.zipFile.getAbsolutePath(),
+ finalItem.isExtracted, finalItem.md5, finalItem.crc,
+ finalItem.headerName, finalItem.countryCode, finalItem.artPath,
+ finalItem.goodName, true );
+ }
}
} );
}
@@ -92,7 +92,7 @@ public void onPopulateListItem( T item, int position, TextView text1, TextView t
/**
* Handle the user's confirmation.
*/
- public void onConfirm();
+ public void onDialogClosed( int which );
}
/**
@@ -291,8 +291,7 @@ public static void promptConfirm( Context context, CharSequence title, CharSeque
@Override
public void onClick( DialogInterface dialog, int which )
{
- if( which == DialogInterface.BUTTON_POSITIVE )
- listener.onConfirm();
+ listener.onDialogClosed(which);
}
};
@@ -302,7 +302,7 @@ protected void updateSidebar()
@Override
public void onAction()
{
- mActivity.finish();
+ CoreInterface.exit();
}
});
@@ -653,7 +653,7 @@ else if( keyDown && keyCode == KeyEvent.KEYCODE_BACK )
if( mDrawerLayout.isDrawerOpen( GravityCompat.START ) )
mDrawerLayout.closeDrawer( GravityCompat.START );
else
- mActivity.finish();
+ CoreInterface.exit();
return true;
}
@@ -290,7 +290,7 @@ public void onOptionsItemSelected( MenuItem item )
setIme();
break;
case R.id.menuItem_exit:
- mActivity.finish();
+ CoreInterface.exit();
break;
default:
break;
@@ -462,10 +462,13 @@ public static void saveState( final String filename )
Prompt.promptConfirm( sActivity, title, message, new PromptConfirmListener()
{
@Override
- public void onConfirm()
+ public void onDialogClosed( int which )
{
- Notifier.showToast( sActivity, R.string.toast_overwritingFile, file.getName() );
- NativeExports.emuSaveFile( file.getAbsolutePath() );
+ if( which == DialogInterface.BUTTON_POSITIVE )
+ {
+ Notifier.showToast( sActivity, R.string.toast_overwritingFile, file.getName() );
+ NativeExports.emuSaveFile( file.getAbsolutePath() );
+ }
}
} );
}
@@ -542,4 +545,22 @@ public static void advanceFrame()
NativeExports.emuPause();
NativeExports.emuAdvanceFrame();
}
+
+ public static void exit()
+ {
+ NativeExports.emuPause();
+ String title = sActivity.getString( R.string.confirm_title );
+ String message = sActivity.getString( R.string.confirmExitGame_message );
+ Prompt.promptConfirm( sActivity, title, message, new PromptConfirmListener()
+ {
+ @Override
+ public void onDialogClosed( int which )
+ {
+ if( which == DialogInterface.BUTTON_POSITIVE )
+ sActivity.finish();
+ else
+ NativeExports.emuResume();
+ }
+ } );
+ }
}
@@ -41,6 +41,7 @@
import paulscode.android.mupen64plusae.util.RomDatabase;
import paulscode.android.mupen64plusae.util.RomDatabase.RomDetail;
import paulscode.android.mupen64plusae.util.RomHeader;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
@@ -377,20 +378,23 @@ private void actionResetGamePrefs()
Prompt.promptConfirm( this, title, message, new PromptConfirmListener()
{
@Override
- public void onConfirm()
+ public void onDialogClosed( int which )
{
- // Reset the user preferences
- mPrefs.unregisterOnSharedPreferenceChangeListener( GamePrefsActivity.this );
- mPrefs.edit().clear().commit();
- PreferenceManager.setDefaultValues( GamePrefsActivity.this, R.xml.preferences_game, true );
+ if( which == DialogInterface.BUTTON_POSITIVE )
+ {
+ // Reset the user preferences
+ mPrefs.unregisterOnSharedPreferenceChangeListener( GamePrefsActivity.this );
+ mPrefs.edit().clear().commit();
+ PreferenceManager.setDefaultValues( GamePrefsActivity.this, R.xml.preferences_game, true );
- // Also reset any manual overrides the user may have made in the config file
- File configFile = new File( mGamePrefs.mupen64plus_cfg );
- if( configFile.exists() )
- configFile.delete();
+ // Also reset any manual overrides the user may have made in the config file
+ File configFile = new File( mGamePrefs.mupen64plus_cfg );
+ if( configFile.exists() )
+ configFile.delete();
- // Rebuild the menu system by restarting the activity
- ActivityHelper.restartActivity( GamePrefsActivity.this );
+ // Rebuild the menu system by restarting the activity
+ ActivityHelper.restartActivity( GamePrefsActivity.this );
+ }
}
} );
}
@@ -28,6 +28,7 @@
import paulscode.android.mupen64plusae.dialog.Prompt.PromptConfirmListener;
import paulscode.android.mupen64plusae.preference.PrefUtil;
import android.annotation.TargetApi;
+import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
@@ -214,15 +215,18 @@ private void actionResetUserPrefs()
Prompt.promptConfirm( this, title, message, new PromptConfirmListener()
{
@Override
- public void onConfirm()
+ public void onDialogClosed( int which )
{
- // Reset the user preferences
- mPrefs.unregisterOnSharedPreferenceChangeListener( GlobalPrefsActivity.this );
- mPrefs.edit().clear().commit();
- PreferenceManager.setDefaultValues( GlobalPrefsActivity.this, R.xml.preferences_global, true );
+ if( which == DialogInterface.BUTTON_POSITIVE )
+ {
+ // Reset the user preferences
+ mPrefs.unregisterOnSharedPreferenceChangeListener( GlobalPrefsActivity.this );
+ mPrefs.edit().clear().commit();
+ PreferenceManager.setDefaultValues( GlobalPrefsActivity.this, R.xml.preferences_global, true );
- // Rebuild the menu system by restarting the activity
- ActivityHelper.restartActivity( GlobalPrefsActivity.this );
+ // Rebuild the menu system by restarting the activity
+ ActivityHelper.restartActivity( GlobalPrefsActivity.this );
+ }
}
} );
}
@@ -315,10 +315,13 @@ private void unmapAll()
Prompt.promptConfirm( this, title, message, new PromptConfirmListener()
{
@Override
- public void onConfirm()
+ public void onDialogClosed( int which )
{
- mProfile.putMap( new InputMap() );
- refreshAllButtons();
+ if( which == DialogInterface.BUTTON_POSITIVE )
+ {
+ mProfile.putMap( new InputMap() );
+ refreshAllButtons();
+ }
}
} );
}
@@ -324,19 +324,22 @@ private void deleteProfile( final Profile profile, final boolean isDefault )
Prompt.promptConfirm( this, title, message, new PromptConfirmListener()
{
@Override
- public void onConfirm()
+ public void onDialogClosed( int which )
{
- assert ( mConfigCustom.keySet().contains( profile.name ) );
-
- //If this was the default profile, pick another default profile
- if(isDefault)
+ if( which == DialogInterface.BUTTON_POSITIVE )
{
- putDefaultProfile(getNoDefaultProfile());
+ assert ( mConfigCustom.keySet().contains( profile.name ) );
+
+ //If this was the default profile, pick another default profile
+ if(isDefault)
+ {
+ putDefaultProfile(getNoDefaultProfile());
+ }
+
+ mConfigCustom.remove( profile.name );
+ mConfigCustom.save();
+ refreshList();
}
-
- mConfigCustom.remove( profile.name );
- mConfigCustom.save();
- refreshList();
}
} );
}

0 comments on commit 293ca58

Please sign in to comment.