Wire in save for OpenRocketDocument.
This commit is contained in:
parent
00519d820a
commit
00696ce7a3
@ -1,6 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_save"
|
||||||
|
android:title="@string/save"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/motor_list_menu_option"
|
android:id="@+id/motor_list_menu_option"
|
||||||
android:icon="@drawable/ic_motorbrowser"
|
android:icon="@drawable/ic_motorbrowser"
|
||||||
|
2
android/src/build.properties
Normal file
2
android/src/build.properties
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
build.version=12.03-droid-DEV
|
||||||
|
build.source=source
|
@ -1,24 +1,30 @@
|
|||||||
package net.sf.openrocket.android;
|
package net.sf.openrocket.android;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||||
import net.sf.openrocket.android.util.AndroidLogWrapper;
|
import net.sf.openrocket.android.util.AndroidLogWrapper;
|
||||||
import net.sf.openrocket.database.ComponentPresetDatabase;
|
import net.sf.openrocket.database.ComponentPresetDatabase;
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
|
import net.sf.openrocket.file.openrocket.OpenRocketSaver;
|
||||||
import net.sf.openrocket.l10n.DebugTranslator;
|
import net.sf.openrocket.l10n.DebugTranslator;
|
||||||
import net.sf.openrocket.l10n.ResourceBundleTranslator;
|
import net.sf.openrocket.l10n.ResourceBundleTranslator;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
|
import android.net.Uri;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
public class Application extends android.app.Application {
|
public class Application extends android.app.Application {
|
||||||
|
|
||||||
private OpenRocketDocument rocketDocument;
|
private OpenRocketDocument rocketDocument;
|
||||||
|
private Uri fileUri;
|
||||||
|
|
||||||
private WarningSet warnings;
|
private WarningSet warnings;
|
||||||
|
|
||||||
// Big B boolean so I can synchronize on it.
|
// Big B boolean so I can synchronize on it.
|
||||||
private static Boolean initialized = false;
|
private static Boolean initialized = false;
|
||||||
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
synchronized (initialized) {
|
synchronized (initialized) {
|
||||||
if ( initialized == true ) {
|
if ( initialized == true ) {
|
||||||
@ -29,21 +35,21 @@ public class Application extends android.app.Application {
|
|||||||
System.setProperty("org.xml.sax.driver","org.xmlpull.v1.sax2.Driver");
|
System.setProperty("org.xml.sax.driver","org.xmlpull.v1.sax2.Driver");
|
||||||
|
|
||||||
net.sf.openrocket.startup.Application.setLogger( new AndroidLogWrapper.LogHelper() );
|
net.sf.openrocket.startup.Application.setLogger( new AndroidLogWrapper.LogHelper() );
|
||||||
|
|
||||||
net.sf.openrocket.startup.Application.setPreferences( new PreferencesAdapter() );
|
net.sf.openrocket.startup.Application.setPreferences( new PreferencesAdapter() );
|
||||||
|
|
||||||
net.sf.openrocket.startup.Application.setComponentPresetDao( new ComponentPresetDatabase() );
|
net.sf.openrocket.startup.Application.setComponentPresetDao( new ComponentPresetDatabase() );
|
||||||
|
|
||||||
MotorDatabaseAdapter db = new MotorDatabaseAdapter(this);
|
MotorDatabaseAdapter db = new MotorDatabaseAdapter(this);
|
||||||
|
|
||||||
net.sf.openrocket.startup.Application.setMotorSetDatabase(db);
|
net.sf.openrocket.startup.Application.setMotorSetDatabase(db);
|
||||||
|
|
||||||
Translator t;
|
Translator t;
|
||||||
t = new ResourceBundleTranslator("l10n.messages");
|
t = new ResourceBundleTranslator("l10n.messages");
|
||||||
if (Locale.getDefault().getLanguage().equals("xx")) {
|
if (Locale.getDefault().getLanguage().equals("xx")) {
|
||||||
t = new DebugTranslator(t);
|
t = new DebugTranslator(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
net.sf.openrocket.startup.Application.setBaseTranslator(t);
|
net.sf.openrocket.startup.Application.setBaseTranslator(t);
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
@ -84,7 +90,18 @@ public class Application extends android.app.Application {
|
|||||||
public void setWarnings(WarningSet warnings) {
|
public void setWarnings(WarningSet warnings) {
|
||||||
this.warnings = warnings;
|
this.warnings = warnings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Uri getFileUri() {
|
||||||
|
return fileUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileUri(Uri fileUri) {
|
||||||
|
this.fileUri = fileUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveOpenRocketDocument() throws IOException {
|
||||||
|
OpenRocketSaver saver = new OpenRocketSaver();
|
||||||
|
saver.save(new File(fileUri.getPath()),rocketDocument);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ implements TCQueryAction.OnTCQueryCompleteListener, OpenRocketLoaderFragment.OnO
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadOrkFile( Uri file ) {
|
private void loadOrkFile( Uri file ) {
|
||||||
|
((Application)getApplication()).setFileUri( file );
|
||||||
AndroidLogWrapper.d(OpenRocketLoaderActivity.class,"Use ork file: " + file);
|
AndroidLogWrapper.d(OpenRocketLoaderActivity.class,"Use ork file: " + file);
|
||||||
String path = file.getPath();
|
String path = file.getPath();
|
||||||
File orkFile = new File(path);
|
File orkFile = new File(path);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package net.sf.openrocket.android.rocket;
|
package net.sf.openrocket.android.rocket;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import net.sf.openrocket.R;
|
import net.sf.openrocket.R;
|
||||||
import net.sf.openrocket.android.ActivityHelpers;
|
import net.sf.openrocket.android.ActivityHelpers;
|
||||||
import net.sf.openrocket.android.Application;
|
import net.sf.openrocket.android.Application;
|
||||||
@ -37,13 +39,13 @@ implements Simulations.OnSimulationSelectedListener
|
|||||||
setContentView(R.layout.openrocketviewer);
|
setContentView(R.layout.openrocketviewer);
|
||||||
ViewPager viewPager = (ViewPager)findViewById(R.id.pager);
|
ViewPager viewPager = (ViewPager)findViewById(R.id.pager);
|
||||||
viewPager.setAdapter( new OpenRocketViewerPager( this.getSupportFragmentManager()));
|
viewPager.setAdapter( new OpenRocketViewerPager( this.getSupportFragmentManager()));
|
||||||
|
|
||||||
setTitle(app.getRocketDocument().getRocket().getName());
|
setTitle(app.getRocketDocument().getRocket().getName());
|
||||||
|
|
||||||
getActionBarHelper().setDisplayHomeAsUpEnabled(true);
|
getActionBarHelper().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
MenuInflater inflater = getMenuInflater();
|
MenuInflater inflater = getMenuInflater();
|
||||||
@ -55,6 +57,14 @@ implements Simulations.OnSimulationSelectedListener
|
|||||||
public boolean onMenuItemSelected(int featureId, MenuItem item) {
|
public boolean onMenuItemSelected(int featureId, MenuItem item) {
|
||||||
AndroidLogWrapper.d(OpenRocketViewer.class,"onMenuItemSelected" + item.getItemId());
|
AndroidLogWrapper.d(OpenRocketViewer.class,"onMenuItemSelected" + item.getItemId());
|
||||||
switch(item.getItemId()) {
|
switch(item.getItemId()) {
|
||||||
|
case R.id.menu_save:
|
||||||
|
// FIXME - Probably want to open a dialog here.
|
||||||
|
try {
|
||||||
|
((Application)getApplication()).saveOpenRocketDocument();
|
||||||
|
} catch ( IOException iex ) {
|
||||||
|
AndroidLogWrapper.d(OpenRocketViewer.class, iex.getMessage());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
ActivityHelpers.goHome(this);
|
ActivityHelpers.goHome(this);
|
||||||
return true;
|
return true;
|
||||||
@ -73,7 +83,7 @@ implements Simulations.OnSimulationSelectedListener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSimulationSelected(int simulationId) {
|
public void onSimulationSelected(int simulationId) {
|
||||||
|
|
||||||
Simulation sim = app.getRocketDocument().getSimulation(simulationId);
|
Simulation sim = app.getRocketDocument().getSimulation(simulationId);
|
||||||
// Check if there is data for this simulation.
|
// Check if there is data for this simulation.
|
||||||
if ( sim.getSimulatedData().getBranchCount() == 0 ) {
|
if ( sim.getSimulatedData().getBranchCount() == 0 ) {
|
||||||
@ -83,7 +93,7 @@ implements Simulations.OnSimulationSelectedListener
|
|||||||
builder.show();
|
builder.show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
View sidepane = findViewById(R.id.sidepane);
|
View sidepane = findViewById(R.id.sidepane);
|
||||||
if ( /* if multi pane */ sidepane != null ) {
|
if ( /* if multi pane */ sidepane != null ) {
|
||||||
SimulationChart chart = new SimulationChart(simulationId);
|
SimulationChart chart = new SimulationChart(simulationId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user