mirror of https://github.com/BOINC/boinc.git
android: visual feedback for task operations
android: corrected status strings android: higher GUI update rate (1s)
This commit is contained in:
parent
9c23a48792
commit
c945adf33c
|
@ -21,25 +21,18 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:clickable="false" >
|
||||
android:clickable="true" >
|
||||
|
||||
<TextView android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:id="@+id/taskName"
|
||||
android:id="@+id/taskHeader"
|
||||
android:text="@string/tasks_header_friendly_name"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
</TextView>
|
||||
|
||||
<LinearLayout
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<TextView android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:id="@+id/taskProgress"
|
||||
android:layout_marginLeft="10dip"
|
||||
android:ems="5"
|
||||
android:singleLine="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
</TextView>
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
|
@ -50,28 +43,31 @@
|
|||
android:layout_height="20dip"
|
||||
android:progressDrawable="@drawable/progressbar_paused" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/taskStatus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
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_height="wrap_content"
|
||||
android:layout_below="@+id/progressBar"
|
||||
android:layout_centerInParent="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/taskTime"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right"
|
||||
android:paddingRight="10dp"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:layout_below="@+id/progressBar"
|
||||
android:layout_alignRight="@+id/progressBar" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<include
|
||||
android:id="@+id/expansion"
|
||||
|
|
|
@ -26,54 +26,75 @@
|
|||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="false"
|
||||
android:layout_centerVertical="false"
|
||||
android:gravity="left"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/projectName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Project Name:"
|
||||
android:text="@string/tasks_header_project_name"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/friendlyAppName"
|
||||
android:id="@+id/taskName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Freindly App Name:"
|
||||
android:text="@string/tasks_header_name"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/deadline"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Deadline:"
|
||||
android:text="@string/tasks_header_deadline"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/taskButtons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ImageView
|
||||
<ImageButton
|
||||
android:id="@+id/abortTask"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@drawable/stopw48"
|
||||
android:background="@android:color/black"
|
||||
android:contentDescription="@string/tasks_button_abort"
|
||||
android:src="@drawable/abortw24" />
|
||||
|
||||
<ImageView
|
||||
<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>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<!-- BOINC platform -->
|
||||
<string name="boinc_platform_name">arm-android-linux-gnu</string>
|
||||
<!-- Monitor behavior -->
|
||||
<integer name="monitor_refresh_rate_ms">5000</integer>
|
||||
<integer name="monitor_refresh_rate_ms">1000</integer>
|
||||
<integer name="monitor_setup_connection_retry_rate_ms">5000</integer>
|
||||
<integer name="monitor_setup_connection_retry_attempts">5</integer>
|
||||
<integer name="autostart_notification_id">460</integer>
|
||||
|
@ -32,4 +32,6 @@
|
|||
<bool name="tab_transfers">true</bool>
|
||||
<bool name="tab_preferences">true</bool>
|
||||
<bool name="tab_eventlog">true</bool>
|
||||
<!-- configuration on tasks layout -->
|
||||
<integer name="tasks_transistion_timeout_number_monitor_loops">10</integer>
|
||||
</resources>
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
<string name="status_idle">Nothing to do</string>
|
||||
<string name="status_idle_long">Waiting for tasks…</string>
|
||||
<string name="status_computing_disabled">Stopped</string>
|
||||
<string name="status_computing_disabled_long">…until you allow me to continue!</string>
|
||||
<string name="status_computing_disabled_long">Allow computation to continue!</string>
|
||||
<string name="status_launching">Starting…</string>
|
||||
<string name="status_noproject">Add a project!</string>
|
||||
<string name="status_closing">Closing…</string>
|
||||
|
@ -183,6 +183,13 @@
|
|||
|
||||
<!-- tasks tab strings -->
|
||||
<string name="tasks_loading">Reading tasks…</string>
|
||||
<string name="tasks_header_name">ID:</string>
|
||||
<string name="tasks_header_friendly_name">Name:</string>
|
||||
<string name="tasks_header_project_name">Project:</string>
|
||||
<string name="tasks_header_deadline">Deadline:</string>
|
||||
<string name="tasks_button_resume">resume task</string>
|
||||
<string name="tasks_button_pause">pause task</string>
|
||||
<string name="tasks_button_abort">abort task</string>
|
||||
<string name="tasks_result_new">new</string>
|
||||
<string name="tasks_result_files_downloading">waiting for download</string>
|
||||
<string name="tasks_result_files_downloaded">download complete</string>
|
||||
|
@ -191,7 +198,6 @@
|
|||
<string name="tasks_result_files_uploaded">upload complete</string>
|
||||
<string name="tasks_result_aborted">aborted</string>
|
||||
<string name="tasks_result_upload_failed">upload failed</string>
|
||||
|
||||
<string name="tasks_active_uninitialized">ready</string>
|
||||
<string name="tasks_active_executing">running</string>
|
||||
<string name="tasks_active_suspended">paused</string>
|
||||
|
@ -236,21 +242,21 @@
|
|||
<!-- suspend reasons -->
|
||||
<string name="suspend_unknown">Computation paused.</string>
|
||||
<string name="suspend_idle">No BOINC tasks ready for computation.</string>
|
||||
<string name="suspend_batteries">Not connected to charger.</string>
|
||||
<string name="suspend_batteries">Connect your device to a charger!</string>
|
||||
<string name="suspend_useractive">User is active.</string>
|
||||
<string name="suspend_tod">Out of computation time-frame.</string>
|
||||
<string name="suspend_bm">BOINC is benchmarking your device.</string>
|
||||
<string name="suspend_bm">BOINC is benchmarking your device…</string>
|
||||
<string name="suspend_disksize">Out of disk space.</string>
|
||||
<string name="suspend_cputhrottle">Your device is busy.</string>
|
||||
<string name="suspend_noinput">No recent tasks available.</string>
|
||||
<string name="suspend_delay">Initialisation delay.</string>
|
||||
<string name="suspend_exclusiveapp">An exclusive app is running.</string>
|
||||
<string name="suspend_cpu">Your device is busy.</string>
|
||||
<string name="suspend_cpu">Your device is busy with a different application.</string>
|
||||
<string name="suspend_network_quota">BOINC reached network transfer limit.</string>
|
||||
<string name="suspend_os">Stopped by Android.</string>
|
||||
<string name="suspend_wifi">Can\'t fetch work, no WiFi connection!</string>
|
||||
<string name="suspend_battery_charging">Your device\'s battery is charging.</string>
|
||||
<string name="suspend_battery_overheating">Your device\'s battery needs to cool down.</string>
|
||||
<string name="suspend_battery_charging">Battery needs to charge prior to computation.</string>
|
||||
<string name="suspend_battery_overheating">Battery needs to cool down.</string>
|
||||
<string name="suspend_user_req">Restarting computation…</string>
|
||||
|
||||
<!-- rpc reasons -->
|
||||
|
|
|
@ -315,7 +315,8 @@ public class PrefsActivity extends FragmentActivity {
|
|||
|
||||
@Override
|
||||
protected Boolean doInBackground(GlobalPreferences... params) {
|
||||
return monitor.setGlobalPreferences(params[0]);
|
||||
if(mIsBound) return monitor.setGlobalPreferences(params[0]);
|
||||
else return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -86,8 +86,7 @@ public class StatusActivity extends Activity {
|
|||
private BroadcastReceiver mClientStatusChangeRec = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context,Intent intent) {
|
||||
String action = intent.getAction();
|
||||
Log.d(TAG+"-localClientStatusRecNoisy","received action " + action);
|
||||
//Log.d(TAG+"-localClientStatusRecNoisy","received action " + intent.getAction());
|
||||
loadLayout(); // load layout, function distincts whether there is something to do
|
||||
}
|
||||
};
|
||||
|
|
|
@ -24,6 +24,7 @@ import edu.berkeley.boinc.adapter.TasksListAdapter;
|
|||
import edu.berkeley.boinc.client.ClientStatus;
|
||||
import edu.berkeley.boinc.client.Monitor;
|
||||
import edu.berkeley.boinc.rpc.Result;
|
||||
import edu.berkeley.boinc.rpc.RpcClient;
|
||||
import edu.berkeley.boinc.utils.BOINCDefs;
|
||||
import android.app.Service;
|
||||
import android.content.BroadcastReceiver;
|
||||
|
@ -33,6 +34,7 @@ import android.content.DialogInterface;
|
|||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
@ -46,7 +48,7 @@ public class TasksActivity extends FragmentActivity {
|
|||
private final String TAG = "BOINC TasksActivity";
|
||||
|
||||
private Monitor monitor;
|
||||
private Boolean mIsBound;
|
||||
private Boolean mIsBound = false;
|
||||
|
||||
private ClientStatus status; //client status, new information gets parsed by monitor, changes notified by "clientstatus" broadcast. read Result from here, to get information about tasks.
|
||||
|
||||
|
@ -72,10 +74,10 @@ public class TasksActivity extends FragmentActivity {
|
|||
|
||||
private BroadcastReceiver mClientStatusChangeRec = new BroadcastReceiver() {
|
||||
|
||||
private final String TAG = "TasksActivity-Receiver";
|
||||
//private final String TAG = "TasksActivity-Receiver";
|
||||
@Override
|
||||
public void onReceive(Context context,Intent intent) {
|
||||
Log.d(TAG,"onReceive");
|
||||
//Log.d(TAG,"onReceive");
|
||||
loadData();
|
||||
}
|
||||
};
|
||||
|
@ -94,8 +96,6 @@ public class TasksActivity extends FragmentActivity {
|
|||
|
||||
//load data model
|
||||
loadData();
|
||||
|
||||
Log.d(TAG, "onCreate");
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
|
@ -141,69 +141,68 @@ public class TasksActivity extends FragmentActivity {
|
|||
setup = true;
|
||||
}
|
||||
|
||||
Log.d(TAG,"loadData: array contains " + data.size() + " results.");
|
||||
Log.d(TAG,"loadData: data set contains " + data.size() + " results.");
|
||||
listAdapter.notifyDataSetChanged(); //force list adapter to refresh
|
||||
|
||||
} else {
|
||||
Log.d(TAG, "loadData array is null");
|
||||
Log.w(TAG, "loadData: array is null, rpc failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updateData(ArrayList<Result> newData) {
|
||||
// Create a new task data list based on new data
|
||||
ArrayList<TaskData> tdl = new ArrayList<TaskData>();
|
||||
for (Result r : newData) {
|
||||
tdl.add(new TaskData(r));
|
||||
}
|
||||
// search for the same id in the old tasks
|
||||
// maybe tasks were rearranged or updated
|
||||
for (int i = 0; i < tdl.size(); i++) {
|
||||
int j;
|
||||
for (j = 0; j < data.size(); j++) {
|
||||
if (tdl.get(i).id.equals(data.get(j).id)) {
|
||||
// this task is old.
|
||||
// retrieve expansion state
|
||||
tdl.get(i).expanded = data.get(j).expanded;
|
||||
break;
|
||||
//loop through all received Result items
|
||||
for(Result rpcResult: newData) {
|
||||
|
||||
//check whether this Result is new
|
||||
Integer index = null;
|
||||
for(int x = 0; x < data.size(); x++) {
|
||||
if(rpcResult.name.equals(data.get(x).id)) {
|
||||
index = x;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (j == data.size()) {
|
||||
// this is a new task, so add it
|
||||
data.add(tdl.get(i));
|
||||
if(index == null) { // result is new, add
|
||||
Log.d(TAG,"new result found, id: " + rpcResult.name);
|
||||
data.add(new TaskData(rpcResult));
|
||||
} else { // result was present before, update its data
|
||||
data.get(index).updateResultData(rpcResult);
|
||||
}
|
||||
}
|
||||
// save new task data list
|
||||
data.clear();
|
||||
|
||||
for (TaskData td: tdl) {
|
||||
data.add(td);
|
||||
}
|
||||
}
|
||||
|
||||
public class TaskData {
|
||||
public static final int TASK_STATE_UNKNOWN = 0;
|
||||
public static final int TASK_STATE_PAUSED = 1;
|
||||
public static final int TASK_STATE_RUNNING = 2;
|
||||
|
||||
public static final int TASK_STATE_ACTIVE = 10;
|
||||
public static final int TASK_STATE_ABORTED = 11;
|
||||
|
||||
public Result result = null;
|
||||
public boolean expanded = false;
|
||||
public String id = "";
|
||||
public int nextRunState = TASK_STATE_UNKNOWN;
|
||||
public int currentRunState = TASK_STATE_UNKNOWN;
|
||||
public int nextAbortState = TASK_STATE_UNKNOWN;
|
||||
public int currentAbortState = TASK_STATE_UNKNOWN;
|
||||
public int nextState = -1;
|
||||
public int loopCounter = 0;
|
||||
public int transistionTimeout = 10; // amount of refresh, until transition times out
|
||||
|
||||
public TaskData(Result data) {
|
||||
this.result = data;
|
||||
this.expanded = false;
|
||||
this.id = data.name;
|
||||
this.currentRunState = determineRunningState();
|
||||
this.nextRunState = this.currentRunState;
|
||||
this.currentAbortState = determineAbortState();
|
||||
this.nextAbortState = this.currentAbortState;
|
||||
this.transistionTimeout = getResources().getInteger(R.integer.tasks_transistion_timeout_number_monitor_loops);
|
||||
}
|
||||
|
||||
public void updateResultData(Result data) {
|
||||
this.result = data;
|
||||
Integer currentState = determineState();
|
||||
if (nextState == -1) return;
|
||||
if(currentState == nextState || (nextState == BOINCDefs.PROCESS_SUSPENDED && currentState == BOINCDefs.PROCESS_UNINITIALIZED)) {
|
||||
Log.d(TAG,"nextState met! " + nextState);
|
||||
nextState = -1;
|
||||
loopCounter = 0;
|
||||
} else {
|
||||
if(loopCounter<transistionTimeout) {
|
||||
Log.d(TAG,"nextState not met yet! " + nextState + " vs " + currentState + " loopCounter: " + loopCounter);
|
||||
loopCounter++;
|
||||
} else {
|
||||
Log.d(TAG,"transition timed out! " + nextState + " vs " + currentState + " loopCounter: " + loopCounter);
|
||||
nextState = -1;
|
||||
loopCounter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final OnClickListener taskClickListener = new OnClickListener() {
|
||||
|
@ -214,66 +213,73 @@ public class TasksActivity extends FragmentActivity {
|
|||
}
|
||||
};
|
||||
|
||||
public final OnClickListener abortClickListener = new OnClickListener() {
|
||||
public final OnClickListener iconClickListener = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ConfirmationDialog cd = ConfirmationDialog.newInstance(
|
||||
getString(R.string.confirm_abort_task_title) + "?",
|
||||
getString(R.string.confirm_abort_task_message) + " " + result.name,
|
||||
getString(R.string.confirm_abort_task_confirm));
|
||||
cd.setConfirmationClicklistener(new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
nextAbortState = TASK_STATE_ABORTED;
|
||||
monitor.abortResultAsync(result.project_url, result.name);
|
||||
try {
|
||||
final Integer operation = (Integer)v.getTag();
|
||||
switch(operation) {
|
||||
case RpcClient.RESULT_SUSPEND:
|
||||
nextState = BOINCDefs.PROCESS_SUSPENDED;
|
||||
new ResultOperationAsync().execute(result.project_url, result.name, operation.toString());
|
||||
break;
|
||||
case RpcClient.RESULT_RESUME:
|
||||
nextState = BOINCDefs.PROCESS_EXECUTING;
|
||||
new ResultOperationAsync().execute(result.project_url, result.name, operation.toString());
|
||||
break;
|
||||
case RpcClient.RESULT_ABORT:
|
||||
ConfirmationDialog cd = ConfirmationDialog.newInstance(
|
||||
getString(R.string.confirm_abort_task_title) + "?",
|
||||
getString(R.string.confirm_abort_task_message) + " " + result.name,
|
||||
getString(R.string.confirm_abort_task_confirm));
|
||||
cd.setConfirmationClicklistener(new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
nextState = BOINCDefs.RESULT_ABORTED;
|
||||
new ResultOperationAsync().execute(result.project_url, result.name, operation.toString());
|
||||
}
|
||||
});
|
||||
cd.show(getSupportFragmentManager(), "");
|
||||
break;
|
||||
default:
|
||||
Log.w(TAG,"could not map operation tag");
|
||||
}
|
||||
});
|
||||
cd.show(getSupportFragmentManager(), "");
|
||||
listAdapter.notifyDataSetChanged(); //force list adapter to refresh
|
||||
listAdapter.notifyDataSetChanged(); //force list adapter to refresh
|
||||
} catch (Exception e) {Log.w(TAG,"failed parsing view tag");}
|
||||
}
|
||||
};
|
||||
|
||||
public final OnClickListener suspendClickListener = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
nextRunState = TASK_STATE_PAUSED;
|
||||
monitor.suspendResultAsync(result.project_url, result.name);
|
||||
listAdapter.notifyDataSetChanged(); //force list adapter to refresh
|
||||
}
|
||||
};
|
||||
|
||||
public final OnClickListener resumeClickListener = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
nextRunState = TASK_STATE_RUNNING;
|
||||
monitor.resumeResultAsync(result.project_url, result.name);
|
||||
listAdapter.notifyDataSetChanged(); //force list adapter to refresh
|
||||
}
|
||||
};
|
||||
|
||||
public int determineRunningState() {
|
||||
if(result.active_task) {
|
||||
if(result.active_task_state == BOINCDefs.PROCESS_EXECUTING) {
|
||||
//running
|
||||
return TASK_STATE_RUNNING;
|
||||
} else {
|
||||
//suspended - ready to run
|
||||
return TASK_STATE_PAUSED;
|
||||
}
|
||||
|
||||
public int determineState() {
|
||||
if(result.active_task){
|
||||
return result.active_task_state;
|
||||
} else {
|
||||
//paused or stopped
|
||||
return TASK_STATE_PAUSED;
|
||||
return result.state;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final class ResultOperationAsync extends AsyncTask<String,Void,Boolean> {
|
||||
|
||||
public int determineAbortState() {
|
||||
if(!result.active_task) {
|
||||
switch (result.state) {
|
||||
case 6:
|
||||
return TASK_STATE_ABORTED;
|
||||
}
|
||||
}
|
||||
return TASK_STATE_ACTIVE;
|
||||
private final String TAG = "SuspendResultAsync";
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(String... params) {
|
||||
try{
|
||||
String url = params[0];
|
||||
String name = params[1];
|
||||
Integer operation = Integer.parseInt(params[2]);
|
||||
Log.d(TAG,"url: " + url + " Name: " + name + " operation: " + operation);
|
||||
|
||||
if(mIsBound) return monitor.resultOperation(url, name, operation);
|
||||
else return false;
|
||||
} catch(Exception e) {Log.w(TAG,"error in do in background",e);}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean success) {
|
||||
if(success) monitor.forceRefresh();
|
||||
else Log.w(TAG,"failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||
|
||||
import edu.berkeley.boinc.R;
|
||||
import edu.berkeley.boinc.TasksActivity.TaskData;
|
||||
import edu.berkeley.boinc.rpc.RpcClient;
|
||||
import edu.berkeley.boinc.utils.BOINCDefs;
|
||||
|
||||
import android.app.Activity;
|
||||
|
@ -33,6 +34,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
@ -58,7 +60,7 @@ public class TasksListAdapter extends ArrayAdapter<TaskData>{
|
|||
v.setOnClickListener(entries.get(position).taskClickListener);
|
||||
|
||||
ProgressBar pb = (ProgressBar) v.findViewById(R.id.progressBar);
|
||||
TextView header = (TextView) v.findViewById(R.id.taskName);
|
||||
TextView header = (TextView) v.findViewById(R.id.taskHeader);
|
||||
TextView status = (TextView) v.findViewById(R.id.taskStatus);
|
||||
TextView time = (TextView) v.findViewById(R.id.taskTime);
|
||||
TextView progress = (TextView) v.findViewById(R.id.taskProgress);
|
||||
|
@ -69,7 +71,7 @@ public class TasksListAdapter extends ArrayAdapter<TaskData>{
|
|||
pb.setProgressDrawable(this.activity.getResources().getDrawable((determineProgressBarLayout(listItem))));
|
||||
|
||||
//v.setTag(listItem.name);
|
||||
String headerT = "Name: " + listItem.result.name;
|
||||
String headerT = getContext().getString(R.string.tasks_header_friendly_name) + " " + listItem.result.app.getName();
|
||||
header.setText(headerT);
|
||||
|
||||
Float fraction = listItem.result.fraction_done;
|
||||
|
@ -90,63 +92,46 @@ public class TasksListAdapter extends ArrayAdapter<TaskData>{
|
|||
if (listItem.expanded) {
|
||||
ll.setVisibility(View.VISIBLE);
|
||||
// update resume/suspend state (button state)
|
||||
listItem.currentRunState = listItem.determineRunningState();
|
||||
// update abort state (button state)
|
||||
listItem.currentAbortState = listItem.determineAbortState();
|
||||
// set deadline
|
||||
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("Deadline: " + deadline);
|
||||
((TextView) v.findViewById(R.id.deadline)).setText(getContext().getString(R.string.tasks_header_deadline) + " " + deadline);
|
||||
// set project name
|
||||
String tempProjectName = listItem.result.project_url;
|
||||
if(listItem.result.project != null) {
|
||||
tempProjectName = listItem.result.project.getName();
|
||||
}
|
||||
((TextView) v.findViewById(R.id.projectName)).setText("Project name: " + tempProjectName);
|
||||
((TextView) v.findViewById(R.id.projectName)).setText(getContext().getString(R.string.tasks_header_project_name) + " " + tempProjectName);
|
||||
// set application friendly name
|
||||
if(listItem.result.app != null) {
|
||||
((TextView) v.findViewById(R.id.friendlyAppName)).setText("App Name: " + listItem.result.app.getName());
|
||||
((TextView) v.findViewById(R.id.taskName)).setText(getContext().getString(R.string.tasks_header_name) + " " + listItem.result.name);
|
||||
}
|
||||
|
||||
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.taskButtons)).setVisibility(View.GONE);
|
||||
} else {
|
||||
|
||||
ImageView suspendResume = (ImageView) v.findViewById(R.id.suspendResumeTask);
|
||||
suspendResume.setOnClickListener(listItem.iconClickListener);
|
||||
|
||||
ImageView suspendResume = (ImageView) v.findViewById(R.id.suspendResumeTask);
|
||||
if (listItem.currentRunState == listItem.nextRunState) {
|
||||
// current button state is same as expected
|
||||
suspendResume.setEnabled(true);
|
||||
suspendResume.setClickable(true);
|
||||
if (listItem.currentRunState == TaskData.TASK_STATE_RUNNING) {
|
||||
suspendResume.setOnClickListener(listItem.suspendClickListener);
|
||||
suspendResume.setImageResource(R.drawable.pausew24);
|
||||
ImageView abortButton = (ImageView) v.findViewById(R.id.abortTask);
|
||||
abortButton.setOnClickListener(listItem.iconClickListener);
|
||||
abortButton.setTag(RpcClient.RESULT_ABORT); // tag on button specified operation triggered in iconClickListener
|
||||
|
||||
if (listItem.nextState == -1) { // not waiting for new state
|
||||
((LinearLayout)v.findViewById(R.id.requestPendingWrapper)).setVisibility(View.GONE);
|
||||
((LinearLayout)v.findViewById(R.id.taskButtons)).setVisibility(View.VISIBLE);
|
||||
if (listItem.determineState() == BOINCDefs.PROCESS_EXECUTING) {
|
||||
suspendResume.setImageResource(R.drawable.pausew24);
|
||||
suspendResume.setTag(RpcClient.RESULT_SUSPEND); // tag on button specified operation triggered in iconClickListener
|
||||
} else {
|
||||
suspendResume.setImageResource(R.drawable.playw24);
|
||||
suspendResume.setTag(RpcClient.RESULT_RESUME); // tag on button specified operation triggered in iconClickListener
|
||||
}
|
||||
} else {
|
||||
suspendResume.setOnClickListener(listItem.resumeClickListener);
|
||||
suspendResume.setImageResource(R.drawable.playw24);
|
||||
((LinearLayout)v.findViewById(R.id.taskButtons)).setVisibility(View.GONE);
|
||||
((LinearLayout)v.findViewById(R.id.requestPendingWrapper)).setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
// waiting for transient state to be as expected
|
||||
// button needs to be disabled (no action should be taken while waiting)
|
||||
suspendResume.setEnabled(false);
|
||||
suspendResume.setClickable(false);
|
||||
suspendResume.setOnClickListener(null);
|
||||
if (listItem.currentRunState == TaskData.TASK_STATE_RUNNING) {
|
||||
suspendResume.setImageResource(R.drawable.pausew24);
|
||||
} else {
|
||||
suspendResume.setImageResource(R.drawable.playw24);
|
||||
}
|
||||
}
|
||||
if (listItem.currentAbortState == listItem.nextAbortState) {
|
||||
// current button state is same as expected
|
||||
if (listItem.currentAbortState == TaskData.TASK_STATE_ABORTED) {
|
||||
suspendResume.setEnabled(false);
|
||||
suspendResume.setClickable(false);
|
||||
} else {
|
||||
suspendResume.setEnabled(true);
|
||||
suspendResume.setClickable(true);
|
||||
((ImageView) v.findViewById(R.id.abortTask)).setOnClickListener(listItem.abortClickListener);
|
||||
}
|
||||
} else {
|
||||
// waiting for transient state to be as expected
|
||||
// button needs to be disabled (no action should be taken while waiting)
|
||||
suspendResume.setEnabled(false);
|
||||
suspendResume.setClickable(false);
|
||||
suspendResume.setOnClickListener(null);
|
||||
}
|
||||
} else {
|
||||
ll.setVisibility(View.GONE);
|
||||
|
@ -159,46 +144,46 @@ public class TasksListAdapter extends ArrayAdapter<TaskData>{
|
|||
String text = "";
|
||||
if(tmp.result.active_task) {
|
||||
switch (tmp.result.active_task_state) {
|
||||
case 0:
|
||||
case BOINCDefs.PROCESS_UNINITIALIZED:
|
||||
text = activity.getString(R.string.tasks_active_uninitialized);
|
||||
break;
|
||||
case 1:
|
||||
case BOINCDefs.PROCESS_EXECUTING:
|
||||
text = activity.getString(R.string.tasks_active_executing);
|
||||
break;
|
||||
case 5:
|
||||
case BOINCDefs.PROCESS_ABORT_PENDING:
|
||||
text = activity.getString(R.string.tasks_active_abort_pending);
|
||||
break;
|
||||
case 8:
|
||||
case BOINCDefs.PROCESS_QUIT_PENDING:
|
||||
text = activity.getString(R.string.tasks_active_quit_pending);
|
||||
break;
|
||||
case 9:
|
||||
case BOINCDefs.PROCESS_SUSPENDED:
|
||||
text = activity.getString(R.string.tasks_active_suspended);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (tmp.result.state) {
|
||||
case 0:
|
||||
case BOINCDefs.RESULT_NEW:
|
||||
text = activity.getString(R.string.tasks_result_new);
|
||||
break;
|
||||
case 1:
|
||||
case BOINCDefs.RESULT_FILES_DOWNLOADING:
|
||||
text = activity.getString(R.string.tasks_result_files_downloading);
|
||||
break;
|
||||
case 2:
|
||||
case BOINCDefs.RESULT_FILES_DOWNLOADED:
|
||||
text = activity.getString(R.string.tasks_result_files_downloaded);
|
||||
break;
|
||||
case 3:
|
||||
case BOINCDefs.RESULT_COMPUTE_ERROR:
|
||||
text = activity.getString(R.string.tasks_result_compute_error);
|
||||
break;
|
||||
case 4:
|
||||
case BOINCDefs.RESULT_FILES_UPLOADING:
|
||||
text = activity.getString(R.string.tasks_result_files_uploading);
|
||||
break;
|
||||
case 5:
|
||||
case BOINCDefs.RESULT_FILES_UPLOADED:
|
||||
text = activity.getString(R.string.tasks_result_files_uploaded);
|
||||
break;
|
||||
case 6:
|
||||
case BOINCDefs.RESULT_ABORTED:
|
||||
text = activity.getString(R.string.tasks_result_aborted);
|
||||
break;
|
||||
case 7:
|
||||
case BOINCDefs.RESULT_UPLOAD_FAILED:
|
||||
text = activity.getString(R.string.tasks_result_upload_failed);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ public class ClientNotification {
|
|||
|
||||
private boolean mIsEnabled = true;
|
||||
private int mOldComputingStatus = -1;
|
||||
private int mOldSuspendReason = -1;
|
||||
|
||||
/**
|
||||
* Returns a reference to a singleton ClientNotification object.
|
||||
|
@ -35,10 +36,12 @@ public class ClientNotification {
|
|||
*/
|
||||
public synchronized void update(Context context, ClientStatus updatedStatus) {
|
||||
if (clientNotification.mOldComputingStatus == -1
|
||||
|| updatedStatus.computingStatus.intValue() != clientNotification.mOldComputingStatus) {
|
||||
|| updatedStatus.computingStatus.intValue() != clientNotification.mOldComputingStatus
|
||||
|| (updatedStatus.computingStatus == ClientStatus.COMPUTING_STATUS_SUSPENDED && updatedStatus.computingSuspendReason != clientNotification.mOldSuspendReason)) {
|
||||
if (clientNotification.mIsEnabled)
|
||||
updateNotification(context, updatedStatus.computingStatus);
|
||||
clientNotification.mOldComputingStatus = updatedStatus.computingStatus;
|
||||
clientNotification.mOldSuspendReason = updatedStatus.computingSuspendReason;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ public class ClientStatus {
|
|||
this.projects = projects;
|
||||
this.transfers = transfers;
|
||||
parseClientStatus();
|
||||
Log.d(TAG,"parsing results: computing: " + computingParseError + computingStatus + computingSuspendReason + " - network: " + networkParseError + networkStatus + networkSuspendReason);
|
||||
Log.d(TAG,"setClientStatus: #results:" + results.size() + " #projects:" + projects.size() + " #transfers:" + transfers.size() + " // computing: " + computingParseError + computingStatus + computingSuspendReason + " - network: " + networkParseError + networkStatus + networkSuspendReason);
|
||||
if(!computingParseError && !networkParseError && !setupStatusParseError) {
|
||||
fire(); // broadcast that status has changed
|
||||
} else {
|
||||
|
|
|
@ -815,40 +815,10 @@ public class Monitor extends Service {
|
|||
(new TransferRetryAsync()).execute(param);
|
||||
}
|
||||
|
||||
public Boolean suspendResult(String url, String name){
|
||||
return rpc.resultOp(RpcClient.RESULT_SUSPEND, url, name);
|
||||
}
|
||||
|
||||
public void suspendResultAsync(String url, String name){
|
||||
Log.d(TAG, "suspendResultAsync");
|
||||
String[] param = new String[2];
|
||||
param[0] = url;
|
||||
param[1] = name;
|
||||
(new SuspendResultAsync()).execute(param);
|
||||
}
|
||||
|
||||
public Boolean resumeResult(String url, String name){
|
||||
return rpc.resultOp(RpcClient.RESULT_RESUME, url, name);
|
||||
}
|
||||
|
||||
public void resumeResultAsync(String url, String name){
|
||||
Log.d(TAG, "resumeResultAsync");
|
||||
String[] param = new String[2];
|
||||
param[0] = url;
|
||||
param[1] = name;
|
||||
(new ResumeResultAsync()).execute(param);
|
||||
}
|
||||
|
||||
public Boolean abortResult(String url, String name){
|
||||
return rpc.resultOp(RpcClient.RESULT_RESUME, url, name);
|
||||
}
|
||||
|
||||
public void abortResultAsync(String url, String name){
|
||||
Log.d(TAG, "abortResultAsync");
|
||||
String[] param = new String[2];
|
||||
param[0] = url;
|
||||
param[1] = name;
|
||||
(new AbortResultAsync()).execute(param);
|
||||
// executes specified operation on result
|
||||
// e.g. RpcClient.RESULT_SUSPEND, RpcClient.RESULT_RESUME, RpcClient.RESULT_ABORT
|
||||
public Boolean resultOperation(String url, String name, int operation) {
|
||||
return rpc.resultOp(operation, url, name);
|
||||
}
|
||||
|
||||
public AccountOut createAccount(String url, String email, String userName, String pwd, String teamName) {
|
||||
|
@ -1103,98 +1073,6 @@ public class Monitor extends Service {
|
|||
}
|
||||
}
|
||||
|
||||
private final class SuspendResultAsync extends AsyncTask<String,String,Boolean> {
|
||||
|
||||
private final String TAG = "SuspendResultAsync";
|
||||
|
||||
private String url;
|
||||
private String name;
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(String... params) {
|
||||
this.url = params[0];
|
||||
this.name = params[1];
|
||||
publishProgress("doInBackground() - SuspendResultAsync url: " + url + " Name: " + name);
|
||||
|
||||
Boolean retry = rpc.resultOp(RpcClient.RESULT_SUSPEND, url, name);
|
||||
if(retry) {
|
||||
publishProgress("successful.");
|
||||
}
|
||||
return retry;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean success) {
|
||||
forceRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onProgressUpdate(String... arg0) {
|
||||
Log.d(TAG, "onProgressUpdate - " + arg0[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private final class ResumeResultAsync extends AsyncTask<String,String,Boolean> {
|
||||
|
||||
private final String TAG = "ResumeResultAsync";
|
||||
|
||||
private String url;
|
||||
private String name;
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(String... params) {
|
||||
this.url = params[0];
|
||||
this.name = params[1];
|
||||
publishProgress("doInBackground() - ResumeResultAsync url: " + url + " Name: " + name);
|
||||
Boolean retry = rpc.resultOp(RpcClient.RESULT_RESUME, url, name);
|
||||
if(retry) {
|
||||
publishProgress("successful.");
|
||||
}
|
||||
return retry;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean success) {
|
||||
forceRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onProgressUpdate(String... arg0) {
|
||||
Log.d(TAG, "onProgressUpdate - " + arg0[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private final class AbortResultAsync extends AsyncTask<String,String,Boolean> {
|
||||
|
||||
private final String TAG = "AbortResultAsync";
|
||||
|
||||
private String url;
|
||||
private String name;
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(String... params) {
|
||||
this.url = params[0];
|
||||
this.name = params[1];
|
||||
publishProgress("doInBackground() - AbortResultAsync url: " + url + " Name: " + name);
|
||||
|
||||
Boolean retry = rpc.resultOp(RpcClient.RESULT_ABORT, url, name);
|
||||
if(retry) {
|
||||
publishProgress("successful.");
|
||||
}
|
||||
return retry;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean success) {
|
||||
forceRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onProgressUpdate(String... arg0) {
|
||||
Log.d(TAG, "onProgressUpdate - " + arg0[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private final class WriteClientRunModeAsync extends AsyncTask<Integer, String, Boolean> {
|
||||
|
||||
private final String TAG = "WriteClientRunModeAsync";
|
||||
|
|
Loading…
Reference in New Issue