Skip to content
Snippets Groups Projects
Commit 73aa5e91 authored by Maxime Graulich's avatar Maxime Graulich
Browse files

Android: add post-processing options

parent fdde3f63
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/model_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp" />
\ No newline at end of file
<?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"
android:padding="15dp" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Intervals type" />
<Spinner
android:id="@+id/intervals_type"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Intervals" />
<EditText
android:id="@+id/intervals"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:digits="0123456789" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Raise (Z)" />
<SeekBar
android:id="@+id/raisez"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="1" />
</LinearLayout>
\ No newline at end of file
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
android:paddingBottom="10dp" /> android:paddingBottom="10dp" />
<LinearLayout <LinearLayout
android:layout_gravity="center_horizontal"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
......
...@@ -104,7 +104,7 @@ public class Gmsh implements Parcelable { ...@@ -104,7 +104,7 @@ public class Gmsh implements Parcelable {
public void writeToParcel(Parcel out, int flags) { public void writeToParcel(Parcel out, int flags) {
out.writeLong(this.ptr); out.writeLong(this.ptr);
} }
public Parcelable.Creator<Gmsh> CREATOR = new Parcelable.Creator<Gmsh>() { public static Parcelable.Creator<Gmsh> CREATOR = new Parcelable.Creator<Gmsh>() {
public Gmsh createFromParcel(Parcel source) { public Gmsh createFromParcel(Parcel source) {
return new Gmsh(source); return new Gmsh(source);
......
...@@ -188,6 +188,7 @@ public class ModelList extends Activity { ...@@ -188,6 +188,7 @@ public class ModelList extends Activity {
skipTag(parser); skipTag(parser);
} }
} }
if(title == null || file == null) return;
Model newModel = new Model(title, summary, new File(dir+"/"+file)); Model newModel = new Model(title, summary, new File(dir+"/"+file));
if(bitmap != null) newModel.setBitmap(new File(dir+"/"+bitmap)); if(bitmap != null) newModel.setBitmap(new File(dir+"/"+bitmap));
if(url != null) newModel.setUrl(Uri.parse(url)); if(url != null) newModel.setUrl(Uri.parse(url));
......
package org.geuz.onelab; package org.geuz.onelab;
import android.os.Bundle; import android.os.Bundle;
import android.os.Parcelable;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment; import android.app.Fragment;
import android.content.Intent;
import android.graphics.Color;
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.view.ViewGroup.LayoutParams;
import android.widget.AbsListView;
import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.LinearLayout;
public class OptionsDisplayFragment extends Fragment{ public class OptionsDisplayFragment extends Fragment{
...@@ -33,7 +40,7 @@ public class OptionsDisplayFragment extends Fragment{ ...@@ -33,7 +40,7 @@ public class OptionsDisplayFragment extends Fragment{
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, final ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
_listView = (SeparatedListView)inflater.inflate(R.layout.fragment_options_display, container, false); _listView = (SeparatedListView)inflater.inflate(R.layout.fragment_options_display, container, false);
CheckBox showGeomPoints = new CheckBox(_listView.getContext()); CheckBox showGeomPoints = new CheckBox(_listView.getContext());
...@@ -90,7 +97,9 @@ public class OptionsDisplayFragment extends Fragment{ ...@@ -90,7 +97,9 @@ public class OptionsDisplayFragment extends Fragment{
for(int i=_listView.itemsCountInSection("Result"); i < PViews.length;i++){ for(int i=_listView.itemsCountInSection("Result"); i < PViews.length;i++){
String[] infos = PViews[i].split("\n"); // name / IntervalsType (1=Iso 2=Continous 3=Discrete 4=Numeric) String[] infos = PViews[i].split("\n"); // name / IntervalsType (1=Iso 2=Continous 3=Discrete 4=Numeric)
final int myID = i; final int myID = i;
LinearLayout layout = new LinearLayout(_listView.getContext());
CheckBox checkbox = new CheckBox(_listView.getContext()); CheckBox checkbox = new CheckBox(_listView.getContext());
checkbox.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
checkbox.setText(infos[0]); checkbox.setText(infos[0]);
checkbox.setChecked(infos[2].equals("1")); checkbox.setChecked(infos[2].equals("1"));
checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
...@@ -100,7 +109,21 @@ public class OptionsDisplayFragment extends Fragment{ ...@@ -100,7 +109,21 @@ public class OptionsDisplayFragment extends Fragment{
mCallback.onRequestRender(); mCallback.onRequestRender();
} }
}); });
_listView.addItem("Result", checkbox); Button button = new Button(_listView.getContext());
button.setText("More options");
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(getActivity(), PostProcessingActivity.class);
intent.putExtra("Gmsh", (Parcelable)_gmsh);
intent.putExtra("PView", myID);
startActivity(intent);
}
});
button.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
button.setBackgroundColor(Color.TRANSPARENT);
layout.addView(checkbox);
layout.addView(button);
_listView.addItem("Result", layout);
} }
} }
......
package org.geuz.onelab;
import java.util.ArrayList;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.Spinner;
public class OptionsPostProcessingFragment extends Fragment{
private Gmsh _gmsh;
private int _pview;
public static OptionsPostProcessingFragment newInstance(Gmsh g, int p) {
OptionsPostProcessingFragment fragment = new OptionsPostProcessingFragment();
Bundle bundle = new Bundle();
bundle.putParcelable("Gmsh", g);
bundle.putInt("PView", p);
fragment.setArguments(bundle);
return fragment;
}
private OptionsPostProcessingFragment() {
super();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
_gmsh = getArguments().getParcelable("Gmsh");
_pview = getArguments().getInt("PView");
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
String[] PViews = _gmsh.getPView();
String[] infos = PViews[_pview].split("\n");
getActivity().getActionBar().setTitle(infos[0]);
LinearLayout layout = (LinearLayout)inflater.inflate(R.layout.fragment_postprocessing, container, false);
final Spinner intervalsType = (Spinner)layout.findViewById(R.id.intervals_type);
final EditText intervals = (EditText)layout.findViewById(R.id.intervals);
final SeekBar raiseZ = (SeekBar)layout.findViewById(R.id.raisez);
intervalsType.setEnabled(infos[2].equals("1"));
ArrayList<String> choices;
ArrayAdapter<String> adapter;
choices = new ArrayList<String>();
choices.add("Iso-values");
choices.add("Continous map");
choices.add("Filled iso-values");
adapter = new ArrayAdapter<String>(container.getContext(), android.R.layout.simple_spinner_dropdown_item, choices);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
intervalsType.setAdapter(adapter);
intervalsType.setSelection(Integer.parseInt(infos[1])-1);
intervalsType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
_gmsh.setPView(_pview, pos+1, -1, -1);
//TODO glView.requestRender();
intervals.setEnabled(pos == 0 || pos == 2);
}
public void onNothingSelected(AdapterView<?> arg0) {} // Unused Auto-generated method stub
});
intervals.setText(infos[3]);
intervals.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_ENTER){ // hide the keyboard
InputMethodManager imm = (InputMethodManager)intervals.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(intervals.getWindowToken(), 0);
return true;
}
return false;
}
});
intervals.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) {
int nIso = 1;
try {
if(s.length() < 1) nIso = 1;
else nIso = Integer.parseInt(s.toString());
}
catch(NumberFormatException e)
{
nIso = 1;
intervals.setText("");
}
if(nIso > 1000) {_gmsh.setPView(_pview, -1, -1, 1000); intervals.setText("1000");}
else if(nIso > 0) _gmsh.setPView(_pview, -1, -1, nIso);
else _gmsh.setPView(_pview, -1, -1, 1);
//glView.requestRender();
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {} // UNUSED Auto-generated method stub
public void afterTextChanged(Editable s) {} // UNUSED Auto-generated method stub
});
return layout;
}
}
package org.geuz.onelab;
import android.app.Activity;
import android.os.Bundle;
public class PostProcessingActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fragment);
Bundle extra = getIntent().getExtras();
int id = extra.getInt("PView", 0);
Gmsh gmsh = extra.getParcelable("Gmsh");
getActionBar().setDisplayHomeAsUpEnabled(true);
OptionsPostProcessingFragment optionsFragment = OptionsPostProcessingFragment.newInstance(gmsh, id);
getFragmentManager().beginTransaction().add(R.id.model_fragment, optionsFragment).commit();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment