diff --git a/contrib/mobile/Android/res/raw/test_geo b/contrib/mobile/Android/res/raw/test_geo deleted file mode 100644 index d60f76efbbb2752e474780b386bfd5adb7660f25..0000000000000000000000000000000000000000 --- a/contrib/mobile/Android/res/raw/test_geo +++ /dev/null @@ -1,64 +0,0 @@ -Point(1) = {0,0,0}; - -DefineConstant -[ - n0 = {3, - Label "Number", - Path "Test widgets/Numbers"} - n01 = {3, Min 1, Max 4, Step 1, - Label "Number (with range)", - Path "Test widgets/Numbers"} - n1 = {3, ReadOnly 1, - Label "Number (read only)", - Path "Test widgets/Numbers"} - n12 = {3, ReadOnlyRange 1, Min 1, Max 4, Step 1, - Label "Number (read only range)", - Path "Test widgets/Numbers"} - n2 = {3, Choices{1, 2, 3, 4}, - Label "Number (with choices)", - Path "Test widgets/Numbers"} - n3 = {1, Choices{0,1}, - Label "Number (with binary choice) - Show String Options?", - Path "Test widgets/Numbers"}, - n4 = {3, Choices{1 = "One", - 2 = "Two", - 3 = "Three", - 4 = "Go!!"}, - Label "Number (with enumeration)", - Path "Test widgets/Numbers"} -]; - -Printf("N3 = %g", n3); - -If(n3) // test define/undefine -Printf("N3 IS SET"); -DefineConstant[ - s0 = {"a", - Label "String", - Path "Test widgets/Strings"} - s1 = {"a", ReadOnly 1, - Label "String (read only)", - Path "Test widgets/Strings"} - s2 = {"a", Choices {"a","b","c"}, - Label "String with choices", - Path "Test widgets/Strings"} - s20 = {"a, c", Choices {"a","b","c"}, MultipleSelection "101", - Label "String with multiple selection", - Path "Test widgets/Strings"} - s3 = {"a.txt", Choices{"a.txt","b.txt","c.txt"}, Kind "file", - Label "File", - Path "Test widgets/Strings"} - s4 = {"a.txt", Kind "file", Macro "Gmsh", - Label "Macro", - Path "Test widgets/Strings"} -]; -EndIf -If(!n3) - Printf("N3 IS **NOT** SET"); -UndefineConstant[ "Test widgets/Strings/s0", - "Test widgets/Strings/s1", - "Test widgets/Strings/s2", - "Test widgets/Strings/s20", - "Test widgets/Strings/s3", - "Test widgets/Strings/s4"]; -EndIf diff --git a/contrib/mobile/Android/res/xml/models.xml b/contrib/mobile/Android/res/xml/models.xml index 80b25aa292b832a095e3c84fe5642701a5ab489b..6f6dcd891a657fe73cfea0671cb6f0d21f65549b 100644 --- a/contrib/mobile/Android/res/xml/models.xml +++ b/contrib/mobile/Android/res/xml/models.xml @@ -12,10 +12,4 @@ <summary></summary> <file type="geo">pmsm.geo</file> </model> - - <model> - <title>Test</title> - <summary>test all parameters of onelab</summary> - <file type="geo">test.geo</file> - </model> </models> diff --git a/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java b/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java index b29bde9d8dc7555143fa4c1d2f6f9515579c2f09..6d135e8742b492196278c9dc4becba0e5d5b2443 100644 --- a/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java +++ b/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java @@ -1,11 +1,8 @@ package org.geuz.onelab; import java.io.File; -import java.io.FileOutputStream; import java.io.FilenameFilter; import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; @@ -17,6 +14,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Environment; import android.os.Handler; +import android.os.Vibrator; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; @@ -29,10 +27,12 @@ import android.content.Intent; import android.content.res.Configuration; import android.content.res.XmlResourceParser; import android.graphics.Color; +import android.graphics.Point; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.text.Editable; import android.text.TextWatcher; +import android.util.DisplayMetrics; import android.util.Log; import android.view.MenuItem; import android.view.MotionEvent; @@ -99,7 +99,6 @@ public class MainActivity extends Activity { gmsh = new Gmsh("", mainHandler); modelList = new Models(); getModels(); - loadNative(); if(intent != null && intent.getAction() != null && intent.getAction().equals(Intent.ACTION_VIEW)) { String tmp = intent.getData().getPath(); pager.setCurrentItem(1); @@ -113,11 +112,27 @@ public class MainActivity extends Activity { setContentView(layout); } + public double screenInch() + { + String inputSystem; + inputSystem = android.os.Build.ID; + Log.d("hai",inputSystem); + Point size = new Point(); + getWindowManager().getDefaultDisplay().getSize(size); + int width = size.x; + int height = size.y; + DisplayMetrics dm = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(dm); + double x = Math.pow(width/dm.xdpi,2); + double y = Math.pow(height/dm.ydpi,2); + return Math.sqrt(x+y); + } + @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuItem listitem = menu.add(Menu.NONE, Menu.NONE, Menu.NONE, R.string.menu_list); - if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) + if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || screenInch() < 7) { MenuItem paramitem = menu.add(Menu.NONE, Menu.NONE, Menu.NONE, R.string.menu_settings); paramitem.setIcon(R.drawable.ic_settings); @@ -188,7 +203,6 @@ public class MainActivity extends Activity { @Override public boolean onInterceptTouchEvent(MotionEvent arg0) { return false; - //return super.onInterceptTouchEvent(arg0); } } @@ -235,32 +249,21 @@ public class MainActivity extends Activity { @Override public float getPageWidth(int position) { - getResources().getConfiguration(); if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { + if(screenInch() < 7) + return 1f; switch (position) { case 1: - if((MainActivity.this).getWindowManager().getDefaultDisplay().getWidth() < 500 ) - return 1f; return 0.25f; case 2: - if((MainActivity.this).getWindowManager().getDefaultDisplay().getWidth() < 500 ) - return 1f; return 0.75f; default: return 1f; } } - switch (position) { - case 1: - if((MainActivity.this).getWindowManager().getDefaultDisplay().getWidth() < 500 ) - return 1f; - return 0.5f; - case 2: - return 1f; - default: - return 1f; - } + + return 1f; } @Override @@ -352,42 +355,6 @@ public class MainActivity extends Activity { } - /** - * Load file from res/raw/ directory to the files directory of the application. - */ - private void loadNative() - { - for( Field f : R.raw.class.getFields()) { - try { - int Msh = f.getInt(null), i; - String androidName = getResources().getResourceEntryName(Msh); - StringBuilder tmp = new StringBuilder(androidName); - tmp.setCharAt(androidName.lastIndexOf('_'), '.'); - String nativeName = tmp.toString(); - //String nativeExtension = nativeName.substring(nativeName.lastIndexOf('.')); - /*if(new File(getFilesDir().toString()+"/"+nativeName).exists()){ - //TODO check if the files are the same - continue; - }*/ - InputStream mshFile = getResources().openRawResource(Msh); - - FileOutputStream outputStream = openFileOutput(nativeName, Context.MODE_WORLD_READABLE); - byte[] buffer = new byte[2048]; - - while ((i = mshFile.read(buffer, 0, buffer.length)) > 0) - outputStream.write(buffer,0,i); - - } catch (IllegalArgumentException e) { - Log.e("Load files", "Error " + e.toString()); - - } catch (IllegalAccessException e) { - Log.e("Load files", "Error " + e.toString()); - - } catch (IOException e) { - Log.e("Load files", "Error " + e.toString()); - } - } - } private View postproView() { ScrollView scroll = new ScrollView(this); @@ -501,15 +468,10 @@ public class MainActivity extends Activity { private View paramView(Context ctx) { LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); - /*TextView title = new TextView(ctx); - title.setText(R.string.title_parameter); - title.setTextAppearance(ctx, android.R.style.TextAppearance_DeviceDefault_Large); - title.setTextColor(Color.BLACK);*/ run = new Button(ctx); reset = new Button(ctx); run.setText("Run"); reset.setText("Reset"); - //reset.setEnabled(false); run.setOnClickListener(new OnClickListener() {public void onClick(View v) { if(run.getText().equals("Show step")) { @@ -525,8 +487,6 @@ public class MainActivity extends Activity { } if(changed){ new Run().execute(); - //gmsh.onelabCB("compute"); - } getAvailableParam(); @@ -572,17 +532,6 @@ public class MainActivity extends Activity { paramListView.addItem(p.getName().split("/")[0].equals("Parameters")? p.getName().split("/")[0] + " > " + p.getName().split("/")[1]: p.getName().split("/")[0], p.getView()); p.setList(paramListView); } - /*LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); - layoutParams.weight = 1; - layout.addView(paramListView, layoutParams); - layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); - layoutParams.weight = 0; - layoutParams.gravity = Gravity.BOTTOM; - layout.addView(onelabBtns,layoutParams); - return layout;*/ - //layout.addView(onelabBtns); - //layout.addView(paramListView); - //return layout; return paramListView; } @@ -746,16 +695,12 @@ public class MainActivity extends Activity { loading.setButton(DialogInterface.BUTTON_NEGATIVE, "Stop", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { - //loading.dismiss(); - //run.setText("Run"); gmsh.onelabCB("stop"); run.setEnabled(false); - //cancel(true); } }); loading.setMessage("..."); loading.show(); - //run.setEnabled(false); run.setText("Show progress"); super.onPreExecute(); } @@ -769,8 +714,9 @@ public class MainActivity extends Activity { @Override protected void onPostExecute(Integer[] result) { loading.dismiss(); - //run.setEnabled(true); run.setText("Run"); + Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + v.vibrate(500); run.setEnabled(true); glView.requestRender(); super.onPostExecute(result); diff --git a/contrib/mobile/Android/src/org/geuz/onelab/SplashScreen.java b/contrib/mobile/Android/src/org/geuz/onelab/SplashScreen.java index c1649880fd654062e0e0dd2e547000f00014074a..c1e3babac01eb44904701c9bfc6bc01f1183d68a 100644 --- a/contrib/mobile/Android/src/org/geuz/onelab/SplashScreen.java +++ b/contrib/mobile/Android/src/org/geuz/onelab/SplashScreen.java @@ -1,9 +1,16 @@ package org.geuz.onelab; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Field; + import android.app.Activity; +import android.content.Context; import android.content.Intent; import android.os.Handler; import android.os.Message; +import android.util.Log; public class SplashScreen extends Activity{ private static final int SPLASHTIME = 1000; // duration for the splash screen in milliseconds @@ -39,8 +46,45 @@ public class SplashScreen extends Activity{ newIntent.setAction(oldIntent.getAction()); newIntent.setData(oldIntent.getData()); } + loadNative(); final Message msg = new Message(); msg.what = STOPSPLASH; handler.sendMessageDelayed(msg, SPLASHTIME); - }; + } + + /** + * Load file from res/raw/ directory to the files directory of the application. + */ + private void loadNative() + { + for( Field f : R.raw.class.getFields()) { + try { + int Msh = f.getInt(null), i; + String androidName = getResources().getResourceEntryName(Msh); + StringBuilder tmp = new StringBuilder(androidName); + tmp.setCharAt(androidName.lastIndexOf('_'), '.'); + String nativeName = tmp.toString(); + /*if(new File(getFilesDir().toString()+"/"+nativeName).exists()){ + //TODO check if the files are the same + continue; + }*/ + InputStream mshFile = getResources().openRawResource(Msh); + + FileOutputStream outputStream = openFileOutput(nativeName, Context.MODE_WORLD_READABLE); + byte[] buffer = new byte[2048]; + + while ((i = mshFile.read(buffer, 0, buffer.length)) > 0) + outputStream.write(buffer,0,i); + + } catch (IllegalArgumentException e) { + Log.e("Load files", "Error " + e.toString()); + + } catch (IllegalAccessException e) { + Log.e("Load files", "Error " + e.toString()); + + } catch (IOException e) { + Log.e("Load files", "Error " + e.toString()); + } + } + } } diff --git a/contrib/mobile/drawGModel.cpp b/contrib/mobile/drawGModel.cpp index db17c91566a3feb84525589dae261f0a51c93cb0..ee283f6fa72bc4f90d24e01472c84c5e2c8e6a11 100644 --- a/contrib/mobile/drawGModel.cpp +++ b/contrib/mobile/drawGModel.cpp @@ -298,10 +298,11 @@ void drawGModel::drawPView(PView *p) drawArray(p->va_points, GL_POINTS,true); drawArray(p->va_lines, GL_LINES,true); drawArray(p->va_triangles, GL_TRIANGLES,true); - - drawVectorArray(p->getOptions(), p->va_vectors); + glLineWidth(1); glPointSize(1); + + drawVectorArray(p->getOptions(), p->va_vectors); } void drawGModel::drawScale() diff --git a/contrib/mobile/utils/onelab_android.sh b/contrib/mobile/utils/onelab_android.sh index bcf05ce710b323a5cef7caf378b813b117ee89f2..1c40d8da99b2729ed3551b1b4a3873ccf94dee95 100644 --- a/contrib/mobile/utils/onelab_android.sh +++ b/contrib/mobile/utils/onelab_android.sh @@ -90,6 +90,7 @@ while read line; do cp bin/Onelab-release-unsigned.apk ../../../../Onelab-unsigned-$(echo $target_name)_$(echo $target_version).apk fi count=$(($count+1)) + break # build only for the first target fi read line # HACK target=$(($target+1))