diff --git a/contrib/mobile/Android/res/drawable-hdpi/ic_list.png b/contrib/mobile/Android/res/drawable-hdpi/ic_list.png deleted file mode 100644 index 0845ffb33f34db2c2e4501f38c5dad6088d53f95..0000000000000000000000000000000000000000 Binary files a/contrib/mobile/Android/res/drawable-hdpi/ic_list.png and /dev/null differ diff --git a/contrib/mobile/Android/res/drawable-hdpi/ic_mesh.png b/contrib/mobile/Android/res/drawable-hdpi/ic_mesh.png deleted file mode 100644 index 2c927569920e18ae051265d2fb7187c682cd8cf5..0000000000000000000000000000000000000000 Binary files a/contrib/mobile/Android/res/drawable-hdpi/ic_mesh.png and /dev/null differ diff --git a/contrib/mobile/Android/res/drawable-hdpi/ic_settings.png b/contrib/mobile/Android/res/drawable-hdpi/ic_settings.png deleted file mode 100644 index aced98ab0d9c88e34b584f2b91441190f7cbf521..0000000000000000000000000000000000000000 Binary files a/contrib/mobile/Android/res/drawable-hdpi/ic_settings.png and /dev/null differ diff --git a/contrib/mobile/Android/res/layout/control_bar.xml b/contrib/mobile/Android/res/layout/control_bar.xml index 89bc5c543d55b4409f06ee9adb75cf918fa34c37..22f76a01b4a66f703cc532677e1dde1e14fd3780 100644 --- a/contrib/mobile/Android/res/layout/control_bar.xml +++ b/contrib/mobile/Android/res/layout/control_bar.xml @@ -2,30 +2,42 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="horizontal" + android:orientation="vertical" android:background="@android:color/black" android:alpha=".50" android:gravity="center" > + <SeekBar + android:id="@+id/controlStepper" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="horizontal" + android:background="@android:color/black" + android:alpha=".50" + android:gravity="center" > - <ImageButton - android:id="@+id/controlPrev" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:src="@android:drawable/ic_media_previous" - android:contentDescription="previous" /> - - <ImageButton - android:id="@+id/controlPlay" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:src="@android:drawable/ic_media_play" - android:contentDescription="play" /> - - <ImageButton - android:id="@+id/controlNext" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:src="@android:drawable/ic_media_next" - android:contentDescription="next" /> + <ImageButton + android:id="@+id/controlPrev" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@android:drawable/ic_media_previous" + android:contentDescription="previous" /> + + <ImageButton + android:id="@+id/controlPlay" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@android:drawable/ic_media_play" + android:contentDescription="play" /> + + <ImageButton + android:id="@+id/controlNext" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@android:drawable/ic_media_next" + android:contentDescription="next" /> + </LinearLayout> </LinearLayout> \ No newline at end of file diff --git a/contrib/mobile/Android/src/org/geuz/onelab/Gmsh.java b/contrib/mobile/Android/src/org/geuz/onelab/Gmsh.java index 2e1e04fda184c4e6ad5b01433b9055489bfec9ae..4ba89b2a5825e9099ca516555d59e05c5ba0c2d9 100644 --- a/contrib/mobile/Android/src/org/geuz/onelab/Gmsh.java +++ b/contrib/mobile/Android/src/org/geuz/onelab/Gmsh.java @@ -31,8 +31,10 @@ public class Gmsh implements Parcelable { public native void setPView(int position, int intervalsType,int visible,int nbIso, float raisez); // Change options for a PView public native int onelabCB(String action); // Call onelab - public native void animationNext(); - public native void animationPrev(); + public boolean haveAnimation() {return numberOfAnimation() > 1;} + public native int numberOfAnimation(); + public native int animationNext(); + public native int animationPrev(); /** Java CLASS **/ private long ptr; diff --git a/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java b/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java index 2a3a8f85b51200ad538d5deb6f1b844dc327d8f6..24013b948e5f19e0768b7e641b9fa9fd41db1e3b 100644 --- a/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java +++ b/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java @@ -120,6 +120,7 @@ public class MainActivity extends Activity{ new Run().execute(); } else if(item.getTitle().equals(getString(R.string.menu_stop))){ + _runStopMenuItem.setEnabled(false); _gmsh.onelabCB("stop"); } else if(item.getTitle().equals(getString(R.string.menu_share))) { @@ -196,6 +197,7 @@ public class MainActivity extends Activity{ protected void onPostExecute(Integer[] result) { //(Vibrator) getSystemService(Context.VIBRATOR_SERVICE).vibrate(350); _runStopMenuItem.setTitle(R.string.menu_run); + _runStopMenuItem.setEnabled(true); if(_modelFragment != null) _modelFragment.hideProgress(); _compute = false; if(_notify) notifyEndComputing(); @@ -332,4 +334,6 @@ public class MainActivity extends Activity{ } }; }; + + public boolean isComputing() {return _compute;} } diff --git a/contrib/mobile/Android/src/org/geuz/onelab/ModelFragment.java b/contrib/mobile/Android/src/org/geuz/onelab/ModelFragment.java index bb4e2c7fd37015bd36a82ea3c0aa680ea1e60ac7..b24245bb217d96b2cfbf899f5902b7c1be6123e7 100644 --- a/contrib/mobile/Android/src/org/geuz/onelab/ModelFragment.java +++ b/contrib/mobile/Android/src/org/geuz/onelab/ModelFragment.java @@ -24,6 +24,7 @@ import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.RelativeLayout; +import android.widget.SeekBar; import android.widget.TextView; public class ModelFragment extends Fragment{ @@ -36,9 +37,10 @@ public class ModelFragment extends Fragment{ private GestureDetector _gestureDetector; private Timer _animation; private Handler _hideDelay; - + private SeekBar _annimationStepper; + final Runnable hideControlsRunnable = new Runnable() {public void run() {hideControlBar();}}; - + public static ModelFragment newInstance(Gmsh g) { ModelFragment fragment = new ModelFragment(); Bundle bundle = new Bundle(); @@ -116,16 +118,19 @@ public class ModelFragment extends Fragment{ final ImageButton prevButton = (ImageButton)_controlBarLayout.findViewById(R.id.controlPrev); final ImageButton playPauseButton = (ImageButton)_controlBarLayout.findViewById(R.id.controlPlay); final ImageButton nextButton = (ImageButton)_controlBarLayout.findViewById(R.id.controlNext); + _annimationStepper = (SeekBar)_controlBarLayout.findViewById(R.id.controlStepper); + _controlBarLayout.setEnabled(false); playPauseButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { postDelay(); if(((ImageButton)v).getContentDescription().equals("play")) { ((ImageButton)v).setContentDescription("pause"); ((ImageButton)v).setImageResource(android.R.drawable.ic_media_pause); + _annimationStepper.setMax(_gmsh.numberOfAnimation()); _animation = new Timer(); _animation.schedule(new TimerTask() { public void run() { - _gmsh.animationNext(); + _annimationStepper.setProgress(_gmsh.animationNext()); requestRender(); } }, 0, 500); prevButton.setEnabled(false); @@ -143,14 +148,14 @@ public class ModelFragment extends Fragment{ nextButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { postDelay(); - _gmsh.animationNext(); + _annimationStepper.setProgress(_gmsh.animationNext()); requestRender(); } }); prevButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { postDelay(); - _gmsh.animationPrev(); + _annimationStepper.setProgress(_gmsh.animationPrev()); requestRender(); } }); @@ -169,9 +174,10 @@ public class ModelFragment extends Fragment{ this.postDelay(6000); } public void showControlBar() { - if(getActivity() == null) return; + if(getActivity() == null || ((MainActivity)getActivity()).isComputing() || !_gmsh.haveAnimation()) return; + _controlBarLayout.setEnabled(true); + _annimationStepper.setMax(_gmsh.numberOfAnimation()); this.postDelay(); - //getActivity().getActionBar().show(); Animation bottomUp = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in); _controlBarLayout.setVisibility(View.VISIBLE); _controlBarLayout.startAnimation(bottomUp); @@ -179,10 +185,10 @@ public class ModelFragment extends Fragment{ public void hideControlBar() { if(getActivity() == null) return; _hideDelay.removeCallbacks(hideControlsRunnable); - //getActivity().getActionBar().hide(); Animation bottomDown = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out); _controlBarLayout.startAnimation(bottomDown); _controlBarLayout.setVisibility(View.INVISIBLE); + } public void showProgress(String progress) { _progressLayout.setAlpha(1); diff --git a/contrib/mobile/androidGModel.cpp b/contrib/mobile/androidGModel.cpp index 606626e84096eda1bb1b3bee54b9e5213b76efba..92ffcf899bc30bf397aee5c7094302774f65f1ae 100644 --- a/contrib/mobile/androidGModel.cpp +++ b/contrib/mobile/androidGModel.cpp @@ -304,14 +304,20 @@ JNIEXPORT jint JNICALL Java_org_geuz_onelab_Gmsh_onelabCB const char* action = env->GetStringUTFChars(jaction, NULL); return onelab_cb(action); } -JNIEXPORT void JNICALL Java_org_geuz_onelab_Gmsh_animationNext + +JNIEXPORT jint JNICALL Java_org_geuz_onelab_Gmsh_numberOfAnimation + (JNIEnv *, jobject) +{ + return number_of_animation(); +} +JNIEXPORT jint JNICALL Java_org_geuz_onelab_Gmsh_animationNext (JNIEnv *, jobject) { - animation_next(); + return animation_next(); } -JNIEXPORT void JNICALL Java_org_geuz_onelab_Gmsh_animationPrev +JNIEXPORT jint JNICALL Java_org_geuz_onelab_Gmsh_animationPrev (JNIEnv *, jobject) { - animation_prev(); + return animation_prev(); } } diff --git a/contrib/mobile/androidGModel.h b/contrib/mobile/androidGModel.h index 043816e97112d3ba65f6faf89cff61ac3df3108a..991a21107160968ca0302dfbe7d4b2b80ea13d3d 100644 --- a/contrib/mobile/androidGModel.h +++ b/contrib/mobile/androidGModel.h @@ -137,20 +137,28 @@ JNIEXPORT void JNICALL Java_org_geuz_onelab_Gmsh_setPView JNIEXPORT jint JNICALL Java_org_geuz_onelab_Gmsh_onelabCB (JNIEnv *, jobject, jstring); +/* + * Class: org_geuz_onelab_Gmsh + * Method: numberOfAnimation + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_geuz_onelab_Gmsh_numberOfAnimation + (JNIEnv *, jobject); + /* * Class: org_geuz_onelab_Gmsh * Method: animationNext - * Signature: ()V + * Signature: ()I */ -JNIEXPORT void JNICALL Java_org_geuz_onelab_Gmsh_animationNext +JNIEXPORT jint JNICALL Java_org_geuz_onelab_Gmsh_animationNext (JNIEnv *, jobject); /* * Class: org_geuz_onelab_Gmsh * Method: animationPrev - * Signature: ()V + * Signature: ()I */ -JNIEXPORT void JNICALL Java_org_geuz_onelab_Gmsh_animationPrev +JNIEXPORT jint JNICALL Java_org_geuz_onelab_Gmsh_animationPrev (JNIEnv *, jobject); #ifdef __cplusplus diff --git a/contrib/mobile/drawContext.cpp b/contrib/mobile/drawContext.cpp index 886f1dcd7236f3b938f772c7781f4eb83e36bb04..3a158c326e2a070dcb840949bcee0e429cee962d 100644 --- a/contrib/mobile/drawContext.cpp +++ b/contrib/mobile/drawContext.cpp @@ -682,41 +682,50 @@ int onelab_cb(std::string action) return redraw; } -void animation_next() { +int number_of_animation() { + int ret = 0; + for(unsigned int i = 0; i < PView::list.size(); i++){ + PView * p = PView::list[i]; + if(p->getOptions()->visible){ + int numSteps = (int)p->getData()->getNumTimeSteps(); + if(numSteps > ret) ret = numSteps; + } + } + return ret; +} + +int animation_next() { + int ret = 0; for(unsigned int i = 0; i < PView::list.size(); i++){ PView * p = PView::list[i]; if(p->getOptions()->visible){ - // skip empty steps int step = (int)p->getOptions()->timeStep + 1; int numSteps = (int)p->getData()->getNumTimeSteps(); - for(int j = 0; j < numSteps; j++){ - if(p->getData()->hasTimeStep(step)) break; - else step += 1; - if(step < 0) step = numSteps - 1; - if(step > numSteps - 1) step = 0; - } + if(step < 0) step = numSteps - 1; + if(step > numSteps - 1) step = 0; p->getOptions()->timeStep = step; p->setChanged(true); + ret = step; } } + return ret; } -void animation_prev() { +int animation_prev() { + int ret = 0; for(unsigned int i = 0; i < PView::list.size(); i++){ PView * p = PView::list[i]; if(p->getOptions()->visible){ // skip empty steps int step = (int)p->getOptions()->timeStep - 1; int numSteps = (int)p->getData()->getNumTimeSteps(); - for(int j = 0; j < numSteps; j++){ - if(p->getData()->hasTimeStep(step)) break; - else step -= 1; - if(step < 0) step = numSteps - 1; - if(step > numSteps - 1) step = 0; - } + if(step < 0) step = numSteps - 1; + if(step > numSteps - 1) step = 0; p->getOptions()->timeStep = step; p->setChanged(true); + ret = step; } } + return ret; } // vim:set ts=2: diff --git a/contrib/mobile/drawContext.h b/contrib/mobile/drawContext.h index e69035fb0a942a188334e752f726a6cea44c67fe..a42a68757704b4f9ff54befec0a5062d10f1aad9 100644 --- a/contrib/mobile/drawContext.h +++ b/contrib/mobile/drawContext.h @@ -21,8 +21,9 @@ void drawArray(VertexArray *va, int type, bool useColorArray=false, bool useNormalArray=false); int onelab_cb(std::string); -void animation_next(); -void animation_prev(); +int animation_next(); +int animation_prev(); +int number_of_animation(); class drawContext{ private: