Task expansion view to match what is shown in the mockups

This commit is contained in:
Keith Uplinger 2013-06-03 23:51:28 -05:00 committed by Rom Walton
parent 0f4457e4f7
commit fcb381b507
10 changed files with 263 additions and 136 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 810 B

View File

@ -20,6 +20,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/white_smoke"
android:orientation="vertical" > android:orientation="vertical" >
<ListView <ListView

View File

@ -20,57 +20,90 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:clickable="false"
android:clickable="true" android:orientation="horizontal" >
android:padding="10dp" >
<ImageView
android:id="@+id/projectIcon"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_margin="10dip"
android:layout_marginLeft="10dip"
android:background="@drawable/shape_blue_border"
android:contentDescription="@drawable/shape_blue_border"
android:padding="1dp"
android:scaleType="fitCenter" />
<TextView android:textAppearance="?android:attr/textAppearanceMedium" <LinearLayout
android:id="@+id/taskHeader"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal" android:layout_marginBottom="5dip"
android:singleLine="true"> android:layout_marginTop="12dip"
</TextView> android:orientation="vertical" >
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="wrap_content"
android:layout_marginRight="10dip"
<ProgressBar android:orientation="horizontal" >
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal" <LinearLayout
android:layout_width="match_parent"
android:layout_height="20dip"
android:progressDrawable="@drawable/progressbar_paused" />
<TextView
android:id="@+id/taskStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_below="@+id/progressBar"
android:layout_alignLeft="@+id/progressBar" />
<TextView android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/taskProgress"
android:singleLine="true"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/progressBar" android:orientation="vertical" >
android:layout_centerInParent="true" />
<TextView
android:id="@+id/taskHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/black"
android:textStyle="bold" />
<TextView
android:id="@+id/projectName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/taskStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/black" />
<TextView
android:id="@+id/taskProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:ems="5"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/black"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<TextView <ImageView
android:id="@+id/taskTime" android:id="@+id/expandCollapse"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" android:layout_alignParentRight="true"
android:layout_below="@+id/progressBar" android:src="@drawable/collapse"
android:layout_alignRight="@+id/progressBar" /> android:contentDescription="@drawable/collapse" />
</RelativeLayout>
</RelativeLayout>
<include
<include android:id="@+id/expansion"
android:id="@+id/expansion" layout="@layout/tasks_layout_listitem_expansion" />
layout="@layout/tasks_layout_listitem_expansion" />
</LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -17,84 +17,159 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with BOINC. If not, see <http://www.gnu.org/licenses/>. along with BOINC. If not, see <http://www.gnu.org/licenses/>.
--> -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:clickable="false" android:clickable="false"
android:orientation="horizontal" > android:orientation="vertical"
android:paddingRight="5dip" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/taskButtons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:gravity="right"
android:orientation="horizontal" >
<ImageView
android:id="@+id/suspendResumeTask"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:contentDescription="@drawable/resumetask"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:src="@drawable/resumetask" />
<ImageView
android:id="@+id/abortTask"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:contentDescription="@drawable/aborttask"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:src="@drawable/aborttask" />
</LinearLayout>
<LinearLayout
android:id="@+id/requestPendingWrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/taskButtons"
android:layout_alignLeft="@id/taskButtons"
android:layout_alignParentRight="true"
android:layout_alignTop="@id/taskButtons"
android:orientation="vertical"
android:visibility="visible" >
<ProgressBar
android:id="@+id/request_progressBar"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp" />
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/taskButtons" >
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="20dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:progressDrawable="@drawable/progressbar_paused" />
</RelativeLayout>
</RelativeLayout>
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="0dip"
android:layout_alignParentLeft="true" android:layout_weight="1"
android:gravity="left"
android:orientation="vertical" > android:orientation="vertical" >
<TextView <LinearLayout
android:id="@+id/projectName" android:layout_width="match_parent"
android:layout_width="wrap_content" android:layout_height="wrap_content" >
android:layout_height="wrap_content"
android:text="@string/tasks_header_project_name" <TextView
android:textAppearance="?android:attr/textAppearanceSmall" /> android:id="@+id/taskTimeLabel"
android:layout_width="wrap_content"
<TextView android:layout_height="wrap_content"
android:id="@+id/taskName" android:paddingRight="5dp"
android:layout_width="wrap_content" android:text="@string/tasks_header_elapsed_time"
android:layout_height="wrap_content" android:textColor="@color/black"
android:text="@string/tasks_header_name" android:textStyle="bold|italic" />
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
<TextView android:id="@+id/taskTime"
android:id="@+id/deadline" android:layout_width="match_parent"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:paddingRight="10dp"
android:text="@string/tasks_header_deadline" android:textAppearance="?android:attr/textAppearanceSmall"
android:textAppearance="?android:attr/textAppearanceSmall" /> android:textColor="@color/black"
android:textStyle="italic" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/taskNameLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dp"
android:text="@string/tasks_header_name"
android:textColor="@color/black"
android:textStyle="bold|italic" />
<TextView
android:id="@+id/taskName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/black"
android:textStyle="italic" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/deadlineLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dp"
android:text="@string/tasks_header_deadline"
android:textColor="@color/black"
android:textStyle="bold|italic" />
<TextView
android:id="@+id/deadline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/black"
android:textStyle="italic" />
</LinearLayout>
</LinearLayout> </LinearLayout>
<LinearLayout </LinearLayout>
android:id="@+id/taskButtons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:orientation="vertical" >
<ImageButton
android:id="@+id/abortTask"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:clickable="true"
android:background="@android:color/black"
android:contentDescription="@string/tasks_button_abort"
android:src="@drawable/abortw24" />
<ImageButton
android:id="@+id/suspendResumeTask"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:clickable="true"
android:background="@android:color/black"
android:contentDescription="@string/tasks_button_resume"
android:src="@drawable/playw24" />
</LinearLayout>
<LinearLayout
android:id="@+id/requestPendingWrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:orientation="vertical"
android:visibility="gone" >
<ProgressBar
android:id="@+id/request_progressBar"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"/>
</LinearLayout>
</RelativeLayout>

View File

@ -211,7 +211,8 @@
<!-- tasks tab strings --> <!-- tasks tab strings -->
<string name="tasks_loading">Reading tasks&#8230;</string> <string name="tasks_loading">Reading tasks&#8230;</string>
<string name="tasks_header_name">ID:</string> <string name="tasks_header_name">Task Name:</string>
<string name="tasks_header_elapsed_time">Elapsed time:</string>
<string name="tasks_header_project_name">Project:</string> <string name="tasks_header_project_name">Project:</string>
<string name="tasks_header_project_paused">(suspended)</string> <string name="tasks_header_project_paused">(suspended)</string>
<string name="tasks_header_deadline">Deadline:</string> <string name="tasks_header_deadline">Deadline:</string>

View File

@ -23,11 +23,13 @@ import java.util.ArrayList;
import edu.berkeley.boinc.R; import edu.berkeley.boinc.R;
import edu.berkeley.boinc.TasksActivity.TaskData; import edu.berkeley.boinc.TasksActivity.TaskData;
import edu.berkeley.boinc.client.Monitor;
import edu.berkeley.boinc.rpc.RpcClient; import edu.berkeley.boinc.rpc.RpcClient;
import edu.berkeley.boinc.utils.BOINCDefs; import edu.berkeley.boinc.utils.BOINCDefs;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -37,7 +39,6 @@ import android.widget.ArrayAdapter;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
public class TasksListAdapter extends ArrayAdapter<TaskData>{ public class TasksListAdapter extends ArrayAdapter<TaskData>{
@ -60,6 +61,15 @@ public class TasksListAdapter extends ArrayAdapter<TaskData>{
v = vi.inflate(R.layout.tasks_layout_listitem, null); v = vi.inflate(R.layout.tasks_layout_listitem, null);
v.setOnClickListener(entries.get(position).taskClickListener); v.setOnClickListener(entries.get(position).taskClickListener);
ImageView ivIcon = (ImageView)v.findViewById(R.id.projectIcon);
Bitmap icon = getIcon(position);
// if available set icon, if not boinc logo
if(icon == null) {
ivIcon.setImageDrawable(getContext().getResources().getDrawable(R.drawable.boinc));
} else {
ivIcon.setImageBitmap(icon);
}
ProgressBar pb = (ProgressBar) v.findViewById(R.id.progressBar); ProgressBar pb = (ProgressBar) v.findViewById(R.id.progressBar);
TextView header = (TextView) v.findViewById(R.id.taskHeader); TextView header = (TextView) v.findViewById(R.id.taskHeader);
TextView status = (TextView) v.findViewById(R.id.taskStatus); TextView status = (TextView) v.findViewById(R.id.taskStatus);
@ -75,6 +85,16 @@ public class TasksListAdapter extends ArrayAdapter<TaskData>{
String headerT = listItem.result.app.getName(); String headerT = listItem.result.app.getName();
header.setText(headerT); header.setText(headerT);
// set project name
String tempProjectName = listItem.result.project_url;
if(listItem.result.project != null) {
tempProjectName = listItem.result.project.getName();
if(listItem.result.project_suspended_via_gui) {
tempProjectName = tempProjectName + " " + getContext().getString(R.string.tasks_header_project_paused);
}
}
((TextView) v.findViewById(R.id.projectName)).setText(tempProjectName);
Float fraction = Float.valueOf((float) 1.0); // default is 100 (e.g. abort show full red progress bar) Float fraction = Float.valueOf((float) 1.0); // default is 100 (e.g. abort show full red progress bar)
if(!listItem.result.active_task && listItem.result.ready_to_report) { //fraction not available if(!listItem.result.active_task && listItem.result.ready_to_report) { //fraction not available
progress.setVisibility(View.GONE); progress.setVisibility(View.GONE);
@ -95,30 +115,22 @@ public class TasksListAdapter extends ArrayAdapter<TaskData>{
else elapsedTime = (int) listItem.result.final_elapsed_time; else elapsedTime = (int) listItem.result.final_elapsed_time;
time.setText(String.format("%02d:%02d:%02d", elapsedTime/3600, (elapsedTime/60)%60, elapsedTime%60)); time.setText(String.format("%02d:%02d:%02d", elapsedTime/3600, (elapsedTime/60)%60, elapsedTime%60));
RelativeLayout ll = (RelativeLayout) v.findViewById(R.id.expansion); LinearLayout ll = (LinearLayout) v.findViewById(R.id.expansion);
if (listItem.expanded) { if (listItem.expanded) {
((ImageView)v.findViewById(R.id.expandCollapse)).setImageResource(R.drawable.expand);
ll.setVisibility(View.VISIBLE); ll.setVisibility(View.VISIBLE);
// update resume/suspend state (button state) // update resume/suspend state (button state)
// set deadline // set deadline
String deadline = (String) DateFormat.format("E d MMM yyyy hh:mm:ss aa", new Date(listItem.result.report_deadline*1000)); String deadline = (String) DateFormat.format("E d MMM yyyy hh:mm:ss aa", new Date(listItem.result.report_deadline*1000));
((TextView) v.findViewById(R.id.deadline)).setText(getContext().getString(R.string.tasks_header_deadline) + " " + deadline); ((TextView) v.findViewById(R.id.deadline)).setText(deadline);
// set project name
String tempProjectName = listItem.result.project_url;
if(listItem.result.project != null) {
tempProjectName = listItem.result.project.getName();
if(listItem.result.project_suspended_via_gui) {
tempProjectName = tempProjectName + " " + getContext().getString(R.string.tasks_header_project_paused);
}
}
((TextView) v.findViewById(R.id.projectName)).setText(getContext().getString(R.string.tasks_header_project_name) + " " + tempProjectName);
// set application friendly name // set application friendly name
if(listItem.result.app != null) { if(listItem.result.app != null) {
((TextView) v.findViewById(R.id.taskName)).setText(getContext().getString(R.string.tasks_header_name) + " " + listItem.result.name); ((TextView) v.findViewById(R.id.taskName)).setText(listItem.result.name);
} }
if(listItem.determineState() == BOINCDefs.PROCESS_ABORTED) { //dont show buttons for aborted task if(listItem.determineState() == BOINCDefs.PROCESS_ABORTED) { //dont show buttons for aborted task
((LinearLayout)v.findViewById(R.id.requestPendingWrapper)).setVisibility(View.GONE); ((LinearLayout)v.findViewById(R.id.requestPendingWrapper)).setVisibility(View.GONE);
((LinearLayout)v.findViewById(R.id.taskButtons)).setVisibility(View.GONE); ((LinearLayout)v.findViewById(R.id.taskButtons)).setVisibility(View.INVISIBLE);
} else { } else {
ImageView suspendResume = (ImageView) v.findViewById(R.id.suspendResumeTask); ImageView suspendResume = (ImageView) v.findViewById(R.id.suspendResumeTask);
@ -135,28 +147,33 @@ public class TasksListAdapter extends ArrayAdapter<TaskData>{
// checking what suspendResume button should be shown // checking what suspendResume button should be shown
if(listItem.result.suspended_via_gui) { // show play if(listItem.result.suspended_via_gui) { // show play
suspendResume.setVisibility(View.VISIBLE); suspendResume.setVisibility(View.VISIBLE);
suspendResume.setImageResource(R.drawable.playw24); suspendResume.setImageResource(R.drawable.resumetask);
suspendResume.setTag(RpcClient.RESULT_RESUME); // tag on button specified operation triggered in iconClickListener suspendResume.setTag(RpcClient.RESULT_RESUME); // tag on button specified operation triggered in iconClickListener
} else if (listItem.determineState() == BOINCDefs.PROCESS_EXECUTING){ // show pause } else if (listItem.determineState() == BOINCDefs.PROCESS_EXECUTING){ // show pause
suspendResume.setVisibility(View.VISIBLE); suspendResume.setVisibility(View.VISIBLE);
suspendResume.setImageResource(R.drawable.pausew24); suspendResume.setImageResource(R.drawable.pausetask);
suspendResume.setTag(RpcClient.RESULT_SUSPEND); // tag on button specified operation triggered in iconClickListener suspendResume.setTag(RpcClient.RESULT_SUSPEND); // tag on button specified operation triggered in iconClickListener
} else { // show nothing } else { // show nothing
suspendResume.setVisibility(View.GONE); suspendResume.setVisibility(View.GONE);
} }
} else { } else {
((LinearLayout)v.findViewById(R.id.taskButtons)).setVisibility(View.GONE); ((LinearLayout)v.findViewById(R.id.taskButtons)).setVisibility(View.INVISIBLE);
((LinearLayout)v.findViewById(R.id.requestPendingWrapper)).setVisibility(View.VISIBLE); ((LinearLayout)v.findViewById(R.id.requestPendingWrapper)).setVisibility(View.VISIBLE);
} }
} }
} else { } else {
((ImageView)v.findViewById(R.id.expandCollapse)).setImageResource(R.drawable.collapse);
ll.setVisibility(View.GONE); ll.setVisibility(View.GONE);
} }
return v; return v;
} }
public Bitmap getIcon(int position) {
return Monitor.getClientStatus().getProjectIcon(entries.get(position).id);
}
private String determineStatusText(TaskData tmp) { private String determineStatusText(TaskData tmp) {