From 964f024c6f27499378845cd14b9e6f374755cd76 Mon Sep 17 00:00:00 2001 From: Maxime Graulich <maxime.graulich@gmail.com> Date: Wed, 4 Sep 2013 09:05:19 +0000 Subject: [PATCH] Android: show progress informations --- .../Android/res/layout/fragment_model.xml | 2 +- .../src/org/geuz/onelab/MainActivity.java | 6 ++--- .../src/org/geuz/onelab/ModelFragment.java | 23 +++++++++++++++++-- .../geuz/onelab/OptionsDisplayFragment.java | 4 +++- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/contrib/mobile/Android/res/layout/fragment_model.xml b/contrib/mobile/Android/res/layout/fragment_model.xml index 0b1475fcfd..b65fd9dcbb 100644 --- a/contrib/mobile/Android/res/layout/fragment_model.xml +++ b/contrib/mobile/Android/res/layout/fragment_model.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" diff --git a/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java b/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java index 7b93f7e320..9c891dfab2 100644 --- a/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java +++ b/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java @@ -69,6 +69,7 @@ public class MainActivity extends Activity implements OptionsDisplayFragment.OnO getFragmentManager().beginTransaction().add(R.id.model_fragment, _modelFragment).commit(); } } + @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); @@ -164,7 +165,7 @@ public class MainActivity extends Activity implements OptionsDisplayFragment.OnO protected void onPostExecute(Integer[] result) { //(Vibrator) getSystemService(Context.VIBRATOR_SERVICE).vibrate(350); _runStopMenuItem.setTitle(R.string.menu_run); - //loading.dismiss(); + if(_modelFragment != null) _modelFragment.hideProgress(); _compute = false; super.onPostExecute(result); } @@ -208,8 +209,7 @@ public class MainActivity extends Activity implements OptionsDisplayFragment.OnO if(_optionsFragment != null) _optionsFragment.refresh(); break; case 2: // we get a message for loading - /*String loadingMessage =(String) msg.obj; - loading.setMessage(loadingMessage);*/ + if(_modelFragment != null) _modelFragment.showProgress((String) msg.obj); break; case 3: // we get a progress for loading //loading.setProgress(msg.arg1); diff --git a/contrib/mobile/Android/src/org/geuz/onelab/ModelFragment.java b/contrib/mobile/Android/src/org/geuz/onelab/ModelFragment.java index 6a67d9615a..686984fbf0 100644 --- a/contrib/mobile/Android/src/org/geuz/onelab/ModelFragment.java +++ b/contrib/mobile/Android/src/org/geuz/onelab/ModelFragment.java @@ -7,11 +7,14 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.TextView; public class ModelFragment extends Fragment{ Gmsh _gmsh; mGLSurfaceView _glView; + TextView _progress; public static ModelFragment newInstance(Gmsh g) { ModelFragment fragment = new ModelFragment(); @@ -34,7 +37,7 @@ public class ModelFragment extends Fragment{ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_model, container, false); - LinearLayout glViewLayout = (LinearLayout)rootView.findViewById(R.id.glViewLayout); + RelativeLayout glViewLayout = (RelativeLayout)rootView.findViewById(R.id.glViewLayout); GLESRender renderer = new GLESRender(_gmsh); _glView = new mGLSurfaceView(glViewLayout.getContext(), renderer); _glView.setEGLContextClientVersion(1); @@ -42,9 +45,25 @@ public class ModelFragment extends Fragment{ _glView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); _glView.requestRender(); glViewLayout.addView(_glView); + _progress = new TextView(container.getContext()); + _progress.setAlpha(0); + RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( + RelativeLayout.LayoutParams.WRAP_CONTENT, + RelativeLayout.LayoutParams.WRAP_CONTENT); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); + _progress.setPadding(10, 0, 10, 10); + _progress.setLayoutParams(layoutParams); + glViewLayout.addView(_progress); return rootView; } - + public void showProgress(String progress) { + _progress.setAlpha(1); + _progress.setText(progress); + } + public void hideProgress() { + _progress.setAlpha(0); + _progress.setText(""); + } public void requestRender() { _glView.requestRender(); } diff --git a/contrib/mobile/Android/src/org/geuz/onelab/OptionsDisplayFragment.java b/contrib/mobile/Android/src/org/geuz/onelab/OptionsDisplayFragment.java index c293ea0e0f..5f5696b9a6 100644 --- a/contrib/mobile/Android/src/org/geuz/onelab/OptionsDisplayFragment.java +++ b/contrib/mobile/Android/src/org/geuz/onelab/OptionsDisplayFragment.java @@ -6,6 +6,7 @@ import android.app.Activity; import android.app.Fragment; import android.content.Intent; import android.graphics.Color; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -110,7 +111,7 @@ public class OptionsDisplayFragment extends Fragment{ } }); Button button = new Button(_listView.getContext()); - button.setText("More options"); + button.setText("More options >"); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(getActivity(), PostProcessingActivity.class); @@ -121,6 +122,7 @@ public class OptionsDisplayFragment extends Fragment{ }); button.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); button.setBackgroundColor(Color.TRANSPARENT); + button.setGravity(Gravity.RIGHT); layout.addView(checkbox); layout.addView(button); _listView.addItem("Result", layout); -- GitLab