Possibility to change user config

This commit is contained in:
pelya
2010-08-21 14:20:45 +03:00
parent 17707104f7
commit 814db2bc42
3 changed files with 31 additions and 24 deletions

View File

@@ -50,7 +50,7 @@ class AudioThread {
if( AudioTrack.getMinBufferSize( rate, channels, encoding ) > bufSize ) if( AudioTrack.getMinBufferSize( rate, channels, encoding ) > bufSize )
bufSize = AudioTrack.getMinBufferSize( rate, channels, encoding ); bufSize = AudioTrack.getMinBufferSize( rate, channels, encoding );
bufSize = bufSize * ((Globals.AudioBufferConfig * 2.5f) + 1.0f); bufSize = (int)((float)bufSize * (((float)Globals.AudioBufferConfig * 2.5f) + 1.0f));
mAudioBuffer = new byte[bufSize]; mAudioBuffer = new byte[bufSize];

View File

@@ -25,11 +25,10 @@ public class MainActivity extends Activity {
_tv = new TextView(this); _tv = new TextView(this);
_tv.setText("Initializing"); _tv.setText("Initializing");
setContentView(_tv); setContentView(_tv);
Settings.Load(this);
mLoadLibraryStub = new LoadLibrary(); mLoadLibraryStub = new LoadLibrary();
mAudioThread = new AudioThread(this); mAudioThread = new AudioThread(this);
Settings.Load(this);
} }
public void startDownloader() public void startDownloader()
@@ -126,6 +125,24 @@ public class MainActivity extends Activity {
mGLView.onTouchEvent(ev); mGLView.onTouchEvent(ev);
return true; return true;
} }
public void setText(final String t)
{
class Callback implements Runnable
{
public TextView Status;
public String text;
public void run()
{
if(Status != null)
Status.setText(text);
}
}
Callback cb = new Callback();
cb.text = new String(t);
cb.Status = _tv;
this.runOnUiThread(cb);
}
private DemoGLSurfaceView mGLView = null; private DemoGLSurfaceView mGLView = null;
private LoadLibrary mLoadLibraryStub = null; private LoadLibrary mLoadLibraryStub = null;

View File

@@ -58,7 +58,7 @@ class Settings
Globals.TrackballDampening = settingsFile.readInt(); Globals.TrackballDampening = settingsFile.readInt();
Globals.AudioBufferConfig = settingsFile.readInt(); Globals.AudioBufferConfig = settingsFile.readInt();
/*
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle("Phone configuration"); builder.setTitle("Phone configuration");
builder.setPositiveButton("Change phone configuration", new DialogInterface.OnClickListener() builder.setPositiveButton("Change phone configuration", new DialogInterface.OnClickListener()
@@ -70,6 +70,7 @@ class Settings
showDownloadConfig(p); showDownloadConfig(p);
} }
}); });
/*
builder.setNegativeButton("Start", new DialogInterface.OnClickListener() builder.setNegativeButton("Start", new DialogInterface.OnClickListener()
{ {
public void onClick(DialogInterface dialog, int item) public void onClick(DialogInterface dialog, int item)
@@ -79,6 +80,7 @@ class Settings
startDownloader(p); startDownloader(p);
} }
}); });
*/
AlertDialog alert = builder.create(); AlertDialog alert = builder.create();
alert.setOwnerActivity(p); alert.setOwnerActivity(p);
changeConfigAlert = alert; changeConfigAlert = alert;
@@ -89,33 +91,21 @@ class Settings
Callback( MainActivity _p ) { p = _p; } Callback( MainActivity _p ) { p = _p; }
public void run() public void run()
{ {
System.out.println("Change phone config: sleeping 2 sec");
try { try {
Thread.sleep(5000); Thread.sleep(1500);
} catch( InterruptedException e ) {}; } catch( InterruptedException e ) {};
if( changeConfigAlert == null ) if( changeConfigAlert == null )
return; return;
class Callback2 implements Runnable changeConfigAlert.dismiss();
{ startDownloader(p);
public void run()
{
System.out.println("Change phone config: launching...");
changeConfigAlert.dismiss(); // Does not work, eh
//changeConfigAlert.getButton(AlertDialog.BUTTON_NEGATIVE).dispatchTouchEvent(MotionEvent.obtain(0l, 0l, MotionEvent.ACTION_DOWN, 0.0f, 0.0f, 0));
//changeConfigAlert.getButton(AlertDialog.BUTTON_NEGATIVE).dispatchTouchEvent(MotionEvent.obtain(0l, 0l, MotionEvent.ACTION_UP, 0.0f, 0.0f, 0));
}
}
p.runOnUiThread(new Callback2());
} }
}; };
changeConfigAlertThread = new Thread(new Callback(p)); changeConfigAlertThread = new Thread(new Callback(p));
changeConfigAlertThread.run(); changeConfigAlertThread.start();
alert.show(); alert.show();
*/
startDownloader(p);
return; return;
} catch( FileNotFoundException e ) { } catch( FileNotFoundException e ) {
@@ -142,9 +132,9 @@ class Settings
c.navigation == Configuration.NAVIGATION_NONAV ? "None" : c.navigation == Configuration.NAVIGATION_NONAV ? "None" :
"Unknown" ) ); "Unknown" ) );
*/ */
showDownloadConfig(p); showDownloadConfig(p);
} }
static void showDownloadConfig(final MainActivity p) { static void showDownloadConfig(final MainActivity p) {