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

Clean Android project

parent 42da145d
No related branches found
No related tags found
No related merge requests found
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
......@@ -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>
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);
......
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());
}
}
}
}
......@@ -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()
......
......@@ -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))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment