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

Android: do not allow sharing if it's compute

parent bf548aab
No related branches found
No related tags found
No related merge requests found
...@@ -54,7 +54,7 @@ public class GLESRender implements Renderer{ ...@@ -54,7 +54,7 @@ public class GLESRender implements Renderer{
public void onSurfaceChanged(GL10 gl, int width, int height) { public void onSurfaceChanged(GL10 gl, int width, int height) {
mGModel.viewInit(width, height); mGModel.viewInit(width, height);
_width = width + 5; _width = width;
_height = height; _height = height;
} }
......
package org.geuz.onelab; package org.geuz.onelab;
import java.io.File; import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import android.app.ActionBar; import android.app.ActionBar;
import android.app.Activity; import android.app.Activity;
...@@ -121,21 +123,36 @@ public class MainActivity extends Activity{ ...@@ -121,21 +123,36 @@ public class MainActivity extends Activity{
_gmsh.onelabCB("stop"); _gmsh.onelabCB("stop");
} }
else if(item.getTitle().equals("Share ...")) { else if(item.getTitle().equals("Share ...")) {
File file = new File(this.getExternalFilesDir(null), "onelab_screenshot.png"); if(this._compute) {
file.setReadable(true, false); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
_modelFragment.takeScreenshot(file); _errorDialog = dialogBuilder.setTitle("Can't show the models list")
Intent shareIntent = new Intent(); .setMessage("The computing have to be finished before you can take a screenshot.")
shareIntent.setAction(Intent.ACTION_SEND); .setPositiveButton("OK", new DialogInterface.OnClickListener() {
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
shareIntent.setType("image/jpeg"); public void onClick(DialogInterface dialog, int which) {
startActivity(Intent.createChooser(shareIntent, "Share screenshot with ...")); dialog.dismiss();
}
})
.show();
}
else {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd-HH_mm_ss");
File file = new File(this.getExternalFilesDir(null), "onelab-screenshot-"+dateFormat.format(new Date())+".png");
file.setReadable(true, false);
_modelFragment.takeScreenshot(file);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
shareIntent.setType("image/jpeg");
startActivity(Intent.createChooser(shareIntent, "Share screenshot with"));
}
} }
else if(item.getItemId() == android.R.id.home) else if(item.getItemId() == android.R.id.home)
{ {
if(this._compute) { if(this._compute) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
_errorDialog = dialogBuilder.setTitle("Can't show the models list") _errorDialog = dialogBuilder.setTitle("Can't show the models list")
.setMessage("The compute have to be finished before you can select an other model.") .setMessage("The computing have to be finished before you can select an other model.")
.setPositiveButton("OK", new DialogInterface.OnClickListener() { .setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
......
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