Checkpoint commit with many different changes. Made the Configuration and Simulation "add" buttons to be action bar items. Added Handler to act as a listener mechansims so the OpenRocketViewer can update fragments when the rocket is modified. Added MotorConfigSpinner as custom View which is more usable than MotorConfigSpinnerAdapter.
This commit is contained in:
parent
4b109f74f8
commit
cb8faf376e
@ -4,25 +4,14 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
|
|
||||||
<LinearLayout
|
<!--
|
||||||
android:layout_width="match_parent"
|
Note because my implementation of ExpandableListFragment is stupid, the id
|
||||||
android:layout_height="0dp"
|
of the ExpandableListView must be @android:id/list
|
||||||
android:layout_weight="1"
|
-->
|
||||||
android:orientation="vertical" >
|
|
||||||
|
|
||||||
<!-- Note because my implementation of ExpandableListFragment is stupid, the id
|
|
||||||
of the ExpandableListView must be @android:id/list -->
|
|
||||||
<ExpandableListView
|
<ExpandableListView
|
||||||
android:id="@android:id/list"
|
android:id="@android:id/list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/openrocketviewerAddConfiguration"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:text="Add" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -61,7 +61,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="" />
|
android:text="" />
|
||||||
|
|
||||||
<Spinner
|
<net.sf.openrocket.android.rocket.MotorConfigSpinner
|
||||||
android:id="@+id/openrocketviewerConfigurationSpinner"
|
android:id="@+id/openrocketviewerConfigurationSpinner"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -43,6 +43,21 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/simulationConditionsLaunchRodAngle" />
|
android:text="@string/simulationConditionsLaunchRodAngle" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/simulation_condition_roddirection"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ems="10"
|
||||||
|
android:gravity="right"
|
||||||
|
android:inputType="number"
|
||||||
|
android:text="0" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/labelTextStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/simulationConditionsLaunchRodDirection" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/simulation_condition_rodangle"
|
android:id="@+id/simulation_condition_rodangle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -52,10 +67,22 @@
|
|||||||
android:inputType="number"
|
android:inputType="number"
|
||||||
android:text="0" />
|
android:text="0" />
|
||||||
|
|
||||||
<Spinner
|
<net.sf.openrocket.android.rocket.MotorConfigSpinner
|
||||||
android:id="@+id/simulationConditionConfigurationSpinner"
|
android:id="@+id/simulationConditionConfigurationSpinner"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:prompt="@string/simulationConditionSelectMotors" />
|
android:prompt="@string/simulationConditionSelectMotors" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/simulationConditionDelete"
|
||||||
|
android:layout_width="250dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/Delete"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/simulationConditionRun"
|
||||||
|
android:layout_width="250dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/Run" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:orderInCategory="0"
|
||||||
|
android:id="@+id/menu_add"
|
||||||
|
android:showAsAction="always"
|
||||||
|
android:title="@string/Add"/>
|
||||||
|
|
||||||
|
</menu>
|
@ -5,6 +5,7 @@
|
|||||||
android:id="@+id/menu_save"
|
android:id="@+id/menu_save"
|
||||||
android:title="@string/save"/>
|
android:title="@string/save"/>
|
||||||
<item
|
<item
|
||||||
|
android:orderInCategory="10"
|
||||||
android:id="@+id/motor_list_menu_option"
|
android:id="@+id/motor_list_menu_option"
|
||||||
android:icon="@drawable/ic_motorbrowser"
|
android:icon="@drawable/ic_motorbrowser"
|
||||||
android:showAsAction="ifRoom"
|
android:showAsAction="ifRoom"
|
||||||
|
10
android/res/menu/rocket_viewer_simulation_option_menu.xml
Normal file
10
android/res/menu/rocket_viewer_simulation_option_menu.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:orderInCategory="0"
|
||||||
|
android:id="@+id/menu_add"
|
||||||
|
android:showAsAction="always"
|
||||||
|
android:title="@string/Add"/>
|
||||||
|
|
||||||
|
</menu>
|
@ -4,6 +4,7 @@
|
|||||||
<string name="app_name">OpenRocket</string>
|
<string name="app_name">OpenRocket</string>
|
||||||
<string name="version">version 12.03</string>
|
<string name="version">version 12.03</string>
|
||||||
<string name="save">Save</string>
|
<string name="save">Save</string>
|
||||||
|
<string name="Add">Add</string>
|
||||||
<string name="MotorListTitle">Motor List</string>
|
<string name="MotorListTitle">Motor List</string>
|
||||||
<string name="Download">Download</string>
|
<string name="Download">Download</string>
|
||||||
<string name="About">About</string>
|
<string name="About">About</string>
|
||||||
@ -80,7 +81,10 @@
|
|||||||
<string name="simulationConditionWind">Wind speed</string>
|
<string name="simulationConditionWind">Wind speed</string>
|
||||||
<string name="simulationConditionsRodLength">Launch Rod Length</string>
|
<string name="simulationConditionsRodLength">Launch Rod Length</string>
|
||||||
<string name="simulationConditionsLaunchRodAngle">Launch Rod Angle</string>
|
<string name="simulationConditionsLaunchRodAngle">Launch Rod Angle</string>
|
||||||
|
<string name="simulationConditionsLaunchRodDirection">Launch Rod Direction</string>
|
||||||
<string name="select_motor">Select Motor</string>
|
<string name="select_motor">Select Motor</string>
|
||||||
<string name="select_delay">Delay</string>
|
<string name="select_delay">Delay</string>
|
||||||
|
<string name="Delete">Delete</string>
|
||||||
|
<string name="Run">Run</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -8,10 +8,13 @@ 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.document.Simulation;
|
||||||
import net.sf.openrocket.file.openrocket.OpenRocketSaver;
|
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 net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
@ -66,9 +69,17 @@ public class Application extends android.app.Application {
|
|||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
initialize();
|
initialize();
|
||||||
|
boolean isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
|
||||||
|
AndroidLogWrapper.setLogEnabled(isDebuggable);
|
||||||
PreferencesActivity.initializePreferences(this, PreferenceManager.getDefaultSharedPreferences(this));
|
PreferencesActivity.initializePreferences(this, PreferenceManager.getDefaultSharedPreferences(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private RocketChangedEventHandler handler;
|
||||||
|
|
||||||
|
public void setHandler( RocketChangedEventHandler handler ) {
|
||||||
|
this.handler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the rocketDocument
|
* @return the rocketDocument
|
||||||
*/
|
*/
|
||||||
@ -76,6 +87,30 @@ public class Application extends android.app.Application {
|
|||||||
return rocketDocument;
|
return rocketDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addNewSimulation() {
|
||||||
|
Rocket rocket = rocketDocument.getRocket();
|
||||||
|
Simulation newSim = new Simulation(rocket);
|
||||||
|
newSim.setName(rocketDocument.getNextSimulationName());
|
||||||
|
rocketDocument.addSimulation(newSim);
|
||||||
|
if ( handler != null ) {
|
||||||
|
handler.simsChangedMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteSimulation( int simulationPos ) {
|
||||||
|
rocketDocument.removeSimulation( simulationPos );
|
||||||
|
if ( handler != null ) {
|
||||||
|
handler.simsChangedMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String addNewMotorConfig() {
|
||||||
|
String configId = rocketDocument.getRocket().newMotorConfigurationID();
|
||||||
|
if ( handler != null ) {
|
||||||
|
handler.configsChangedMessage();
|
||||||
|
}
|
||||||
|
return configId;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @param rocketDocument the rocketDocument to set
|
* @param rocketDocument the rocketDocument to set
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
package net.sf.openrocket.android;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.os.Message;
|
||||||
|
|
||||||
|
public abstract class RocketChangedEventHandler extends Handler {
|
||||||
|
|
||||||
|
public RocketChangedEventHandler() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public RocketChangedEventHandler(Callback callback) {
|
||||||
|
super(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RocketChangedEventHandler(Looper looper) {
|
||||||
|
super(looper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RocketChangedEventHandler(Looper looper, Callback callback) {
|
||||||
|
super(looper, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final int MOTOR_CONFIGS_CHANGED = 1;
|
||||||
|
public static final int SIMS_CHANGED = 2;
|
||||||
|
|
||||||
|
public void simsChangedMessage() {
|
||||||
|
Message m = this.obtainMessage(SIMS_CHANGED);
|
||||||
|
this.dispatchMessage(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void configsChangedMessage() {
|
||||||
|
Message m = this.obtainMessage(MOTOR_CONFIGS_CHANGED);
|
||||||
|
this.dispatchMessage(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
int what = msg.what;
|
||||||
|
switch ( what ) {
|
||||||
|
case SIMS_CHANGED:
|
||||||
|
doSimsChanged();
|
||||||
|
break;
|
||||||
|
case MOTOR_CONFIGS_CHANGED:
|
||||||
|
doMotorConfigsChanged();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
super.handleMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void doSimsChanged();
|
||||||
|
|
||||||
|
protected abstract void doMotorConfigsChanged();
|
||||||
|
|
||||||
|
}
|
@ -25,6 +25,10 @@ import android.widget.Button;
|
|||||||
import android.widget.ExpandableListAdapter;
|
import android.widget.ExpandableListAdapter;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.actionbarsherlock.view.Menu;
|
||||||
|
import com.actionbarsherlock.view.MenuInflater;
|
||||||
|
import com.actionbarsherlock.view.MenuItem;
|
||||||
|
|
||||||
public class Configurations extends ExpandableListFragment {
|
public class Configurations extends ExpandableListFragment {
|
||||||
|
|
||||||
private final static String wizardFrag = "wizardFrag";
|
private final static String wizardFrag = "wizardFrag";
|
||||||
@ -32,20 +36,27 @@ public class Configurations extends ExpandableListFragment {
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
setHasOptionsMenu(true);
|
||||||
View v = inflater.inflate(R.layout.rocket_configurations, container, false);
|
View v = inflater.inflate(R.layout.rocket_configurations, container, false);
|
||||||
|
|
||||||
Button b = (Button) v.findViewById(R.id.openrocketviewerAddConfiguration);
|
return v;
|
||||||
|
}
|
||||||
b.setOnClickListener( new View.OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
((Application)getActivity().getApplication()).getRocketDocument().getRocket().newMotorConfigurationID();
|
inflater.inflate(R.menu.rocket_viewer_configurations_option_menu, menu);
|
||||||
Configurations.this.setup();
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
return v;
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId())
|
||||||
|
{
|
||||||
|
case R.id.menu_add:
|
||||||
|
addConfiguration();
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -56,6 +67,14 @@ public class Configurations extends ExpandableListFragment {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void refreshConfigsList() {
|
||||||
|
setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addConfiguration() {
|
||||||
|
((Application)getActivity().getApplication()).addNewMotorConfig();
|
||||||
|
}
|
||||||
|
|
||||||
private static class MotorMountInfo {
|
private static class MotorMountInfo {
|
||||||
|
|
||||||
private RocketComponent mmt;
|
private RocketComponent mmt;
|
||||||
|
@ -0,0 +1,87 @@
|
|||||||
|
package net.sf.openrocket.android.rocket;
|
||||||
|
|
||||||
|
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
public class MotorConfigSpinner extends Spinner {
|
||||||
|
|
||||||
|
public MotorConfigSpinner(Context context, AttributeSet attrs,
|
||||||
|
int defStyle, int mode) {
|
||||||
|
super(context, attrs, defStyle, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MotorConfigSpinner(Context context, AttributeSet attrs, int defStyle) {
|
||||||
|
super(context, attrs, defStyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MotorConfigSpinner(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MotorConfigSpinner(Context context, int mode) {
|
||||||
|
super(context, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MotorConfigSpinner(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createAdapter(Rocket rocket ) {
|
||||||
|
|
||||||
|
setAdapter(new MotorConfigSpinnerAdapter(this.getContext(), rocket) );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectedConfiguration( String configId ) {
|
||||||
|
this.setSelection( ((MotorConfigSpinnerAdapter)getAdapter()).getConfigurationPosition( configId ));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelectedConfiguration() {
|
||||||
|
return ((MotorConfigSpinnerAdapter)getAdapter()).getConfiguration( this.getSelectedItemPosition() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MotorConfigSpinnerAdapter extends ArrayAdapter<String> {
|
||||||
|
|
||||||
|
private String[] motorConfigs;
|
||||||
|
|
||||||
|
public MotorConfigSpinnerAdapter(Context context, Rocket rocket) {
|
||||||
|
super(context, android.R.layout.simple_spinner_item);
|
||||||
|
|
||||||
|
motorConfigs = rocket.getMotorConfigurationIDs();
|
||||||
|
|
||||||
|
for( String config: motorConfigs ) {
|
||||||
|
this.add(rocket.getMotorConfigurationNameOrDescription(config));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getConfigurationPosition(String configId) {
|
||||||
|
|
||||||
|
int selectedIndex = 0;
|
||||||
|
|
||||||
|
if ( configId == null ) {
|
||||||
|
return selectedIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
for( String s : motorConfigs ) {
|
||||||
|
// Note - s may be null since it is a valid id.
|
||||||
|
if ( configId.equals(s) ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
selectedIndex++;
|
||||||
|
}
|
||||||
|
if( selectedIndex > motorConfigs.length ) {
|
||||||
|
selectedIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return selectedIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConfiguration( int position ) {
|
||||||
|
return motorConfigs[position];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,20 +0,0 @@
|
|||||||
package net.sf.openrocket.android.rocket;
|
|
||||||
|
|
||||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
|
|
||||||
public class MotorConfigSpinnerAdapter extends ArrayAdapter<String> {
|
|
||||||
|
|
||||||
public MotorConfigSpinnerAdapter(Context context, Rocket rocket) {
|
|
||||||
super(context, android.R.layout.simple_spinner_item);
|
|
||||||
|
|
||||||
String[] motorConfigs = rocket.getMotorConfigurationIDs();
|
|
||||||
|
|
||||||
for( String config: motorConfigs ) {
|
|
||||||
this.add(rocket.getMotorConfigurationNameOrDescription(config));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -32,19 +32,35 @@ implements Simulations.OnSimulationSelectedListener
|
|||||||
|
|
||||||
private Application app;
|
private Application app;
|
||||||
|
|
||||||
|
private final static int OVERVIEW_POS = 0;
|
||||||
|
private final static int COMPONENT_POS = 1;
|
||||||
|
private final static int SIMS_POS = 2;
|
||||||
|
private final static int CONFIGS_POS = 3;
|
||||||
|
private final static int TABSIZE = 4;
|
||||||
|
|
||||||
|
private OpenRocketViewerPagerAdapter viewPagerAdapter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
app = (Application) this.getApplication();
|
app = (Application) this.getApplication();
|
||||||
setContentView(R.layout.openrocketviewer);
|
|
||||||
ViewPager viewPager = (ViewPager)findViewById(R.id.pager);
|
|
||||||
viewPager.setAdapter( new OpenRocketViewerPager( this.getSupportFragmentManager()));
|
|
||||||
|
|
||||||
setTitle(app.getRocketDocument().getRocket().getName());
|
setTitle(app.getRocketDocument().getRocket().getName());
|
||||||
|
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
|
setContentView(R.layout.openrocketviewer);
|
||||||
|
ViewPager viewPager = (ViewPager)findViewById(R.id.pager);
|
||||||
|
viewPagerAdapter = new OpenRocketViewerPagerAdapter( this.getSupportFragmentManager() );
|
||||||
|
viewPager.setAdapter( viewPagerAdapter );
|
||||||
|
|
||||||
|
app.setHandler( new RocketChangedEventHandler( ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
app.setHandler(null);
|
||||||
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -87,7 +103,7 @@ implements Simulations.OnSimulationSelectedListener
|
|||||||
|
|
||||||
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() == null || sim.getSimulatedData().getBranchCount() == 0 ) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setMessage("The selected simulation does not have saved data.");
|
builder.setMessage("The selected simulation does not have saved data.");
|
||||||
builder.setCancelable(true);
|
builder.setCancelable(true);
|
||||||
@ -117,25 +133,47 @@ implements Simulations.OnSimulationSelectedListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class OpenRocketViewerPager extends FragmentPagerAdapter {
|
private class RocketChangedEventHandler extends net.sf.openrocket.android.RocketChangedEventHandler {
|
||||||
|
|
||||||
public OpenRocketViewerPager( FragmentManager fm ) {
|
|
||||||
|
@Override
|
||||||
|
protected void doSimsChanged() {
|
||||||
|
Simulations sims = (Simulations) viewPagerAdapter.getFragmentAtPos(SIMS_POS);
|
||||||
|
if ( sims != null ) {
|
||||||
|
sims.refreshSimulationList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doMotorConfigsChanged() {
|
||||||
|
Configurations configs = (Configurations) viewPagerAdapter.getFragmentAtPos(CONFIGS_POS);
|
||||||
|
if ( configs != null ) {
|
||||||
|
configs.refreshConfigsList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
private class OpenRocketViewerPagerAdapter extends FragmentPagerAdapter {
|
||||||
|
|
||||||
|
public OpenRocketViewerPagerAdapter( FragmentManager fm ) {
|
||||||
super(fm);
|
super(fm);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return 4;
|
return TABSIZE;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Fragment getItem( int position ) {
|
public Fragment getItem( int position ) {
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case 0:
|
case OVERVIEW_POS:
|
||||||
return new Overview();
|
return new Overview();
|
||||||
case 1:
|
case COMPONENT_POS:
|
||||||
return new Component();
|
return new Component();
|
||||||
case 2:
|
case SIMS_POS:
|
||||||
return new Simulations();
|
return new Simulations();
|
||||||
case 3:
|
case CONFIGS_POS:
|
||||||
return new Configurations();
|
return new Configurations();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -143,17 +181,23 @@ implements Simulations.OnSimulationSelectedListener
|
|||||||
@Override
|
@Override
|
||||||
public CharSequence getPageTitle(int position) {
|
public CharSequence getPageTitle(int position) {
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case 0:
|
case OVERVIEW_POS:
|
||||||
return "Overview";
|
return "Overview";
|
||||||
case 1:
|
case COMPONENT_POS:
|
||||||
return "Components";
|
return "Components";
|
||||||
case 2:
|
case SIMS_POS:
|
||||||
return "Simulations";
|
return "Simulations";
|
||||||
case 3:
|
case CONFIGS_POS:
|
||||||
return "Configurations";
|
return "Configurations";
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Fragment getFragmentAtPos( int pos ) {
|
||||||
|
String tag = "android:switcher:"+R.id.pager+":"+pos;
|
||||||
|
Fragment f = OpenRocketViewer.this.getSupportFragmentManager().findFragmentByTag(tag);
|
||||||
|
return f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.Spinner;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class Overview extends Fragment
|
public class Overview extends Fragment
|
||||||
@ -36,7 +35,7 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
|||||||
private AerodynamicCalculator aerodynamicCalculator = new BarrowmanCalculator();
|
private AerodynamicCalculator aerodynamicCalculator = new BarrowmanCalculator();
|
||||||
private MassCalculator massCalculator = new BasicMassCalculator();
|
private MassCalculator massCalculator = new BasicMassCalculator();
|
||||||
|
|
||||||
private Spinner configurationSpinner;
|
private MotorConfigSpinner configurationSpinner;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -44,7 +43,7 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
|||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
AndroidLogWrapper.d(Overview.class, "Created View");
|
AndroidLogWrapper.d(Overview.class, "Created View");
|
||||||
View v = inflater.inflate(R.layout.rocket_overview, container, false);
|
View v = inflater.inflate(R.layout.rocket_overview, container, false);
|
||||||
configurationSpinner = (Spinner) v.findViewById(R.id.openrocketviewerConfigurationSpinner);
|
configurationSpinner = (MotorConfigSpinner) v.findViewById(R.id.openrocketviewerConfigurationSpinner);
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
@ -81,29 +80,12 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
|||||||
|
|
||||||
// Find the index of the default configuration so we can preselect it.
|
// Find the index of the default configuration so we can preselect it.
|
||||||
Configuration defaultConfiguration = rocketDocument.getDefaultConfiguration();
|
Configuration defaultConfiguration = rocketDocument.getDefaultConfiguration();
|
||||||
int selectedIndex = 0;
|
configurationSpinner.createAdapter(rocket);
|
||||||
if ( defaultConfiguration != null ) {
|
|
||||||
String defaultConfigId = defaultConfiguration.getMotorConfigurationID();
|
|
||||||
if ( defaultConfigId != null ) {
|
|
||||||
for( String s : rocket.getMotorConfigurationIDs() ) {
|
|
||||||
// Note - s may be null since it is a valid id.
|
|
||||||
if ( defaultConfigId.equals(s) ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
selectedIndex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if( selectedIndex > rocket.getMotorConfigurationIDs().length ) {
|
|
||||||
selectedIndex = 0;
|
|
||||||
}
|
|
||||||
MotorConfigSpinnerAdapter spinnerAdapter = new MotorConfigSpinnerAdapter(getActivity(),rocket);
|
|
||||||
|
|
||||||
AndroidLogWrapper.d(Overview.class, "spinnerAdapter = " + spinnerAdapter);
|
|
||||||
AndroidLogWrapper.d(Overview.class, "configurationSpinner = " + configurationSpinner);
|
AndroidLogWrapper.d(Overview.class, "configurationSpinner = " + configurationSpinner);
|
||||||
|
|
||||||
configurationSpinner.setAdapter(spinnerAdapter);
|
if ( defaultConfiguration != null ) {
|
||||||
configurationSpinner.setSelection(selectedIndex);
|
configurationSpinner.setSelectedConfiguration(defaultConfiguration.getMotorConfigurationID());
|
||||||
|
}
|
||||||
configurationSpinner.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() {
|
configurationSpinner.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() {
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package net.sf.openrocket.android.rocket;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
|
||||||
|
public abstract class RocketChangedMessages {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,106 @@
|
|||||||
|
|
||||||
|
package net.sf.openrocket.android.rocket;
|
||||||
|
|
||||||
|
import net.sf.openrocket.R;
|
||||||
|
import net.sf.openrocket.android.Application;
|
||||||
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
|
import net.sf.openrocket.document.Simulation;
|
||||||
|
import net.sf.openrocket.simulation.SimulationOptions;
|
||||||
|
import net.sf.openrocket.unit.UnitGroup;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
import com.actionbarsherlock.app.SherlockDialogFragment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An activity that encapsulates a graphical view of the chart.
|
||||||
|
*/
|
||||||
|
public class SimulationEditFragment extends SherlockDialogFragment {
|
||||||
|
|
||||||
|
private int simulationId;
|
||||||
|
|
||||||
|
private EditText windspeedField;
|
||||||
|
private EditText rodlengthField;
|
||||||
|
private EditText rodangleField;
|
||||||
|
private EditText roddirectionField;
|
||||||
|
private MotorConfigSpinner motorSpinner;
|
||||||
|
|
||||||
|
public static SimulationEditFragment newInstance( int simulationId ) {
|
||||||
|
SimulationEditFragment frag = new SimulationEditFragment();
|
||||||
|
Bundle b = new Bundle();
|
||||||
|
b.putInt("simulationId", simulationId);
|
||||||
|
frag.setArguments(b);
|
||||||
|
return frag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setStyle(DialogFragment.STYLE_NO_TITLE,getTheme());
|
||||||
|
|
||||||
|
if ( savedInstanceState != null ) {
|
||||||
|
simulationId = savedInstanceState.getInt("simulationId");
|
||||||
|
} else {
|
||||||
|
Bundle b = getArguments();
|
||||||
|
simulationId = b.getInt("simulationId");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View v = inflater.inflate(R.layout.simulation_condition_dialog, container, false);
|
||||||
|
|
||||||
|
Button deleteButton = (Button) v.findViewById(R.id.simulationConditionDelete);
|
||||||
|
deleteButton.setOnClickListener( new OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
onDelete();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
windspeedField = (EditText) v.findViewById(R.id.simulation_condition_windspeed);
|
||||||
|
rodlengthField = (EditText) v.findViewById(R.id.simulation_condition_rodlength);
|
||||||
|
rodangleField = (EditText) v.findViewById(R.id.simulation_condition_rodangle);
|
||||||
|
roddirectionField = (EditText) v.findViewById(R.id.simulation_condition_roddirection);
|
||||||
|
|
||||||
|
motorSpinner = (MotorConfigSpinner) v.findViewById(R.id.simulationConditionConfigurationSpinner);
|
||||||
|
|
||||||
|
OpenRocketDocument rocketDocument = ((Application)getActivity().getApplication()).getRocketDocument();
|
||||||
|
|
||||||
|
motorSpinner.createAdapter(rocketDocument.getRocket());
|
||||||
|
|
||||||
|
Simulation sim = rocketDocument.getSimulation(simulationId);
|
||||||
|
|
||||||
|
SimulationOptions options = sim.getOptions();
|
||||||
|
if ( options != null ) {
|
||||||
|
windspeedField.setText( UnitGroup.UNITS_VELOCITY.toString( options.getWindSpeedAverage() ));
|
||||||
|
rodlengthField.setText( UnitGroup.UNITS_LENGTH.toString( options.getLaunchRodLength() ));
|
||||||
|
rodangleField.setText( String.valueOf( options.getLaunchRodLength() ));
|
||||||
|
roddirectionField.setText( String.valueOf( options.getLaunchRodDirection() ));
|
||||||
|
motorSpinner.setSelectedConfiguration(options.getMotorConfigurationID());
|
||||||
|
}
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putInt("simulationId", simulationId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDelete( ) {
|
||||||
|
((Application)getActivity().getApplication()).deleteSimulation(simulationId);
|
||||||
|
getDialog().dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,26 +5,35 @@ import net.sf.openrocket.android.Application;
|
|||||||
import net.sf.openrocket.android.util.AndroidLogWrapper;
|
import net.sf.openrocket.android.util.AndroidLogWrapper;
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
import net.sf.openrocket.document.Simulation;
|
import net.sf.openrocket.document.Simulation;
|
||||||
|
import net.sf.openrocket.simulation.FlightData;
|
||||||
import net.sf.openrocket.unit.Unit;
|
import net.sf.openrocket.unit.Unit;
|
||||||
import net.sf.openrocket.unit.UnitGroup;
|
import net.sf.openrocket.unit.UnitGroup;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
import android.widget.AdapterView.OnItemLongClickListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class Simulations extends Fragment
|
import com.actionbarsherlock.app.SherlockFragment;
|
||||||
|
import com.actionbarsherlock.view.Menu;
|
||||||
|
import com.actionbarsherlock.view.MenuInflater;
|
||||||
|
import com.actionbarsherlock.view.MenuItem;
|
||||||
|
|
||||||
|
public class Simulations extends SherlockFragment
|
||||||
implements SharedPreferences.OnSharedPreferenceChangeListener
|
implements SharedPreferences.OnSharedPreferenceChangeListener
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private final static String wizardFrag = "wizardFrag";
|
||||||
|
|
||||||
public interface OnSimulationSelectedListener {
|
public interface OnSimulationSelectedListener {
|
||||||
public void onSimulationSelected( int simulationId );
|
public void onSimulationSelected( int simulationId );
|
||||||
}
|
}
|
||||||
@ -35,12 +44,29 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
setHasOptionsMenu(true);
|
||||||
View v = inflater.inflate(R.layout.rocket_simulations, container, false);
|
View v = inflater.inflate(R.layout.rocket_simulations, container, false);
|
||||||
simulationList = (ListView) v.findViewById(R.id.openrocketviewerSimulationList);
|
simulationList = (ListView) v.findViewById(R.id.openrocketviewerSimulationList);
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
inflater.inflate(R.menu.rocket_viewer_simulation_option_menu, menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId())
|
||||||
|
{
|
||||||
|
case R.id.menu_add:
|
||||||
|
addSimulation();
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
@ -81,6 +107,10 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void refreshSimulationList() {
|
||||||
|
setup();
|
||||||
|
}
|
||||||
|
|
||||||
private void setup() {
|
private void setup() {
|
||||||
final OpenRocketDocument rocketDocument = ((Application)getActivity().getApplication()).getRocketDocument();
|
final OpenRocketDocument rocketDocument = ((Application)getActivity().getApplication()).getRocketDocument();
|
||||||
AndroidLogWrapper.d(Simulations.class,"activity = {0}", this.getActivity());
|
AndroidLogWrapper.d(Simulations.class,"activity = {0}", this.getActivity());
|
||||||
@ -99,9 +129,14 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("motors: ").append(sim.getConfiguration().getMotorConfigurationDescription());
|
sb.append("motors: ").append(sim.getConfiguration().getMotorConfigurationDescription());
|
||||||
Unit distanceUnit = UnitGroup.UNITS_DISTANCE.getDefaultUnit();
|
Unit distanceUnit = UnitGroup.UNITS_DISTANCE.getDefaultUnit();
|
||||||
sb.append(" apogee: ").append( distanceUnit.toStringUnit(sim.getSimulatedData().getMaxAltitude()));
|
FlightData flightData = sim.getSimulatedData();
|
||||||
sb.append(" time: ").append(sim.getSimulatedData().getFlightTime()).append("s");
|
if ( flightData != null ) {
|
||||||
|
sb.append(" apogee: ").append( distanceUnit.toStringUnit(flightData.getMaxAltitude()));
|
||||||
|
sb.append(" time: ").append(flightData.getFlightTime()).append("s");
|
||||||
((TextView)v.findViewById(android.R.id.text2)).setText( sb.toString() );
|
((TextView)v.findViewById(android.R.id.text2)).setText( sb.toString() );
|
||||||
|
} else {
|
||||||
|
((TextView)v.findViewById(android.R.id.text2)).setText("No simulation data");
|
||||||
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,9 +149,27 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
simulationList.setOnItemLongClickListener( new OnItemLongClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onItemLongClick(AdapterView<?> parent, View view,
|
||||||
|
int position, long id) {
|
||||||
|
final SimulationEditFragment f = SimulationEditFragment.newInstance(position);
|
||||||
|
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
|
||||||
|
ft.add(f, wizardFrag);
|
||||||
|
ft.commit();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
simulationList.setAdapter(sims);
|
simulationList.setAdapter(sims);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addSimulation() {
|
||||||
|
((Application)getActivity().getApplication()).addNewSimulation();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
package net.sf.openrocket.android.simulation;
|
|
||||||
|
|
||||||
import net.sf.openrocket.R;
|
|
||||||
import net.sf.openrocket.android.ActivityHelpers;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.app.FragmentActivity;
|
|
||||||
import android.support.v4.app.FragmentTransaction;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An activity that encapsulates a graphical view of the chart.
|
|
||||||
*/
|
|
||||||
public class SimulationRunActivity extends FragmentActivity {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
int simulationNumber = getIntent().getIntExtra("Simulation", -1);
|
|
||||||
|
|
||||||
Fragment graph = SimulationRunFragment.newInstance(simulationNumber);
|
|
||||||
|
|
||||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
|
||||||
ft.replace(android.R.id.content, graph);
|
|
||||||
ft.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onMenuItemSelected(int featureId, MenuItem item) {
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.preference_menu_option:
|
|
||||||
ActivityHelpers.startPreferences(this);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.onMenuItemSelected(featureId, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
MenuItem prefItem = menu.add(Menu.NONE, R.id.preference_menu_option, Menu.CATEGORY_SYSTEM, R.string.Preferences);
|
|
||||||
prefItem.setIcon(R.drawable.ic_menu_preferences);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
|
|
||||||
package net.sf.openrocket.android.simulation;
|
|
||||||
|
|
||||||
import net.sf.openrocket.R;
|
|
||||||
import net.sf.openrocket.android.Application;
|
|
||||||
import net.sf.openrocket.android.rocket.MotorConfigSpinnerAdapter;
|
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
|
||||||
import net.sf.openrocket.document.Simulation;
|
|
||||||
import net.sf.openrocket.unit.UnitGroup;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.DialogFragment;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.Spinner;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An activity that encapsulates a graphical view of the chart.
|
|
||||||
*/
|
|
||||||
public class SimulationRunFragment extends DialogFragment {
|
|
||||||
|
|
||||||
int simulationId;
|
|
||||||
|
|
||||||
EditText windspeedField;
|
|
||||||
EditText rodlengthField;
|
|
||||||
EditText rodangleField;
|
|
||||||
Spinner motorSpinner;
|
|
||||||
|
|
||||||
public static SimulationRunFragment newInstance( int simulationId ) {
|
|
||||||
SimulationRunFragment frag = new SimulationRunFragment();
|
|
||||||
Bundle b = new Bundle();
|
|
||||||
b.putInt("simulationId", simulationId);
|
|
||||||
frag.setArguments(b);
|
|
||||||
return frag;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setStyle(DialogFragment.STYLE_NO_TITLE,getTheme());
|
|
||||||
|
|
||||||
if ( savedInstanceState != null ) {
|
|
||||||
simulationId = savedInstanceState.getInt("simulationId");
|
|
||||||
} else {
|
|
||||||
Bundle b = getArguments();
|
|
||||||
simulationId = b.getInt("simulationId");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
View v = inflater.inflate(R.layout.simulation_condition_dialog, container, false);
|
|
||||||
windspeedField = (EditText) v.findViewById(R.id.simulation_condition_windspeed);
|
|
||||||
rodlengthField = (EditText) v.findViewById(R.id.simulation_condition_rodlength);
|
|
||||||
rodangleField = (EditText) v.findViewById(R.id.simulation_condition_rodangle);
|
|
||||||
|
|
||||||
motorSpinner = (Spinner) v.findViewById(R.id.simulationConditionConfigurationSpinner);
|
|
||||||
|
|
||||||
OpenRocketDocument rocketDocument = ((Application)getActivity().getApplication()).getRocketDocument();
|
|
||||||
|
|
||||||
Simulation sim = rocketDocument.getSimulation(simulationId);
|
|
||||||
|
|
||||||
windspeedField.setText( UnitGroup.UNITS_VELOCITY.toString(sim.getSimulatedConditions().getWindSpeedAverage()) );
|
|
||||||
rodlengthField.setText( UnitGroup.UNITS_LENGTH.toString(sim.getSimulatedConditions().getLaunchRodLength()));
|
|
||||||
rodangleField.setText( String.valueOf( sim.getSimulatedConditions().getLaunchRodLength() ));
|
|
||||||
|
|
||||||
MotorConfigSpinnerAdapter spinnerAdapter = new MotorConfigSpinnerAdapter(getActivity(),rocketDocument.getRocket());
|
|
||||||
motorSpinner.setAdapter(spinnerAdapter);
|
|
||||||
/* TODO - enable saving.
|
|
||||||
((Button) v.findViewById(R.id.motorDetailsSaveButton)).setOnClickListener(
|
|
||||||
new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
MotorDetailsFragment.this.saveChanges();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
outState.putInt("simulationId", simulationId);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -9,7 +9,11 @@ import android.util.Log;
|
|||||||
|
|
||||||
public class AndroidLogWrapper {
|
public class AndroidLogWrapper {
|
||||||
|
|
||||||
private static final boolean logEnabled = false;
|
private static boolean logEnabled = false;
|
||||||
|
|
||||||
|
public static void setLogEnabled( boolean value ) {
|
||||||
|
logEnabled = value;
|
||||||
|
}
|
||||||
|
|
||||||
public static void d( Class clzz, String msg ) {
|
public static void d( Class clzz, String msg ) {
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package net.sf.openrocket.android.util;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
@ -19,6 +18,8 @@ import android.widget.ListAdapter;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.actionbarsherlock.app.SherlockFragment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Pulled from https://gist.github.com/1316903
|
* Pulled from https://gist.github.com/1316903
|
||||||
@ -30,7 +31,7 @@ import android.widget.TextView;
|
|||||||
*
|
*
|
||||||
* All ASLv2 licensed.
|
* All ASLv2 licensed.
|
||||||
*/
|
*/
|
||||||
public class ExpandableListFragment extends Fragment
|
public class ExpandableListFragment extends SherlockFragment
|
||||||
implements OnCreateContextMenuListener, ExpandableListView.OnChildClickListener,
|
implements OnCreateContextMenuListener, ExpandableListView.OnChildClickListener,
|
||||||
ExpandableListView.OnGroupCollapseListener, ExpandableListView.OnGroupExpandListener
|
ExpandableListView.OnGroupCollapseListener, ExpandableListView.OnGroupExpandListener
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user