Added way to delete motor configurations through long click in the configurations tab.
This commit is contained in:
parent
e73c5500a5
commit
1eb8f3203f
@ -13,6 +13,8 @@
|
|||||||
<string name="configurePlot">Change Plot</string>
|
<string name="configurePlot">Change Plot</string>
|
||||||
<string name="view_events">View Events</string>
|
<string name="view_events">View Events</string>
|
||||||
<string name="simulationPlotDialogTitle">Select Series And Events</string>
|
<string name="simulationPlotDialogTitle">Select Series And Events</string>
|
||||||
|
<string name="DeleteConfigTitle">Delete Motor Configuration</string>
|
||||||
|
|
||||||
<string name="plot">Plot</string>
|
<string name="plot">Plot</string>
|
||||||
<string name="saving">Saving file…</string>
|
<string name="saving">Saving file…</string>
|
||||||
<string name="loading">Loading file…</string>
|
<string name="loading">Loading file…</string>
|
||||||
|
|||||||
@ -95,6 +95,11 @@ public class CurrentRocket {
|
|||||||
return configId;
|
return configId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized void deleteMotorConfig( Context context, String config ) {
|
||||||
|
rocketDocument.getRocket().removeMotorConfigurationID(config);
|
||||||
|
notifyMotorConfigChanged(context);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param rocketDocument the rocketDocument to set
|
* @param rocketDocument the rocketDocument to set
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -24,6 +24,7 @@ public abstract class ChangeEventBroadcastReceiver extends BroadcastReceiver {
|
|||||||
switch( type ) {
|
switch( type ) {
|
||||||
case Events.CONFIGS_CHANGED:
|
case Events.CONFIGS_CHANGED:
|
||||||
doMotorConfigsChanged();
|
doMotorConfigsChanged();
|
||||||
|
doSimsChanged();
|
||||||
break;
|
break;
|
||||||
case Events.SIMS_CHANGED:
|
case Events.SIMS_CHANGED:
|
||||||
doSimsChanged();
|
doSimsChanged();
|
||||||
|
|||||||
@ -15,6 +15,9 @@ import net.sf.openrocket.motor.Motor;
|
|||||||
import net.sf.openrocket.rocketcomponent.MotorMount;
|
import net.sf.openrocket.rocketcomponent.MotorMount;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
import net.sf.openrocket.unit.UnitGroup;
|
import net.sf.openrocket.unit.UnitGroup;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -23,6 +26,7 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.BaseExpandableListAdapter;
|
import android.widget.BaseExpandableListAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ExpandableListAdapter;
|
import android.widget.ExpandableListAdapter;
|
||||||
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.actionbarsherlock.view.Menu;
|
import com.actionbarsherlock.view.Menu;
|
||||||
@ -73,6 +77,10 @@ public class Configurations extends ExpandableListFragment {
|
|||||||
CurrentRocketHolder.getCurrentRocket().addNewMotorConfig(getActivity());
|
CurrentRocketHolder.getCurrentRocket().addNewMotorConfig(getActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeConfiguration( String config ) {
|
||||||
|
CurrentRocketHolder.getCurrentRocket().deleteMotorConfig( getActivity(), config );
|
||||||
|
}
|
||||||
|
|
||||||
private static class MotorMountInfo {
|
private static class MotorMountInfo {
|
||||||
|
|
||||||
private RocketComponent mmt;
|
private RocketComponent mmt;
|
||||||
@ -172,11 +180,11 @@ public class Configurations extends ExpandableListFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getGroupView(int groupPosition, boolean isExpanded,
|
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
|
||||||
View convertView, ViewGroup parent) {
|
|
||||||
if ( convertView == null ) {
|
if ( convertView == null ) {
|
||||||
convertView = getActivity().getLayoutInflater().inflate(android.R.layout.simple_expandable_list_item_1,null);
|
convertView = getActivity().getLayoutInflater().inflate(android.R.layout.simple_expandable_list_item_1,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
String configDescription = rocketDocument.getRocket().getMotorConfigurationNameOrDescription((String) getGroup(groupPosition));
|
String configDescription = rocketDocument.getRocket().getMotorConfigurationNameOrDescription((String) getGroup(groupPosition));
|
||||||
((TextView)convertView.findViewById(android.R.id.text1)).setText( configDescription );
|
((TextView)convertView.findViewById(android.R.id.text1)).setText( configDescription );
|
||||||
return convertView;
|
return convertView;
|
||||||
@ -222,9 +230,7 @@ public class Configurations extends ExpandableListFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChildSelectable(int groupPosition,
|
public boolean isChildSelectable(int groupPosition, int childPosition) {
|
||||||
int childPosition) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,6 +239,34 @@ public class Configurations extends ExpandableListFragment {
|
|||||||
setListAdapter(configurationAdapter);
|
setListAdapter(configurationAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onListItemLongClick(ListView l, View v, int position, long id) {
|
||||||
|
|
||||||
|
Object o = getExpandableListAdapter().getGroup(position);
|
||||||
|
|
||||||
|
if ( o == null || ! (o instanceof String) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final String motorConfigId = (String)o;
|
||||||
|
|
||||||
|
AlertDialog.Builder b = new AlertDialog.Builder( getActivity() );
|
||||||
|
b.setTitle(R.string.DeleteConfigTitle);
|
||||||
|
b.setCancelable(true);
|
||||||
|
b.setPositiveButton(R.string.Delete, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
Configurations.this.removeConfiguration(motorConfigId);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
Dialog dialog = b.create();
|
||||||
|
|
||||||
|
dialog.setCanceledOnTouchOutside(true);
|
||||||
|
dialog.show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private class MotorWizardOnClickListener implements View.OnClickListener {
|
private class MotorWizardOnClickListener implements View.OnClickListener {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|||||||
@ -51,6 +51,14 @@ ExpandableListView.OnGroupCollapseListener, ExpandableListView.OnGroupExpandList
|
|||||||
onListItemClick((ListView) parent, v, position, id);
|
onListItemClick((ListView) parent, v, position, id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
final private AdapterView.OnItemLongClickListener mOnLongClickListener = new AdapterView.OnItemLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
return onListItemLongClick( (ListView) parent, view, position, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
ExpandableListAdapter mAdapter;
|
ExpandableListAdapter mAdapter;
|
||||||
ExpandableListView mList;
|
ExpandableListView mList;
|
||||||
@ -135,6 +143,10 @@ ExpandableListView.OnGroupCollapseListener, ExpandableListView.OnGroupExpandList
|
|||||||
public void onListItemClick(ListView l, View v, int position, long id) {
|
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean onListItemLongClick(ListView l, View v, int position, long id ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/** Provide the cursor for the list view. */
|
/** Provide the cursor for the list view. */
|
||||||
public void setListAdapter(ExpandableListAdapter adapter) {
|
public void setListAdapter(ExpandableListAdapter adapter) {
|
||||||
boolean hadAdapter = mAdapter != null;
|
boolean hadAdapter = mAdapter != null;
|
||||||
@ -283,6 +295,7 @@ ExpandableListView.OnGroupCollapseListener, ExpandableListView.OnGroupExpandList
|
|||||||
}
|
}
|
||||||
mListShown = true;
|
mListShown = true;
|
||||||
mList.setOnItemClickListener(mOnClickListener);
|
mList.setOnItemClickListener(mOnClickListener);
|
||||||
|
mList.setOnItemLongClickListener(mOnLongClickListener);
|
||||||
if (mAdapter != null) {
|
if (mAdapter != null) {
|
||||||
setListAdapter(mAdapter);
|
setListAdapter(mAdapter);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user