diff --git a/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java b/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java index c49fe250625cb22821e44fb34b2fe34b7ee4b7fb..6203d2aaaf226b77a7c38b4fde6d16029040a86d 100644 --- a/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java +++ b/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java @@ -198,7 +198,7 @@ public class MainActivity extends Activity{ _runStopMenuItem.setTitle(R.string.menu_run); if(_modelFragment != null) _modelFragment.hideProgress(); _compute = false; - if(_notify) notifyEndOfCompute(); + if(_notify) notifyEndComputing(); super.onPostExecute(result); } @@ -261,48 +261,39 @@ public class MainActivity extends Activity{ if(!_compute) return; if(level == Activity.TRIM_MEMORY_COMPLETE){ _gmsh.onelabCB("stop"); - notifyInterruptComputing(); + notifyEndComputing("The computing had to stop because your device ran out of memory"); _notify = false; } else if(level == Activity.TRIM_MEMORY_COMPLETE) { - // TODO + notifyComputing("Computing in progress - low memory", true); } super.onTrimMemory(level); } - private void notifyComputing() { + private void notifyComputing(String msg, boolean alert) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); Notification.Builder notifyBuilder = new Notification.Builder(this); notifyBuilder.setContentTitle("ONELAB") .setContentIntent(pendingIntent) - .setContentText("Computing in progress") + .setContentText(msg) .setSmallIcon(R.drawable.ic_launcher) .setProgress(0, 0, true); - NotificationManager mNotificationManager = - (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + if(alert) notifyBuilder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE); + NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(1337, notifyBuilder.getNotification()); } - private void notifyEndOfCompute() { - Intent intent = new Intent(this, MainActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); - PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); - Notification.Builder notifyBuilder = new Notification.Builder(this) - .setSmallIcon(R.drawable.ic_launcher) - .setContentIntent(pendingIntent) - .setContentTitle("ONELAB") - .setDefaults(Notification.DEFAULT_ALL) - .setAutoCancel(true) - .setProgress(0, 0, false) - .setContentText("The computing is finished"); - NotificationManager mNotificationManager = - (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - mNotificationManager.notify(1337, notifyBuilder.getNotification()); + private void notifyComputing() { + notifyComputing("Computing in progress", false); + } + + private void notifyEndComputing() { + notifyEndComputing("The computing is finished"); } - private void notifyInterruptComputing() { + private void notifyEndComputing(String msg) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); @@ -313,9 +304,8 @@ public class MainActivity extends Activity{ .setDefaults(Notification.DEFAULT_ALL) .setAutoCancel(true) .setProgress(0, 0, false) - .setContentText("The computing had to stop because your device ran out of memory"); - NotificationManager mNotificationManager = - (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + .setContentText(msg); + NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(1337, notifyBuilder.getNotification()); } diff --git a/contrib/mobile/Android/src/org/geuz/onelab/ModelFragment.java b/contrib/mobile/Android/src/org/geuz/onelab/ModelFragment.java index 826ea9dbad6fd0accb43c0a8b37590247ca5a19d..38d91dd4b6c2ed92dc11adee4a2518725ba64d51 100644 --- a/contrib/mobile/Android/src/org/geuz/onelab/ModelFragment.java +++ b/contrib/mobile/Android/src/org/geuz/onelab/ModelFragment.java @@ -33,7 +33,7 @@ public class ModelFragment extends Fragment{ private TextView _progress; private LinearLayout _progressLayout; private LinearLayout _controlBarLayout; - private GestureDetector _gestureListener; + private GestureDetector _gestureDetector; private Timer _animation; private Handler _hideDelay; @@ -69,46 +69,29 @@ public class ModelFragment extends Fragment{ _glView.requestRender(); _hideDelay = new Handler(); this.postDelay(); - _gestureListener = new GestureDetector(getActivity(), new OnGestureListener() { - public boolean onSingleTapUp(MotionEvent e) { + _gestureDetector = new GestureDetector(getActivity(), new OnGestureListener() { + public boolean onSingleTapUp(MotionEvent e) { return false; } // UNUSED Auto-generated method stub + public void onShowPress(MotionEvent e) {} // UNUSED Auto-generated method stub + public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { return false; } // UNUSED Auto-generated method stub + public void onLongPress(MotionEvent e) {} // UNUSED Auto-generated method stub + public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { return false; } // UNUSED Auto-generated method stub + public boolean onDown(MotionEvent e) { return false; } // UNUSED Auto-generated method stub + }); + _gestureDetector.setOnDoubleTapListener(new GestureDetector.OnDoubleTapListener() { + public boolean onSingleTapConfirmed(MotionEvent e) { if(View.VISIBLE == _controlBarLayout.getVisibility()) hideControlBar(); else showControlBar(); return true; } - - public void onShowPress(MotionEvent e) { - // TODO Auto-generated method stub - - } - - public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, - float distanceY) { - // TODO Auto-generated method stub - return false; - } - - public void onLongPress(MotionEvent e) { - // TODO Auto-generated method stub - - } - - public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, - float velocityY) { - // TODO Auto-generated method stub - return false; - } - - public boolean onDown(MotionEvent e) { - // TODO Auto-generated method stub - return false; - } + public boolean onDoubleTapEvent(MotionEvent e) { return false; } // UNUSED Auto-generated method stub + public boolean onDoubleTap(MotionEvent e) { return false; } // UNUSED Auto-generated method stub }); _glView.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { - return _gestureListener.onTouchEvent(event); + return _gestureDetector.onTouchEvent(event); } }); glViewLayout.addView(_glView); @@ -130,7 +113,9 @@ public class ModelFragment extends Fragment{ layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); glViewLayout.addView(_progressLayout, layoutParams); _controlBarLayout = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.control_bar, null); - ImageButton playPauseButton = (ImageButton)_controlBarLayout.findViewById(R.id.controlPlay); + 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); playPauseButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { postDelay(); @@ -143,15 +128,18 @@ public class ModelFragment extends Fragment{ _gmsh.animationNext(); requestRender(); } }, 0, 500); + prevButton.setEnabled(false); + nextButton.setEnabled(false); } else { ((ImageButton)v).setContentDescription("play"); ((ImageButton)v).setImageResource(android.R.drawable.ic_media_play); _animation.cancel(); + prevButton.setEnabled(true); + nextButton.setEnabled(true); } } }); - ImageButton nextButton = (ImageButton)_controlBarLayout.findViewById(R.id.controlNext); nextButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { postDelay(); @@ -159,7 +147,6 @@ public class ModelFragment extends Fragment{ requestRender(); } }); - ImageButton prevButton = (ImageButton)_controlBarLayout.findViewById(R.id.controlPrev); prevButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { postDelay(); diff --git a/contrib/mobile/drawContext.cpp b/contrib/mobile/drawContext.cpp index 58eea35343783a6debbcf09732cb05f1c97e903c..c94b66cf916c9c0c3502ac146ec3fcfdfd4a4308 100644 --- a/contrib/mobile/drawContext.cpp +++ b/contrib/mobile/drawContext.cpp @@ -370,7 +370,7 @@ void drawContext::drawScale() PView *p = PView::list[i]; PViewOptions *opt = p->getOptions(); if(!opt->visible) continue; - + double width = 6*(this->_right -this->_left) / 10.; double height = (this->_top - this->_bottom) / 20.; double box = width / (opt->nbIso ? opt->nbIso : 1); @@ -462,6 +462,7 @@ void drawContext::drawScale() glDisableClientState(GL_VERTEX_ARRAY); free(vertex); free(color); + char label[1024]; drawString *lbl = new drawString(p->getData()->getName().c_str(), 20); lbl->draw(xmin+width/2, ymin-height/2, 0., _width/(_right-_left), _height/(_top-_bottom)); @@ -472,6 +473,7 @@ void drawContext::drawScale() val->setText(label); val->draw(xmin+i*width/2, ymin+height/2, 0., _width/(_right-_left), _height/(_top-_bottom)); } + nPview++; } glPopMatrix(); @@ -575,6 +577,8 @@ void drawContext::drawView() this->_bottom + (this->_top - this->_bottom)/15.0, 0, (this->_top - this->_bottom)/20.); checkGlError("Draw axes"); + this->drawScale(); + checkGlError("Draw scales"); glEnable(GL_DEPTH_TEST); this->drawMesh(); checkGlError("Draw mesh"); @@ -582,8 +586,6 @@ void drawContext::drawView() checkGlError("Draw geometry"); this->drawPost(); checkGlError("Draw post-pro"); - this->drawScale(); - checkGlError("Draw scales"); glDisable(GL_DEPTH_TEST); }