mirror of https://github.com/BOINC/boinc.git
android: harmonized status strings
This commit is contained in:
parent
69ab6f570c
commit
e5c698863a
|
@ -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" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
<resources>
|
||||
<!-- app global -->
|
||||
<string name="app_name">BOINC</string>
|
||||
<string name="autostart_notification_header">BOINC started.</string>
|
||||
<string name="autostart_notification_text">to manage auto-start configuration go to BOINC settings..</string>
|
||||
|
||||
<!-- path and file configuration -->
|
||||
<string name="client_path">/data/data/edu.berkeley.boinc/client/</string>
|
||||
|
@ -105,8 +103,6 @@
|
|||
<string name="attachproject_registration_toast_login_successful">Successful.</string>
|
||||
|
||||
<!-- main activity -->
|
||||
<string name="main_launching">Starting BOINC…</string>
|
||||
<string name="main_quitting">Closing BOINC…</string>
|
||||
<string name="main_noproject_warning">No scientific project attached! tab here to enter account.</string>
|
||||
<string name="main_error">Whooops</string>
|
||||
<string name="main_error_long">…this should not happen!\nClick on the icon to try again.</string>
|
||||
|
@ -120,15 +116,18 @@
|
|||
<string name="tab_eventlog">Event Log</string>
|
||||
<string name="tab_debug">Debug</string>
|
||||
|
||||
<!-- status tab strings -->
|
||||
<!-- status strings -->
|
||||
<string name="status_running">Computing</string>
|
||||
<string name="status_running_long">Thank you for participating!</string>
|
||||
<string name="status_paused">Paused</string>
|
||||
<string name="status_paused_long">Computation suspended.</string>
|
||||
<string name="status_idle">Idle</string>
|
||||
<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_launching">Starting…</string>
|
||||
<string name="status_noproject">Add a project!</string>
|
||||
<string name="status_closing">Closing…</string>
|
||||
<string name="disable_computation">Stop computation</string>
|
||||
<string name="enable_computation">Allow computation</string>
|
||||
|
||||
|
@ -238,7 +237,6 @@
|
|||
<string name="suspend_idle">No BOINC tasks ready for computation.</string>
|
||||
<string name="suspend_batteries">Not connected to charger.</string>
|
||||
<string name="suspend_useractive">User is active.</string>
|
||||
<string name="suspend_userreq">Restarting computation…</string>
|
||||
<string name="suspend_tod">Out of computation time-frame.</string>
|
||||
<string name="suspend_bm">BOINC is benchmarking your device.</string>
|
||||
<string name="suspend_disksize">Out of disk space.</string>
|
||||
|
@ -252,6 +250,7 @@
|
|||
<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_user_req">Restarting computation…</string>
|
||||
|
||||
<!-- rpc reasons -->
|
||||
<string name="rpcreason_userreq">Requested by user</string>
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<Project> implements OnItemClickListener {
|
||||
private final String TAG = "ProjectsListAdapter";
|
||||
//private final String TAG = "ProjectsListAdapter";
|
||||
|
||||
private ArrayList<Project> entries;
|
||||
private Activity activity;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue