diff --git a/android/BOINC/res/layout/status_layout.xml b/android/BOINC/res/layout/status_layout.xml index 3e247f2ae7..eb658e1be6 100644 --- a/android/BOINC/res/layout/status_layout.xml +++ b/android/BOINC/res/layout/status_layout.xml @@ -90,7 +90,7 @@ android:id="@+id/restarting_text" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/suspend_userreq" + android:text="@string/suspend_user_req" android:textAppearance="?android:attr/textAppearanceSmall" /> diff --git a/android/BOINC/res/values/strings.xml b/android/BOINC/res/values/strings.xml index d30ebbefaa..5c55f1963c 100644 --- a/android/BOINC/res/values/strings.xml +++ b/android/BOINC/res/values/strings.xml @@ -20,8 +20,6 @@ BOINC - BOINC started. - to manage auto-start configuration go to BOINC settings.. /data/data/edu.berkeley.boinc/client/ @@ -105,8 +103,6 @@ Successful. - Starting BOINC… - Closing BOINC… No scientific project attached! tab here to enter account. Whooops …this should not happen!\nClick on the icon to try again. @@ -120,15 +116,18 @@ Event Log Debug - + Computing Thank you for participating! Paused Computation suspended. - Idle + Nothing to do Waiting for tasks… Stopped …until you allow me to continue! + Starting… + Add a project! + Closing… Stop computation Allow computation @@ -238,7 +237,6 @@ No BOINC tasks ready for computation. Not connected to charger. User is active. - Restarting computation… Out of computation time-frame. BOINC is benchmarking your device. Out of disk space. @@ -252,6 +250,7 @@ Can\'t fetch work, no WiFi connection! Your device\'s battery is charging. Your device\'s battery needs to cool down. + Restarting computation… Requested by user diff --git a/android/BOINC/src/edu/berkeley/boinc/BOINCActivity.java b/android/BOINC/src/edu/berkeley/boinc/BOINCActivity.java index 07d7244115..89065b5dc5 100644 --- a/android/BOINC/src/edu/berkeley/boinc/BOINCActivity.java +++ b/android/BOINC/src/edu/berkeley/boinc/BOINCActivity.java @@ -127,35 +127,12 @@ public class BOINCActivity extends TabActivity { } } - /* - public static void logMessage(Context ctx, String tag, String message) { - Intent testLog = new Intent(); - testLog.setAction("edu.berkeley.boinc.log"); - testLog.putExtra("message", message); - testLog.putExtra("tag", tag); - ctx.sendBroadcast(testLog); - }*/ - // tests whether status is available and whether it changed since the last event. private void determineStatus() { Integer newStatus = -1; try { if(mIsBound) { newStatus = Monitor.getClientStatus().setupStatus; - switch(Monitor.getClientStatus().computingStatus) { - case ClientStatus.COMPUTING_STATUS_COMPUTING: - this.setTitle("BOINC - Running"); - break; - case ClientStatus.COMPUTING_STATUS_IDLE: - this.setTitle("BOINC - Idle"); - break; - case ClientStatus.COMPUTING_STATUS_SUSPENDED: - this.setTitle("BOINC - Suspended"); - break; - default: - this.setTitle("BOINC"); - break; - } if(newStatus != clientSetupStatus) { //only act, when status actually different form old status Log.d(TAG,"determineStatus() client setup status changed! old clientSetupStatus: " + clientSetupStatus + " - new: " + newStatus); clientSetupStatus = newStatus; @@ -165,6 +142,7 @@ public class BOINCActivity extends TabActivity { startActivity(new Intent(this,AttachProjectListActivity.class)); intialStart = false; } + setAppTitle(); } } catch (Exception e) {} } @@ -192,7 +170,7 @@ public class BOINCActivity extends TabActivity { errorLayout.setVisibility(View.GONE); loadingLayout.setVisibility(View.VISIBLE); TextView launchingHeader = (TextView) findViewById(R.id.loading_header); - launchingHeader.setText(R.string.main_launching); + launchingHeader.setText(R.string.status_launching); break; case ClientStatus.SETUP_STATUS_NOPROJECT: loadingLayout.setVisibility(View.GONE); @@ -205,7 +183,7 @@ public class BOINCActivity extends TabActivity { errorLayout.setVisibility(View.GONE); loadingLayout.setVisibility(View.VISIBLE); TextView quittingHeader = (TextView) findViewById(R.id.loading_header); - quittingHeader.setText(R.string.main_quitting); + quittingHeader.setText(R.string.status_closing); break; case ClientStatus.SETUP_STATUS_CLOSED: finish(); // close application @@ -276,6 +254,16 @@ public class BOINCActivity extends TabActivity { Log.d(TAG, "tab layout setup done"); } + + // set app title to status string of ClientStatus + private void setAppTitle() { + String title = getString(R.string.app_name); + String status = Monitor.getClientStatus().getCurrentStatusString(); + if (!status.isEmpty()) { + title += " - " + status; + } + this.setTitle(title); + } // triggered by click on noproject_warning, starts login activity public void noProjectClicked(View view) { diff --git a/android/BOINC/src/edu/berkeley/boinc/ProjectsActivity.java b/android/BOINC/src/edu/berkeley/boinc/ProjectsActivity.java index 0a35f0f24e..0560a620fc 100644 --- a/android/BOINC/src/edu/berkeley/boinc/ProjectsActivity.java +++ b/android/BOINC/src/edu/berkeley/boinc/ProjectsActivity.java @@ -38,7 +38,6 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; -import android.view.View.OnClickListener; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; diff --git a/android/BOINC/src/edu/berkeley/boinc/StatusActivity.java b/android/BOINC/src/edu/berkeley/boinc/StatusActivity.java index 4b3969ad6f..603ad47335 100644 --- a/android/BOINC/src/edu/berkeley/boinc/StatusActivity.java +++ b/android/BOINC/src/edu/berkeley/boinc/StatusActivity.java @@ -216,7 +216,7 @@ public class StatusActivity extends Activity { centerWrapper.setVisibility(View.GONE); LinearLayout restartingWrapper = (LinearLayout) findViewById(R.id.restarting_wrapper); restartingWrapper.setVisibility(View.VISIBLE); - statusDescriptor.setText(R.string.suspend_userreq); + statusDescriptor.setText(R.string.suspend_user_req); break; case BOINCDefs.SUSPEND_REASON_TIME_OF_DAY: statusDescriptor.setText(R.string.suspend_tod); diff --git a/android/BOINC/src/edu/berkeley/boinc/adapter/ProjectsListAdapter.java b/android/BOINC/src/edu/berkeley/boinc/adapter/ProjectsListAdapter.java index 39b8dab4e3..7cbc7a0ce2 100644 --- a/android/BOINC/src/edu/berkeley/boinc/adapter/ProjectsListAdapter.java +++ b/android/BOINC/src/edu/berkeley/boinc/adapter/ProjectsListAdapter.java @@ -24,7 +24,6 @@ import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import android.text.format.DateUtils; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; @@ -44,7 +43,7 @@ import edu.berkeley.boinc.rpc.Project; import edu.berkeley.boinc.utils.BOINCUtils; public class ProjectsListAdapter extends ArrayAdapter implements OnItemClickListener { - private final String TAG = "ProjectsListAdapter"; + //private final String TAG = "ProjectsListAdapter"; private ArrayList entries; private Activity activity; diff --git a/android/BOINC/src/edu/berkeley/boinc/adapter/TasksListAdapter.java b/android/BOINC/src/edu/berkeley/boinc/adapter/TasksListAdapter.java index c3967caf4d..e9d04c3f96 100644 --- a/android/BOINC/src/edu/berkeley/boinc/adapter/TasksListAdapter.java +++ b/android/BOINC/src/edu/berkeley/boinc/adapter/TasksListAdapter.java @@ -33,7 +33,6 @@ 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; diff --git a/android/BOINC/src/edu/berkeley/boinc/client/ClientNotification.java b/android/BOINC/src/edu/berkeley/boinc/client/ClientNotification.java index 11972fbfe0..9d171de452 100644 --- a/android/BOINC/src/edu/berkeley/boinc/client/ClientNotification.java +++ b/android/BOINC/src/edu/berkeley/boinc/client/ClientNotification.java @@ -9,7 +9,7 @@ import android.content.Context; import android.content.Intent; public class ClientNotification { - private static final String TAG = "ClientNotification"; + //private static final String TAG = "ClientNotification"; private static final int NOTIFICATION_ID = 460; @@ -66,24 +66,28 @@ public class ClientNotification { private void updateNotification(Context context, int status) { switch(status) { case ClientStatus.COMPUTING_STATUS_NEVER: -// hide(context); -// break; + show(context, R.drawable.ic_stat_notify_boinc_paused, BOINCActivity.class); + break; case ClientStatus.COMPUTING_STATUS_SUSPENDED: + show(context, R.drawable.ic_stat_notify_boinc_paused, BOINCActivity.class); + break; case ClientStatus.COMPUTING_STATUS_IDLE: - show(context, R.drawable.ic_stat_notify_boinc_paused, R.string.status_idle, BOINCActivity.class); + show(context, R.drawable.ic_stat_notify_boinc_paused, BOINCActivity.class); break; case ClientStatus.COMPUTING_STATUS_COMPUTING: - show(context, R.drawable.ic_stat_notify_boinc_normal, R.string.status_running, BOINCActivity.class); + show(context, R.drawable.ic_stat_notify_boinc_normal, BOINCActivity.class); break; } } - private void show(Context context, int icon, int message, Class launchActivity) { + private void show(Context context, int icon, Class launchActivity) { + // get status string from ClientStatus + String statusText = Monitor.getClientStatus().getCurrentStatusString(); // Set the icon, scrolling text and time-stamp Notification notification = new Notification( icon, - context.getText(message), + statusText, System.currentTimeMillis()); // The PendingIntent to launch activity PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, @@ -91,7 +95,7 @@ public class ClientNotification { // Set the info for the views that show in the notification panel. notification.setLatestEventInfo(context, context.getText(R.string.app_name), - context.getText(message), pendingIntent); + statusText, pendingIntent); notification.flags |= Notification.FLAG_NO_CLEAR; NotificationManager nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); diff --git a/android/BOINC/src/edu/berkeley/boinc/client/ClientStatus.java b/android/BOINC/src/edu/berkeley/boinc/client/ClientStatus.java index 182be54801..5195e569e7 100644 --- a/android/BOINC/src/edu/berkeley/boinc/client/ClientStatus.java +++ b/android/BOINC/src/edu/berkeley/boinc/client/ClientStatus.java @@ -25,6 +25,7 @@ import android.content.Intent; import android.os.PowerManager; import android.os.PowerManager.WakeLock; import android.util.Log; +import edu.berkeley.boinc.R; import edu.berkeley.boinc.rpc.CcStatus; import edu.berkeley.boinc.rpc.GlobalPreferences; import edu.berkeley.boinc.rpc.Project; @@ -198,6 +199,55 @@ public class ClientStatus { return projectGraphics; } + // returns a string describing the current client status. + // use this method, to harmonize UI text, e.g. in Notification, Status Tab, App Title. + public String getCurrentStatusString() { + String statusString = ""; + try { + switch(setupStatus) { + case SETUP_STATUS_AVAILABLE: + switch(computingStatus) { + case COMPUTING_STATUS_COMPUTING: + statusString = ctx.getString(R.string.status_running); + break; + case COMPUTING_STATUS_IDLE: + statusString = ctx.getString(R.string.status_idle); + break; + case COMPUTING_STATUS_SUSPENDED: + switch(computingSuspendReason) { + case BOINCDefs.SUSPEND_REASON_USER_REQ: + // restarting after user has previously manually suspended computation + statusString = ctx.getString(R.string.suspend_user_req); + break; + case BOINCDefs.SUSPEND_REASON_BENCHMARKS: + statusString = ctx.getString(R.string.suspend_bm); + break; + default: + statusString = ctx.getString(R.string.status_paused); + break; + } + break; + case COMPUTING_STATUS_NEVER: + statusString = ctx.getString(R.string.status_computing_disabled); + break; + } + break; + case SETUP_STATUS_CLOSING: + statusString = ctx.getString(R.string.status_closing); + break; + case SETUP_STATUS_LAUNCHING: + statusString = ctx.getString(R.string.status_launching); + break; + case SETUP_STATUS_NOPROJECT: + statusString = ctx.getString(R.string.status_noproject); + break; + } + } catch (Exception e) { + Log.w(TAG, "error parsing setup status string",e); + } + return statusString; + } + /* * parses RPC data to ClientStatus data model. */ diff --git a/android/BOINC/src/edu/berkeley/boinc/client/Monitor.java b/android/BOINC/src/edu/berkeley/boinc/client/Monitor.java index 611acbfb7f..d5d5c507d2 100644 --- a/android/BOINC/src/edu/berkeley/boinc/client/Monitor.java +++ b/android/BOINC/src/edu/berkeley/boinc/client/Monitor.java @@ -33,7 +33,6 @@ import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; - import android.app.NotificationManager; import android.app.Service; import android.content.Intent; @@ -53,7 +52,6 @@ import edu.berkeley.boinc.rpc.Project; import edu.berkeley.boinc.rpc.ProjectAttachReply; import edu.berkeley.boinc.rpc.ProjectInfo; import edu.berkeley.boinc.rpc.ProjectConfig; -import edu.berkeley.boinc.rpc.Result; import edu.berkeley.boinc.rpc.RpcClient; import edu.berkeley.boinc.rpc.Transfer; @@ -95,16 +93,16 @@ public class Monitor extends Service { String clientProcessName = clientPath + clientName; String md5AssetClient = ComputeMD5Asset(clientName); - Log.d(TAG, "Hash of client (Asset): '" + md5AssetClient + "'"); + //Log.d(TAG, "Hash of client (Asset): '" + md5AssetClient + "'"); String md5InstalledClient = ComputeMD5File(clientProcessName); - Log.d(TAG, "Hash of client (File): '" + md5InstalledClient + "'"); + //Log.d(TAG, "Hash of client (File): '" + md5InstalledClient + "'"); // If client hashes do not match, we need to install the one that is a part // of the package. Shutdown the currently running client if needed. // if (md5InstalledClient.compareToIgnoreCase(md5AssetClient) != 0) { - + Log.d(TAG,"Hashes of installed client does not match binary in assets - re-install."); // Determine if BOINC is already running. // quitProcessOsLevel(clientProcessName); diff --git a/android/BOINC/src/edu/berkeley/boinc/receiver/BootReceiver.java b/android/BOINC/src/edu/berkeley/boinc/receiver/BootReceiver.java index ce62d7fe56..d8b4c3e477 100644 --- a/android/BOINC/src/edu/berkeley/boinc/receiver/BootReceiver.java +++ b/android/BOINC/src/edu/berkeley/boinc/receiver/BootReceiver.java @@ -19,11 +19,7 @@ package edu.berkeley.boinc.receiver; import edu.berkeley.boinc.AppPreferences; -import edu.berkeley.boinc.BOINCActivity; -import edu.berkeley.boinc.R; import edu.berkeley.boinc.client.Monitor; -import android.app.PendingIntent; -import android.app.Service; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -42,14 +38,10 @@ public class BootReceiver extends BroadcastReceiver { if(prefs.getAutostart()) { Log.d(TAG,"autostart enabled, start Monitor..."); Intent startServiceIntent = new Intent(context, Monitor.class); - //startServiceIntent.putExtra("autostart", true); context.startService(startServiceIntent); - - PendingIntent contentIntent = PendingIntent.getActivity(context.getApplicationContext(), 0, new Intent(context.getApplicationContext(), BOINCActivity.class), 0); - } else { // do nothing - Log.d(TAG,"autostart disabeld"); + Log.d(TAG,"autostart disabeld - do nothing"); } }