diff --git a/android/BOINC/res/layout/status_layout.xml b/android/BOINC/res/layout/status_layout.xml
index 20b94bed3a..93b040d37a 100644
--- a/android/BOINC/res/layout/status_layout.xml
+++ b/android/BOINC/res/layout/status_layout.xml
@@ -59,17 +59,38 @@
-
+ android:visibility="gone"
+ android:padding="10dp"
+ android:orientation="vertical">
+
+
+
+
+
+
+
+
+
Add a project!
Closing…
Benchmarking…
+ project image
Reading preferences…
diff --git a/android/BOINC/src/edu/berkeley/boinc/StatusActivity.java b/android/BOINC/src/edu/berkeley/boinc/StatusActivity.java
index 877f328fbe..79f7209d78 100644
--- a/android/BOINC/src/edu/berkeley/boinc/StatusActivity.java
+++ b/android/BOINC/src/edu/berkeley/boinc/StatusActivity.java
@@ -19,7 +19,10 @@
package edu.berkeley.boinc;
import java.util.ArrayList;
+
+import edu.berkeley.boinc.adapter.GalleryAdapter;
import edu.berkeley.boinc.client.ClientStatus;
+import edu.berkeley.boinc.client.ClientStatus.ImageWrapper;
import edu.berkeley.boinc.client.Monitor;
import edu.berkeley.boinc.utils.BOINCDefs;
import android.app.Activity;
@@ -41,9 +44,14 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup.LayoutParams;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
import android.widget.TextView;
+import android.widget.Toast;
import android.widget.ViewFlipper;
public class StatusActivity extends Activity implements OnClickListener{
@@ -58,32 +66,7 @@ public class StatusActivity extends Activity implements OnClickListener{
private Integer suspendReason = -1;
//slide show
- private ViewFlipper imageFrame;
-
- // gesture detection
- private final GestureDetector gdt = new GestureDetector(new GestureListener());
- private class GestureListener extends SimpleOnGestureListener {
- // values taken from example on Stackoverflow. seems appropriate.
- private final int SWIPE_MIN_DISTANCE = 120;
- private final int SWIPE_THRESHOLD_VELOCITY = 200;
- @Override
- public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
- if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
- //Log.d(TAG, "right to left...");
- imageFrame.setInAnimation(getApplicationContext(), R.anim.in_from_right);
- imageFrame.setOutAnimation(getApplicationContext(), R.anim.out_to_left);
- imageFrame.showNext();
- return false;
- } else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
- //Log.d(TAG, "left to right...");
- imageFrame.setInAnimation(getApplicationContext(), R.anim.in_from_left);
- imageFrame.setOutAnimation(getApplicationContext(), R.anim.out_to_right);
- imageFrame.showPrevious();
- return false;
- }
- return false;
- }
- }
+ private LinearLayout slideshowWrapper;
private BroadcastReceiver mClientStatusChangeRec = new BroadcastReceiver() {
@Override
@@ -173,12 +156,12 @@ public class StatusActivity extends Activity implements OnClickListener{
TextView statusHeader = (TextView) findViewById(R.id.status_header);
ImageView statusImage = (ImageView) findViewById(R.id.status_image);
TextView statusDescriptor = (TextView) findViewById(R.id.status_long);
- imageFrame = (ViewFlipper) findViewById(R.id.slideshowFrame);
+ slideshowWrapper = (LinearLayout) findViewById(R.id.slideshow_wrapper);
// adapt to specific computing status
switch(status.computingStatus) {
case ClientStatus.COMPUTING_STATUS_NEVER:
- imageFrame.setVisibility(View.GONE);
+ slideshowWrapper.setVisibility(View.GONE);
statusHeader.setText(R.string.status_computing_disabled);
statusImage.setImageResource(R.drawable.playw48);
statusImage.setContentDescription(getString(R.string.status_computing_disabled));
@@ -187,7 +170,7 @@ public class StatusActivity extends Activity implements OnClickListener{
statusDescriptor.setText(R.string.status_computing_disabled_long);
break;
case ClientStatus.COMPUTING_STATUS_SUSPENDED:
- imageFrame.setVisibility(View.GONE);
+ slideshowWrapper.setVisibility(View.GONE);
statusHeader.setText(R.string.status_paused);
statusImage.setImageResource(R.drawable.pausew48);
statusImage.setContentDescription(getString(R.string.status_paused));
@@ -260,7 +243,7 @@ public class StatusActivity extends Activity implements OnClickListener{
suspendReason = status.computingSuspendReason;
break;
case ClientStatus.COMPUTING_STATUS_IDLE:
- imageFrame.setVisibility(View.GONE);
+ slideshowWrapper.setVisibility(View.GONE);
statusHeader.setText(R.string.status_idle);
statusImage.setImageResource(R.drawable.pausew48);
statusImage.setContentDescription(getString(R.string.status_idle));
@@ -297,33 +280,49 @@ public class StatusActivity extends Activity implements OnClickListener{
private Boolean loadSlideshow() {
// get slideshow images
- ArrayList images = Monitor.getClientStatus().getSlideshowImages();
+ final ArrayList images = Monitor.getClientStatus().getSlideshowImages();
if(images == null || images.size() == 0) return false;
// images available, adapt layout
+ Gallery gallery = (Gallery) findViewById(R.id.gallery);
+ final ImageView imageView = (ImageView) findViewById(R.id.image_view);
+ final TextView imageDesc = (TextView)findViewById(R.id.image_description);
+ imageView.setImageBitmap(images.get(0).image);
+ imageDesc.setText(images.get(0).projectName);
LinearLayout centerWrapper = (LinearLayout) findViewById(R.id.center_wrapper);
centerWrapper.setVisibility(View.GONE);
- imageFrame.setVisibility(View.VISIBLE);
- LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
- imageFrame.removeAllViews();
+ slideshowWrapper.setVisibility(View.VISIBLE);
+ //gallery.setVisibility(View.GONE);
+
+ //setup gallery
+ gallery.setAdapter(new GalleryAdapter(this,images));
+
+ gallery.setOnItemClickListener(new OnItemClickListener() {
+ public void onItemClick(AdapterView> parent, View v, int position, long id) {
+ imageView.setImageBitmap(images.get(position).image);
+ imageDesc.setText(images.get(position).projectName);
+ }
+ });
+
+ /*
// create views for all available bitmaps
for (Bitmap image: images) {
ImageView imageView = new ImageView(this);
imageView.setLayoutParams(params);
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
imageView.setImageBitmap(image);
- imageFrame.addView(imageView);
- }
-
+ viewFlipper.addView(imageView);
+ }*/
+ /*
// capture click events and pass on to Gesture Detector
- imageFrame.setOnTouchListener(new OnTouchListener() {
+ slideshowWrapper.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(final View view, final MotionEvent event) {
gdt.onTouchEvent(event);
return true;
}
- });
+ });*/
return true;
}
diff --git a/android/BOINC/src/edu/berkeley/boinc/adapter/GalleryAdapter.java b/android/BOINC/src/edu/berkeley/boinc/adapter/GalleryAdapter.java
new file mode 100644
index 0000000000..57060ff648
--- /dev/null
+++ b/android/BOINC/src/edu/berkeley/boinc/adapter/GalleryAdapter.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * This file is part of BOINC.
+ * http://boinc.berkeley.edu
+ * Copyright (C) 2012 University of California
+ *
+ * BOINC is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * BOINC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with BOINC. If not, see .
+ ******************************************************************************/
+package edu.berkeley.boinc.adapter;
+
+import java.util.ArrayList;
+
+import edu.berkeley.boinc.client.ClientStatus.ImageWrapper;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewGroup.LayoutParams;
+import android.widget.BaseAdapter;
+import android.widget.Gallery;
+import android.widget.ImageView;
+
+public class GalleryAdapter extends BaseAdapter{
+
+ int mGalleryItemBackground;
+ private Context ctx;
+
+ private ArrayList images = new ArrayList();
+
+ public GalleryAdapter(Context ctx, ArrayList images) {
+ this.ctx = ctx;
+ this.images = images;
+ }
+
+ public int getCount() {
+ return images.size();
+ }
+
+ public ImageWrapper getItem(int position) {
+ return images.get(position);
+ }
+
+ public long getItemId(int position) {
+ return position;
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ ImageView imageView = new ImageView(ctx);
+
+ LayoutParams params = new Gallery.LayoutParams(290, 126);
+ imageView.setLayoutParams(params);
+ imageView.setScaleType(ImageView.ScaleType.FIT_XY);
+ imageView.setImageBitmap(images.get(position).image);
+
+ return imageView;
+ }
+
+
+}
diff --git a/android/BOINC/src/edu/berkeley/boinc/client/ClientStatus.java b/android/BOINC/src/edu/berkeley/boinc/client/ClientStatus.java
index e5794abac1..c2811cdceb 100644
--- a/android/BOINC/src/edu/berkeley/boinc/client/ClientStatus.java
+++ b/android/BOINC/src/edu/berkeley/boinc/client/ClientStatus.java
@@ -233,9 +233,9 @@ public class ClientStatus {
// returns list with slideshow images of all projects
// 126 * 29 pixel from /projects/PNAME/slideshow_appname_n
// not aware of project or application!
- public synchronized ArrayList getSlideshowImages() {
+ public synchronized ArrayList getSlideshowImages() {
- ArrayList slideshowImages = new ArrayList();
+ ArrayList slideshowImages = new ArrayList();
for (Project project: projects) {
// get file paths
@@ -262,7 +262,7 @@ public class ClientStatus {
options.inSampleSize = 1;
for (String filePath : filePaths) {
Bitmap tmp = BitmapFactory.decodeFile(filePath, options);
- if(tmp!=null) slideshowImages.add(tmp);
+ if(tmp!=null) slideshowImages.add(new ImageWrapper(tmp,project.project_name));
else Log.d(TAG,"loadSlideshowImagesFromFile(): null for path: " + filePath);
}
}
@@ -486,4 +486,15 @@ public class ClientStatus {
return projectDir + "/" + fileName;
}
+
+ // Wrapper for slideshow images
+ public class ImageWrapper {
+ public Bitmap image;
+ public String projectName;
+
+ public ImageWrapper(Bitmap image, String projectName) {
+ this.image = image;
+ this.projectName = projectName;
+ }
+ }
}