Suggest converting to rodir, if write test has failed
This commit is contained in:
parent
09a88e4cbc
commit
300e65e200
5 changed files with 76 additions and 52 deletions
|
@ -76,6 +76,9 @@
|
||||||
<string name="lollipop_write_fail_msg">Из-за политик записи в новых версиях Android, полноценно воспользоваться внешней памятью невозможно. </string>
|
<string name="lollipop_write_fail_msg">Из-за политик записи в новых версиях Android, полноценно воспользоваться внешней памятью невозможно. </string>
|
||||||
<string name="kitkat_write_fail_msg">Из-за политик записи Android 4.4, вы не можете воспользоваться внешней памятью. </string>
|
<string name="kitkat_write_fail_msg">Из-за политик записи Android 4.4, вы не можете воспользоваться внешней памятью. </string>
|
||||||
<string name="readonly_fs_fail_msg">Похоже, ваша файловая система в режиме только для чтения. </string>
|
<string name="readonly_fs_fail_msg">Похоже, ваша файловая система в режиме только для чтения. </string>
|
||||||
|
<string name="convert_to_rodir">Конвертировать в RoDir</string>
|
||||||
|
<string name="rodir_warning">Обратите внимание, что теперь ваши настройки будут сохранены в %s</string>
|
||||||
|
|
||||||
<!-- /Write check -->
|
<!-- /Write check -->
|
||||||
|
|
||||||
<!-- Tutorial -->
|
<!-- Tutorial -->
|
||||||
|
|
|
@ -103,6 +103,8 @@
|
||||||
<string name="lollipop_write_fail_msg">Due to writing politics of newer Android versions, you can\'t use this storage. </string>
|
<string name="lollipop_write_fail_msg">Due to writing politics of newer Android versions, you can\'t use this storage. </string>
|
||||||
<string name="kitkat_write_fail_msg">Due to writing politics of Android 4.4, you can\'t use this storage. </string>
|
<string name="kitkat_write_fail_msg">Due to writing politics of Android 4.4, you can\'t use this storage. </string>
|
||||||
<string name="readonly_fs_fail_msg">Seems you have read-only filesystem. </string>
|
<string name="readonly_fs_fail_msg">Seems you have read-only filesystem. </string>
|
||||||
|
<string name="convert_to_rodir">Convert to RoDir</string>
|
||||||
|
<string name="rodir_warning">Please note, that your game settings and saves will be stored in %s</string>
|
||||||
<!-- /Write check -->
|
<!-- /Write check -->
|
||||||
|
|
||||||
<!-- Tutorial -->
|
<!-- Tutorial -->
|
||||||
|
|
|
@ -257,7 +257,7 @@ public class LauncherActivity extends Activity
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged( CompoundButton v, boolean isChecked )
|
public void onCheckedChanged( CompoundButton v, boolean isChecked )
|
||||||
{
|
{
|
||||||
enableRoDir( isChecked );
|
hideRodirSettings( !isChecked );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -303,12 +303,24 @@ public class LauncherActivity extends Activity
|
||||||
}
|
}
|
||||||
changeButtonsStyle((ViewGroup)tabHost.getParent());
|
changeButtonsStyle((ViewGroup)tabHost.getParent());
|
||||||
hideResolutionSettings( !resolution.isChecked() );
|
hideResolutionSettings( !resolution.isChecked() );
|
||||||
enableRoDir( useRoDir.isChecked() );
|
hideRodirSettings( !useRoDir.isChecked() );
|
||||||
updateResolutionResult();
|
updateResolutionResult();
|
||||||
toggleResolutionFields();
|
toggleResolutionFields();
|
||||||
if( !mPref.getBoolean("successfulRun",false) )
|
if( !mPref.getBoolean("successfulRun",false) )
|
||||||
showFirstRun();
|
showFirstRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume()
|
||||||
|
{
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
useRoDir.setChecked( mPref.getBoolean("use_rodir", false) );
|
||||||
|
useRoDirAuto.setChecked( mPref.getBoolean("use_rodir_auto", true) );
|
||||||
|
writePath.setText(mPref.getString("writedir", FWGSLib.getExternalFilesDir(this)));
|
||||||
|
|
||||||
|
hideRodirSettings( !useRoDir.isChecked() );
|
||||||
|
}
|
||||||
|
|
||||||
void updatePath( String text )
|
void updatePath( String text )
|
||||||
{
|
{
|
||||||
|
@ -321,9 +333,9 @@ public class LauncherActivity extends Activity
|
||||||
scaleGroup.setVisibility( hide ? View.GONE : View.VISIBLE );
|
scaleGroup.setVisibility( hide ? View.GONE : View.VISIBLE );
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableRoDir( boolean enable )
|
void hideRodirSettings( boolean hide )
|
||||||
{
|
{
|
||||||
rodirSettings.setVisibility( enable ? View.VISIBLE : View.GONE );
|
rodirSettings.setVisibility( hide ? View.GONE : View.VISIBLE );
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWatcher resTextChangeWatcher = new TextWatcher()
|
TextWatcher resTextChangeWatcher = new TextWatcher()
|
||||||
|
|
|
@ -72,7 +72,6 @@ public class XashActivity extends Activity {
|
||||||
private static boolean mHasVibrator;
|
private static boolean mHasVibrator;
|
||||||
private int mReturingWithResultCode = 0;
|
private int mReturingWithResultCode = 0;
|
||||||
|
|
||||||
private static int OPEN_DOCUMENT_TREE_RESULT = 1;
|
|
||||||
private static int FPICKER_RESULT = 2;
|
private static int FPICKER_RESULT = 2;
|
||||||
|
|
||||||
|
|
||||||
|
@ -148,7 +147,7 @@ public class XashActivity extends Activity {
|
||||||
Log.v( TAG, "folderask == false. Checking write permission..." );
|
Log.v( TAG, "folderask == false. Checking write permission..." );
|
||||||
|
|
||||||
// check write permission and run engine, if possible
|
// check write permission and run engine, if possible
|
||||||
String basedir = getStringExtraFromIntent( getIntent(), "basedir", mPref.getString( "basedir", "/sdcard/xash/" ) );
|
String basedir = FWGSLib.getStringExtraFromIntent( getIntent(), "basedir", mPref.getString( "basedir", "/sdcard/xash/" ) );
|
||||||
checkWritePermission( basedir );
|
checkWritePermission( basedir );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,36 +186,6 @@ public class XashActivity extends Activity {
|
||||||
String basedir = mPref.getString( "basedir", "/sdcard/xash/" );
|
String basedir = mPref.getString( "basedir", "/sdcard/xash/" );
|
||||||
checkWritePermission( basedir );
|
checkWritePermission( basedir );
|
||||||
}
|
}
|
||||||
/*else if( mReturingWithResultCode == OPEN_DOCUMENT_TREE_RESULT )
|
|
||||||
{
|
|
||||||
String basedir = getStringExtraFromIntent( getIntent(), "basedir", mPref.getString("basedir","/sdcard/xash/"));
|
|
||||||
Log.v(TAG, "Got permissions. Checking writing again...");
|
|
||||||
|
|
||||||
if( nativeTestWritePermission( basedir ) == 0 )
|
|
||||||
{
|
|
||||||
Log.v(TAG, "Write test has failed twice!");
|
|
||||||
String msg = getString(R.string.lollipop_request_permission_fail_msg) + getString(R.string.ask_about_new_basedir_msg);
|
|
||||||
|
|
||||||
new AlertDialog.Builder(this)
|
|
||||||
.setTitle( R.string.write_failed )
|
|
||||||
.setMessage( msg )
|
|
||||||
.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
|
|
||||||
{
|
|
||||||
public void onClick(DialogInterface dialog, int whichButton)
|
|
||||||
{
|
|
||||||
XashActivity act = XashActivity.this;
|
|
||||||
act.setFolderAsk( true );
|
|
||||||
act.finish();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setCancelable(false)
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
launchSurfaceAndEngine();
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
mReturingWithResultCode = 0;
|
mReturingWithResultCode = 0;
|
||||||
}
|
}
|
||||||
|
@ -323,16 +292,17 @@ public class XashActivity extends Activity {
|
||||||
editor.commit();
|
editor.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getStringExtraFromIntent( Intent intent, String extraString, String ifNotFound )
|
|
||||||
|
private DialogInterface.OnClickListener folderAskEnable = new DialogInterface.OnClickListener()
|
||||||
{
|
{
|
||||||
String ret = intent.getStringExtra( extraString );
|
@Override
|
||||||
if( ret == null )
|
public void onClick( DialogInterface dialog, int whichButton )
|
||||||
{
|
{
|
||||||
ret = ifNotFound;
|
XashActivity act = XashActivity.this;
|
||||||
|
act.setFolderAsk( XashActivity.this, true );
|
||||||
|
act.finish();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkWritePermission( String basedir )
|
private void checkWritePermission( String basedir )
|
||||||
{
|
{
|
||||||
|
@ -366,13 +336,12 @@ public class XashActivity extends Activity {
|
||||||
new AlertDialog.Builder( this )
|
new AlertDialog.Builder( this )
|
||||||
.setTitle( R.string.write_failed )
|
.setTitle( R.string.write_failed )
|
||||||
.setMessage( msg )
|
.setMessage( msg )
|
||||||
.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
|
.setPositiveButton( R.string.ok, folderAskEnable )
|
||||||
|
.setNegativeButton( R.string.convert_to_rodir, new DialogInterface.OnClickListener()
|
||||||
{
|
{
|
||||||
public void onClick( DialogInterface dialog, int whichButton )
|
public void onClick( DialogInterface dialog, int whichButton )
|
||||||
{
|
{
|
||||||
XashActivity act = XashActivity.this;
|
XashActivity.this.convertToRodir();
|
||||||
act.setFolderAsk( XashActivity.this, true );
|
|
||||||
act.finish();
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setCancelable( false )
|
.setCancelable( false )
|
||||||
|
@ -385,6 +354,33 @@ public class XashActivity extends Activity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void convertToRodir()
|
||||||
|
{
|
||||||
|
mWriteDir = FWGSLib.getExternalFilesDir(this);
|
||||||
|
|
||||||
|
new AlertDialog.Builder( this )
|
||||||
|
.setTitle( R.string.convert_to_rodir )
|
||||||
|
.setMessage( String.format( getString( R.string.rodir_warning, mWriteDir ) ) )
|
||||||
|
.setNegativeButton( R.string.cancel, folderAskEnable )
|
||||||
|
.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onClick( DialogInterface dialog, int whichButton )
|
||||||
|
{
|
||||||
|
XashActivity.mUseRoDir = true;
|
||||||
|
|
||||||
|
SharedPreferences.Editor editor = XashActivity.this.mPref.edit();
|
||||||
|
editor.putBoolean("use_rodir", XashActivity.mUseRoDir);
|
||||||
|
editor.putString("writedir", XashActivity.mWriteDir);
|
||||||
|
editor.commit();
|
||||||
|
|
||||||
|
XashActivity.this.launchSurfaceAndEngine();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setCancelable( false )
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
private void launchSurfaceAndEngine()
|
private void launchSurfaceAndEngine()
|
||||||
{
|
{
|
||||||
Log.v( TAG, "Everything is OK. Launching engine..." );
|
Log.v( TAG, "Everything is OK. Launching engine..." );
|
||||||
|
@ -468,10 +464,10 @@ public class XashActivity extends Activity {
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
final String enginedir = getFilesDir().getParentFile().getPath() + "/lib";
|
final String enginedir = getFilesDir().getParentFile().getPath() + "/lib";
|
||||||
|
|
||||||
String argv = getStringExtraFromIntent( intent, "argv", mPref.getString( "argv", "-dev 3 -log" ) );
|
String argv = FWGSLib.getStringExtraFromIntent( intent, "argv", mPref.getString( "argv", "-dev 3 -log" ) );
|
||||||
String gamelibdir = getStringExtraFromIntent( intent, "gamelibdir", enginedir );
|
String gamelibdir = FWGSLib.getStringExtraFromIntent( intent, "gamelibdir", enginedir );
|
||||||
String gamedir = getStringExtraFromIntent( intent, "gamedir", "valve" );
|
String gamedir = FWGSLib.getStringExtraFromIntent( intent, "gamedir", "valve" );
|
||||||
String basedir = getStringExtraFromIntent( intent, "basedir", mPref.getString( "basedir", "/sdcard/xash/" ) );
|
String basedir = FWGSLib.getStringExtraFromIntent( intent, "basedir", mPref.getString( "basedir", "/sdcard/xash/" ) );
|
||||||
String gdbsafe = intent.getStringExtra( "gdbsafe" );
|
String gdbsafe = intent.getStringExtra( "gdbsafe" );
|
||||||
|
|
||||||
bIsCstrike = ( gamedir.equals("cstrike") || gamedir.equals("czero") || gamedir.equals("czeror") );
|
bIsCstrike = ( gamedir.equals("cstrike") || gamedir.equals("czero") || gamedir.equals("czeror") );
|
||||||
|
|
|
@ -127,6 +127,17 @@ public class FWGSLib
|
||||||
return (metrics.widthPixels > metrics.heightPixels);
|
return (metrics.widthPixels > metrics.heightPixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getStringExtraFromIntent( Intent intent, String extraString, String ifNotFound )
|
||||||
|
{
|
||||||
|
String ret = intent.getStringExtra( extraString );
|
||||||
|
if( ret == null )
|
||||||
|
{
|
||||||
|
ret = ifNotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static final int sdk = Integer.valueOf(Build.VERSION.SDK);
|
public static final int sdk = Integer.valueOf(Build.VERSION.SDK);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue