Rework the motor browser functionality to make it more tablet friendly.
This commit is contained in:
parent
ad86008f28
commit
3f37586278
@ -72,7 +72,7 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".android.motor.MotorBrowserActivity" />
|
<activity android:name=".android.motor.MotorBrowserActivity" />
|
||||||
<activity android:name=".android.motor.MotorDetailsActivity" />
|
<activity android:name=".android.motor.BurnPlotActivity" />
|
||||||
<activity android:name=".android.thrustcurve.TCQueryActivity" />
|
<activity android:name=".android.thrustcurve.TCQueryActivity" />
|
||||||
<activity android:name=".android.simulation.SimulationViewActivity" />
|
<activity android:name=".android.simulation.SimulationViewActivity" />
|
||||||
<activity android:name=".android.filebrowser.SimpleFileBrowser" />
|
<activity android:name=".android.filebrowser.SimpleFileBrowser" />
|
||||||
|
20
android/res/layout-xlarge-land/motorbrowser.xml
Normal file
20
android/res/layout-xlarge-land/motorbrowser.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/motorBrowserList"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="4"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/sidepane"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
20
android/res/layout-xlarge-port/motorbrowser.xml
Normal file
20
android/res/layout-xlarge-port/motorbrowser.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/motorBrowserList"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="3" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/sidepane"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -1,39 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical" >
|
|
||||||
|
|
||||||
<fragment
|
|
||||||
android:id="@+id/burnPlotFragment"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:layout_marginLeft="0px"
|
|
||||||
android:layout_marginRight="0px"
|
|
||||||
android:layout_marginTop="5px"
|
|
||||||
class="net.sf.openrocket.android.motor.BurnPlotFragment"
|
|
||||||
title="Burn Plot" />
|
|
||||||
|
|
||||||
<SlidingDrawer
|
|
||||||
android:id="@+id/drawer"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="0.4"
|
|
||||||
android:content="@+id/motorDetailForm"
|
|
||||||
android:handle="@+id/handle" >
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/handle"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="30px"
|
|
||||||
android:src="@drawable/arrow_up_float"
|
|
||||||
android:text="" />
|
|
||||||
|
|
||||||
<fragment
|
|
||||||
android:id="@+id/motorDetailForm"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
class="net.sf.openrocket.android.motor.MotorDetailsFragment" />
|
|
||||||
</SlidingDrawer>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
@ -1,108 +1,125 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
android:id="@+id/motorDetailForm"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="@android:color/black"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:paddingTop="10px" >
|
|
||||||
|
|
||||||
<TableRow >
|
<TableLayout
|
||||||
|
android:id="@+id/motorDetailForm"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@android:color/black"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingTop="10dp" >
|
||||||
|
|
||||||
<TextView
|
<TableRow>
|
||||||
android:paddingRight="10px"
|
|
||||||
android:text="Manufacturer" />
|
|
||||||
|
|
||||||
<EditText
|
<TextView
|
||||||
android:id="@+id/motorDetailsManufacturer"
|
android:paddingRight="10dp"
|
||||||
android:layout_width="match_parent"
|
android:text="Manufacturer" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/motorDetailsManufacturer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.04"
|
||||||
|
android:editable="false"
|
||||||
|
android:inputType="text" />
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:paddingRight="10dp"
|
||||||
|
android:text="Name" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/motorDetailsName"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.04"
|
||||||
|
android:editable="false"
|
||||||
|
android:inputType="text" />
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:paddingRight="10dp"
|
||||||
|
android:text="Delays" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/motorDetailsDelays"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.04"
|
||||||
|
android:editable="false"
|
||||||
|
android:inputType="number" />
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:paddingRight="10dp"
|
||||||
|
android:text="Case Info" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/motorDetailsCaseInfo"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.04"
|
||||||
|
android:editable="false"
|
||||||
|
android:inputType="text" />
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:paddingRight="10dp"
|
||||||
|
android:text="Impulse Class" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/motorDetailsImpuseClass"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.04"
|
||||||
|
android:editable="false"
|
||||||
|
android:inputType="text" />
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:paddingRight="10dp"
|
||||||
|
android:text="Diameter" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/motorDetailsDiameter"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.04"
|
||||||
|
android:editable="false"
|
||||||
|
android:inputType="text" />
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:paddingRight="10dp"
|
||||||
|
android:text="Length" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/motorDetailsLength"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.04"
|
||||||
|
android:editable="false"
|
||||||
|
android:inputType="text" />
|
||||||
|
</TableRow>
|
||||||
|
</TableLayout>
|
||||||
|
<!--
|
||||||
|
<Button
|
||||||
|
android:id="@+id/motorDetailsSaveButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="0.04"
|
android:text="@string/save" />
|
||||||
android:editable="false" />
|
-->
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
<TableRow >
|
</ScrollView>
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:paddingRight="10px"
|
|
||||||
android:text="Name" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/motorDetailsName"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.04"
|
|
||||||
android:editable="false" />
|
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
<TableRow >
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:paddingRight="10px"
|
|
||||||
android:text="Delays" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/motorDetailsDelays"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.04"
|
|
||||||
android:editable="false" />
|
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
<TableRow >
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:paddingRight="10px"
|
|
||||||
android:text="Case Info" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/motorDetailsCaseInfo"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.04"
|
|
||||||
android:editable="false" />
|
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
<TableRow >
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:paddingRight="10px"
|
|
||||||
android:text="Impulse Class" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/motorDetailsImpuseClass"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.04"
|
|
||||||
android:editable="false" />
|
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
<TableRow >
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:paddingRight="10px"
|
|
||||||
android:text="Diameter" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/motorDetailsDiameter"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.04"
|
|
||||||
android:editable="false" />
|
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
<TableRow >
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:paddingRight="10px"
|
|
||||||
android:text="Length" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/motorDetailsLength"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.04"
|
|
||||||
android:editable="false" />
|
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
</TableLayout>
|
|
12
android/res/layout/motorbrowser.xml
Normal file
12
android/res/layout/motorbrowser.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/motorBrowserList"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<menu
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<item android:enabled="true" android:id="@+id/save" android:visible="true" android:title="@string/save"/>
|
|
||||||
|
|
||||||
</menu>
|
|
@ -0,0 +1,23 @@
|
|||||||
|
package net.sf.openrocket.android.motor;
|
||||||
|
|
||||||
|
import net.sf.openrocket.android.util.AndroidLogWrapper;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
|
||||||
|
public class BurnPlotActivity extends FragmentActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
AndroidLogWrapper.d(BurnPlotActivity.class,"onCreate Bundle = "+ String.valueOf(savedInstanceState));
|
||||||
|
|
||||||
|
Intent i = getIntent();
|
||||||
|
long motorId = i.getLongExtra("Motor",-1);
|
||||||
|
|
||||||
|
BurnPlotFragment burnPlot = BurnPlotFragment.newInstance(motorId);
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(android.R.id.content, burnPlot).commit();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import net.sf.openrocket.R;
|
import net.sf.openrocket.R;
|
||||||
|
import net.sf.openrocket.android.db.DbAdapter;
|
||||||
import net.sf.openrocket.android.util.AndroidLogWrapper;
|
import net.sf.openrocket.android.util.AndroidLogWrapper;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
@ -27,6 +28,7 @@ import com.androidplot.xy.YValueMarker;
|
|||||||
public class BurnPlotFragment extends Fragment implements OnTouchListener {
|
public class BurnPlotFragment extends Fragment implements OnTouchListener {
|
||||||
|
|
||||||
private ExtendedThrustCurveMotor motor;
|
private ExtendedThrustCurveMotor motor;
|
||||||
|
private long motorId;
|
||||||
|
|
||||||
private XYPlot mySimpleXYPlot;
|
private XYPlot mySimpleXYPlot;
|
||||||
private SimpleXYSeries mySeries;
|
private SimpleXYSeries mySeries;
|
||||||
@ -39,12 +41,44 @@ public class BurnPlotFragment extends Fragment implements OnTouchListener {
|
|||||||
private ScaleGestureDetector mScaleDetector;
|
private ScaleGestureDetector mScaleDetector;
|
||||||
private float mScaleFactor = 1.f;
|
private float mScaleFactor = 1.f;
|
||||||
|
|
||||||
|
public static BurnPlotFragment newInstance( long motorId ) {
|
||||||
|
BurnPlotFragment frag = new BurnPlotFragment();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong("motorId", motorId);
|
||||||
|
frag.setArguments(bundle);
|
||||||
|
return frag;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
AndroidLogWrapper.d(BurnPlotFragment.class,"onCreate");
|
AndroidLogWrapper.d(BurnPlotFragment.class,"onCreate");
|
||||||
|
|
||||||
|
if ( savedInstanceState!= null) {
|
||||||
|
motorId = savedInstanceState.getLong("motorId",-1);
|
||||||
|
} else {
|
||||||
|
Bundle b = getArguments();
|
||||||
|
motorId = b.getLong("motorId");
|
||||||
|
}
|
||||||
|
|
||||||
|
DbAdapter mDbHelper = new DbAdapter(getActivity());
|
||||||
|
mDbHelper.open();
|
||||||
|
|
||||||
|
try {
|
||||||
|
motor = mDbHelper.getMotorDao().fetchMotor(motorId);
|
||||||
|
} catch ( Exception e ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
mDbHelper.close();
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putLong("motorId", motorId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
@ -53,6 +87,7 @@ public class BurnPlotFragment extends Fragment implements OnTouchListener {
|
|||||||
mySimpleXYPlot = (XYPlot) v.findViewById(R.id.xyplot);
|
mySimpleXYPlot = (XYPlot) v.findViewById(R.id.xyplot);
|
||||||
mySimpleXYPlot.setOnTouchListener(this);
|
mySimpleXYPlot.setOnTouchListener(this);
|
||||||
mScaleDetector = new ScaleGestureDetector(v.getContext(), new ScaleListener());
|
mScaleDetector = new ScaleGestureDetector(v.getContext(), new ScaleListener());
|
||||||
|
init(motor);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +98,8 @@ public class BurnPlotFragment extends Fragment implements OnTouchListener {
|
|||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
void init( ExtendedThrustCurveMotor motor ) {
|
|
||||||
|
private void init( ExtendedThrustCurveMotor motor ) {
|
||||||
|
|
||||||
mySimpleXYPlot.setUserDomainOrigin(0);
|
mySimpleXYPlot.setUserDomainOrigin(0);
|
||||||
mySimpleXYPlot.setUserRangeOrigin(0);
|
mySimpleXYPlot.setUserRangeOrigin(0);
|
||||||
|
@ -6,6 +6,7 @@ import net.sf.openrocket.android.PreferencesActivity;
|
|||||||
import net.sf.openrocket.android.util.AndroidLogWrapper;
|
import net.sf.openrocket.android.util.AndroidLogWrapper;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@ -23,13 +24,8 @@ implements MotorListFragment.OnMotorSelectedListener
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.motorbrowser);
|
||||||
if (getSupportFragmentManager().findFragmentById(android.R.id.content) == null) {
|
getSupportFragmentManager().beginTransaction().add( R.id.motorBrowserList, new MotorListFragment()).commit();
|
||||||
motorList = MotorListFragment.newInstance();
|
|
||||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
|
||||||
ft.add(android.R.id.content, motorList);
|
|
||||||
ft.commit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -59,23 +55,19 @@ implements MotorListFragment.OnMotorSelectedListener
|
|||||||
|
|
||||||
View sidepane = findViewById(R.id.sidepane);
|
View sidepane = findViewById(R.id.sidepane);
|
||||||
if ( /* if multi pane */ sidepane != null ) {
|
if ( /* if multi pane */ sidepane != null ) {
|
||||||
/*
|
|
||||||
Simulation sim = app.getRocketDocument().getSimulation(simulationId);
|
|
||||||
SimulationChart chart = new SimulationChart(simulationId);
|
|
||||||
|
|
||||||
Fragment graph = SimulationFragment.newInstance(chart);
|
Fragment graph = BurnPlotFragment.newInstance(motorId);
|
||||||
|
|
||||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||||
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
|
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
|
||||||
// probably only want to update back stack for first time.
|
// probably only want to update back stack for first time.
|
||||||
ft.addToBackStack("simulationplot");
|
ft.addToBackStack("burnplot");
|
||||||
ft.replace(R.id.sidepane, graph);
|
ft.replace(R.id.sidepane, graph);
|
||||||
ft.show(graph);
|
ft.show(graph);
|
||||||
ft.commit();
|
ft.commit();
|
||||||
*/
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Intent i = new Intent(this,MotorDetailsActivity.class);
|
Intent i = new Intent(this,BurnPlotActivity.class);
|
||||||
i.putExtra("Motor", motorId);
|
i.putExtra("Motor", motorId);
|
||||||
startActivity(i);
|
startActivity(i);
|
||||||
}
|
}
|
||||||
|
@ -1,87 +0,0 @@
|
|||||||
package net.sf.openrocket.android.motor;
|
|
||||||
|
|
||||||
import net.sf.openrocket.R;
|
|
||||||
import net.sf.openrocket.android.db.DbAdapter;
|
|
||||||
import net.sf.openrocket.android.util.AndroidLogWrapper;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.FragmentActivity;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.SlidingDrawer;
|
|
||||||
|
|
||||||
public class MotorDetailsActivity extends FragmentActivity
|
|
||||||
implements SlidingDrawer.OnDrawerCloseListener, SlidingDrawer.OnDrawerOpenListener {
|
|
||||||
|
|
||||||
private SlidingDrawer slidingDrawer;
|
|
||||||
private ImageView handle;
|
|
||||||
|
|
||||||
private ExtendedThrustCurveMotor motor;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
AndroidLogWrapper.d(MotorDetailsActivity.class,"onCreate Bundle = "+ String.valueOf(savedInstanceState));
|
|
||||||
setContentView(R.layout.motor_detail);
|
|
||||||
|
|
||||||
Intent i = getIntent();
|
|
||||||
long motorId = i.getLongExtra("Motor",-1);
|
|
||||||
|
|
||||||
DbAdapter mDbHelper = new DbAdapter(this);
|
|
||||||
mDbHelper.open();
|
|
||||||
|
|
||||||
try {
|
|
||||||
motor = mDbHelper.getMotorDao().fetchMotor(motorId);
|
|
||||||
} catch ( Exception e ) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
mDbHelper.close();
|
|
||||||
|
|
||||||
BurnPlotFragment burnPlot = (BurnPlotFragment) getSupportFragmentManager().findFragmentById(R.id.burnPlotFragment);
|
|
||||||
burnPlot.init(motor);
|
|
||||||
|
|
||||||
MotorDetailsFragment motorDetails = (MotorDetailsFragment) getSupportFragmentManager().findFragmentById(R.id.motorDetailForm);
|
|
||||||
motorDetails.init(motor);
|
|
||||||
|
|
||||||
slidingDrawer = (SlidingDrawer) findViewById(R.id.drawer);
|
|
||||||
|
|
||||||
slidingDrawer.setOnDrawerOpenListener(this);
|
|
||||||
slidingDrawer.setOnDrawerCloseListener(this);
|
|
||||||
|
|
||||||
handle = (ImageView) findViewById(R.id.handle);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDrawerOpened() {
|
|
||||||
handle.setImageResource(R.drawable.arrow_down_float);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDrawerClosed() {
|
|
||||||
handle.setImageResource(R.drawable.arrow_up_float);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
MenuInflater inflater = getMenuInflater();
|
|
||||||
inflater.inflate(R.menu.motor_details_option_menu, menu);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onMenuItemSelected(int featureId, MenuItem item) {
|
|
||||||
switch(item.getItemId()) {
|
|
||||||
case R.id.save:
|
|
||||||
// Extract form data to Motor.
|
|
||||||
// Save motor.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.onMenuItemSelected(featureId, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -2,15 +2,17 @@ package net.sf.openrocket.android.motor;
|
|||||||
|
|
||||||
import net.sf.openrocket.R;
|
import net.sf.openrocket.R;
|
||||||
import net.sf.openrocket.android.db.ConversionUtils;
|
import net.sf.openrocket.android.db.ConversionUtils;
|
||||||
|
import net.sf.openrocket.android.db.DbAdapter;
|
||||||
import net.sf.openrocket.motor.ThrustCurveMotor;
|
import net.sf.openrocket.motor.ThrustCurveMotor;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
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.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
public class MotorDetailsFragment extends Fragment {
|
public class MotorDetailsFragment extends DialogFragment {
|
||||||
|
|
||||||
EditText manuField;
|
EditText manuField;
|
||||||
EditText nameField;
|
EditText nameField;
|
||||||
@ -20,6 +22,43 @@ public class MotorDetailsFragment extends Fragment {
|
|||||||
EditText diameterField;
|
EditText diameterField;
|
||||||
EditText lengthField;
|
EditText lengthField;
|
||||||
|
|
||||||
|
ExtendedThrustCurveMotor motor;
|
||||||
|
|
||||||
|
public static MotorDetailsFragment newInstance( long motorId ) {
|
||||||
|
MotorDetailsFragment fragment = new MotorDetailsFragment();
|
||||||
|
Bundle b = new Bundle();
|
||||||
|
b.putLong("motorId", motorId);
|
||||||
|
fragment.setArguments(b);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setStyle(DialogFragment.STYLE_NO_TITLE,getTheme());
|
||||||
|
|
||||||
|
Long motorId;
|
||||||
|
if ( savedInstanceState != null ) {
|
||||||
|
motorId = savedInstanceState.getLong("motorId");
|
||||||
|
} else {
|
||||||
|
Bundle b = getArguments();
|
||||||
|
motorId = b.getLong("motorId");
|
||||||
|
}
|
||||||
|
DbAdapter mDbHelper = new DbAdapter(getActivity());
|
||||||
|
mDbHelper.open();
|
||||||
|
try {
|
||||||
|
motor = mDbHelper.getMotorDao().fetchMotor(motorId);
|
||||||
|
} catch ( Exception e ) {
|
||||||
|
}
|
||||||
|
mDbHelper.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle arg0) {
|
||||||
|
super.onSaveInstanceState(arg0);
|
||||||
|
arg0.putLong("motorId", motor.getId());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
@ -31,19 +70,37 @@ public class MotorDetailsFragment extends Fragment {
|
|||||||
impulseClassField = (EditText) v.findViewById(R.id.motorDetailsImpuseClass);
|
impulseClassField = (EditText) v.findViewById(R.id.motorDetailsImpuseClass);
|
||||||
diameterField = (EditText) v.findViewById(R.id.motorDetailsDiameter);
|
diameterField = (EditText) v.findViewById(R.id.motorDetailsDiameter);
|
||||||
lengthField = (EditText) v.findViewById(R.id.motorDetailsLength);
|
lengthField = (EditText) v.findViewById(R.id.motorDetailsLength);
|
||||||
|
init();
|
||||||
|
/* TODO - enable saving.
|
||||||
|
((Button) v.findViewById(R.id.motorDetailsSaveButton)).setOnClickListener(
|
||||||
|
new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
MotorDetailsFragment.this.saveChanges();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
*/
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init( ExtendedThrustCurveMotor m ) {
|
private void init( ) {
|
||||||
ThrustCurveMotor tcm = m.getThrustCurveMotor();
|
ThrustCurveMotor tcm = motor.getThrustCurveMotor();
|
||||||
manuField.setText( tcm.getManufacturer().getDisplayName());
|
manuField.setText( tcm.getManufacturer().getDisplayName());
|
||||||
nameField.setText( tcm.getDesignation() );
|
nameField.setText( tcm.getDesignation() );
|
||||||
delaysField.setText( ConversionUtils.delaysToString(tcm.getStandardDelays()) );
|
delaysField.setText( ConversionUtils.delaysToString(tcm.getStandardDelays()) );
|
||||||
caseField.setText( m.getCaseInfo());
|
caseField.setText( motor.getCaseInfo());
|
||||||
impulseClassField.setText( m.getImpulseClass());
|
impulseClassField.setText( motor.getImpulseClass());
|
||||||
diameterField.setText( String.valueOf(tcm.getDiameter()*1000.0) );
|
diameterField.setText( String.valueOf(tcm.getDiameter()*1000.0) );
|
||||||
lengthField.setText( String.valueOf(tcm.getLength()*1000.0) );
|
lengthField.setText( String.valueOf(tcm.getLength()*1000.0) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void saveChanges() {
|
||||||
|
DbAdapter mDbHelper = new DbAdapter(getActivity());
|
||||||
|
mDbHelper.open();
|
||||||
|
try {
|
||||||
|
mDbHelper.getMotorDao().insertOrUpdateMotor(motor);
|
||||||
|
} catch ( Exception e ) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,9 @@ import android.content.res.Resources;
|
|||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@ -35,12 +38,12 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static MotorListFragment newInstance( ) {
|
public static MotorListFragment newInstance( ) {
|
||||||
|
|
||||||
MotorListFragment frag = new MotorListFragment();
|
MotorListFragment frag = new MotorListFragment();
|
||||||
return frag;
|
return frag;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int CONTEXTMENU_DELETE = Menu.FIRST+1;
|
private static final int CONTEXTMENU_DELETE = Menu.FIRST+1;
|
||||||
|
private static final int CONTEXTMENU_EDIT = Menu.FIRST+2;
|
||||||
|
|
||||||
private String groupColumnPreferenceKey;
|
private String groupColumnPreferenceKey;
|
||||||
private String groupColumn = MotorDao.CASE_INFO;
|
private String groupColumn = MotorDao.CASE_INFO;
|
||||||
@ -165,6 +168,7 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
|||||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||||
menu.setHeaderTitle("Motor Operations");
|
menu.setHeaderTitle("Motor Operations");
|
||||||
menu.add(Menu.NONE,CONTEXTMENU_DELETE,CONTEXTMENU_DELETE,"Delete");
|
menu.add(Menu.NONE,CONTEXTMENU_DELETE,CONTEXTMENU_DELETE,"Delete");
|
||||||
|
menu.add(Menu.NONE,CONTEXTMENU_EDIT,CONTEXTMENU_EDIT,"Edit");
|
||||||
super.onCreateContextMenu(menu, v, menuInfo);
|
super.onCreateContextMenu(menu, v, menuInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,6 +182,21 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
|||||||
mDbHelper.getMotorDao().deleteMotor(motorId);
|
mDbHelper.getMotorDao().deleteMotor(motorId);
|
||||||
refreshData();
|
refreshData();
|
||||||
return true;
|
return true;
|
||||||
|
case CONTEXTMENU_EDIT:
|
||||||
|
// DialogFragment.show() will take care of adding the fragment
|
||||||
|
// in a transaction. We also want to remove any currently showing
|
||||||
|
// dialog, so make our own transaction and take care of that here.
|
||||||
|
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||||
|
Fragment prev = getFragmentManager().findFragmentByTag("dialog");
|
||||||
|
if (prev != null) {
|
||||||
|
ft.remove(prev);
|
||||||
|
}
|
||||||
|
ft.addToBackStack(null);
|
||||||
|
|
||||||
|
// Create and show the dialog.
|
||||||
|
DialogFragment newFragment = MotorDetailsFragment.newInstance(motorId);
|
||||||
|
newFragment.show(ft, "dialog");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return super.onContextItemSelected(item);
|
return super.onContextItemSelected(item);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user