Skip to content

Commit b2acce7

Browse files
author
rjmatthews62
committed
Applied patches from Agustin Henze... Issue 592, 605 and 609
1 parent 6acd404 commit b2acce7

File tree

16 files changed

+50
-25
lines changed

16 files changed

+50
-25
lines changed

android/BeanShellForAndroid/.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
66
<classpathentry combineaccessrules="false" kind="src" path="/InterpreterForAndroid"/>
77
<classpathentry combineaccessrules="false" kind="src" path="/Utils"/>
8+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
89
<classpathentry kind="output" path="bin/classes"/>
910
</classpath>

android/BluetoothFacade/src/com/googlecode/android_scripting/facade/BluetoothFacade.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public BluetoothAdapter call() throws Exception {
7272
});
7373
}
7474

75-
@Rpc(description = "Returns true when there's an active Bluetooth connection.")
75+
@Rpc(description = "Returns active Bluetooth connections.")
7676
public Map<String, String> bluetoothActiveConnections() {
7777
Map<String, String> out = new HashMap<String, String>();
7878
for (Map.Entry<String, BluetoothConnection> entry : connections.entrySet()) {

android/Common/src/com/googlecode/android_scripting/facade/LocationFacade.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,17 @@ public void shutdown() {
125125
stopLocating();
126126
}
127127

128+
@Rpc(description = "Returns availables providers on the phone")
129+
public List<String> locationProviders() {
130+
return mLocationManager.getAllProviders();
131+
}
132+
133+
@Rpc(description = "Ask if provider is enabled")
134+
public boolean locationProviderEnabled(
135+
@RpcParameter(name = "provider", description = "Name of location provider") String provider) {
136+
return mLocationManager.isProviderEnabled(provider);
137+
}
138+
128139
@Rpc(description = "Starts collecting location data.")
129140
@RpcStartEvent("location")
130141
public void startLocating(

android/Common/src/com/googlecode/android_scripting/interpreter/html/HtmlActivityTask.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,20 @@ public void register(String eventName, Integer id) {
255255

256256
@Override
257257
public void onEventReceived(Event event) {
258-
JSONObject json = new JSONObject();
258+
final JSONObject json = new JSONObject();
259259
try {
260260
json.put("data", JsonBuilder.build(event.getData()));
261261
} catch (JSONException e) {
262262
Log.e(e);
263263
}
264264
if (mEventMap.containsKey(event.getName())) {
265-
for (Integer id : mEventMap.get(event.getName())) {
266-
mView.loadUrl(String.format("javascript:droid._callback(%d, %s);", id, json));
265+
for (final Integer id : mEventMap.get(event.getName())) {
266+
getActivity().runOnUiThread(new Runnable() {
267+
@Override
268+
public void run() {
269+
mView.loadUrl(String.format("javascript:droid._callback(%d, %s);", id, json));
270+
}
271+
});
267272
}
268273
}
269274
}
@@ -373,4 +378,4 @@ public void run() {
373378
return true;
374379
}
375380
}
376-
}
381+
}

android/InterpreterForAndroidTemplate/.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
<classpathentry kind="src" path="gen"/>
55
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
66
<classpathentry kind="lib" path="libs/interpreter.jar"/>
7+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
78
<classpathentry kind="output" path="bin/classes"/>
89
</classpath>

android/JRubyForAndroid/.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
66
<classpathentry combineaccessrules="false" kind="src" path="/InterpreterForAndroid"/>
77
<classpathentry combineaccessrules="false" kind="src" path="/Utils"/>
8+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
89
<classpathentry kind="output" path="bin/classes"/>
910
</classpath>

android/LuaForAndroid/.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
66
<classpathentry combineaccessrules="false" kind="src" path="/InterpreterForAndroid"/>
77
<classpathentry combineaccessrules="false" kind="src" path="/Utils"/>
8+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
89
<classpathentry kind="output" path="bin/classes"/>
910
</classpath>

android/PerlForAndroid/.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
<classpathentry combineaccessrules="false" kind="src" path="/InterpreterForAndroid"/>
66
<classpathentry combineaccessrules="false" kind="src" path="/Utils"/>
77
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
8+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
89
<classpathentry kind="output" path="bin/classes"/>
910
</classpath>

android/PythonForAndroid/.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
<classpathentry combineaccessrules="false" kind="src" path="/InterpreterForAndroid"/>
77
<classpathentry combineaccessrules="false" kind="src" path="/Utils"/>
88
<classpathentry combineaccessrules="false" kind="src" path="/Common"/>
9+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
910
<classpathentry kind="output" path="bin/classes"/>
1011
</classpath>

android/QuickAction/.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
<classpathentry kind="src" path="src"/>
44
<classpathentry kind="src" path="gen"/>
55
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
6+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
67
<classpathentry kind="output" path="bin/classes"/>
78
</classpath>

android/RhinoForAndroid/.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
66
<classpathentry combineaccessrules="false" kind="src" path="/InterpreterForAndroid"/>
77
<classpathentry combineaccessrules="false" kind="src" path="/Utils"/>
8+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
89
<classpathentry kind="output" path="bin/classes"/>
910
</classpath>

android/ScriptForAndroidTemplate/.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
<classpathentry kind="lib" path="libs/libGoogleAnalytics.jar"/>
88
<classpathentry kind="lib" path="libs/script.jar"/>
99
<classpathentry kind="lib" path="libs/guava-r06.jar"/>
10+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
1011
<classpathentry kind="output" path="bin/classes"/>
1112
</classpath>

android/ScriptingLayerForAndroid/src/com/googlecode/android_scripting/activity/ScriptingLayerService.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import android.os.Binder;
2626
import android.os.IBinder;
2727
import android.preference.PreferenceManager;
28-
import android.widget.RemoteViews;
2928

3029
import com.googlecode.android_scripting.AndroidProxy;
3130
import com.googlecode.android_scripting.BaseApplication;
@@ -64,6 +63,7 @@ public class ScriptingLayerService extends ForegroundService {
6463
private volatile int mModCount = 0;
6564
private NotificationManager mNotificationManager;
6665
private Notification mNotification;
66+
private PendingIntent mNotificationPendingIntent;
6767
private InterpreterConfiguration mInterpreterConfiguration;
6868

6969
private volatile WeakReference<InterpreterProcess> mRecentlyKilledProcess;
@@ -105,21 +105,16 @@ public void onCreate() {
105105
protected Notification createNotification() {
106106
mNotification =
107107
new Notification(R.drawable.sl4a_notification_logo, null, System.currentTimeMillis());
108-
mNotification.contentView = new RemoteViews(getPackageName(), R.layout.notification);
109-
mNotification.contentView.setTextViewText(R.id.notification_title, "SL4A Service");
110-
mNotification.contentView.setTextViewText(R.id.notification_action,
111-
"Tap to view running scripts.");
112108
mNotification.flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
113109
Intent notificationIntent = new Intent(this, ScriptingLayerService.class);
114110
notificationIntent.setAction(Constants.ACTION_SHOW_RUNNING_SCRIPTS);
115-
mNotification.contentIntent = PendingIntent.getService(this, 0, notificationIntent, 0);
111+
mNotificationPendingIntent = PendingIntent.getService(this, 0, notificationIntent, 0);
112+
mNotification.setLatestEventInfo(this, "SL4A Service", "Tap to view running scripts",
113+
mNotificationPendingIntent);
116114
return mNotification;
117115
}
118116

119117
private void updateNotification(String tickerText) {
120-
StringBuilder message = new StringBuilder();
121-
message.append(getText(R.string.script_number_message));
122-
message.append(mProcessMap.size());
123118
mNotification.iconLevel = mProcessMap.size();
124119
if (tickerText.equals(mNotification.tickerText)) {
125120
// Consequent notifications with the same ticker-text are displayed without any ticker-text.
@@ -128,7 +123,13 @@ private void updateNotification(String tickerText) {
128123
} else {
129124
mNotification.tickerText = tickerText;
130125
}
131-
mNotification.contentView.setTextViewText(R.id.notification_message, message);
126+
String msg;
127+
if (mProcessMap.size() <= 1) {
128+
msg = "Tap to view " + Integer.toString(mProcessMap.size()) + " running script";
129+
} else {
130+
msg = "Tap to view " + Integer.toString(mProcessMap.size()) + " running scripts";
131+
}
132+
mNotification.setLatestEventInfo(this, "SL4A Service", msg, mNotificationPendingIntent);
132133
mNotificationManager.notify(NOTIFICATION_ID, mNotification);
133134
}
134135

android/ScriptingLayerForAndroid/src/com/googlecode/android_scripting/activity/TriggerService.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import android.content.Intent;
2424
import android.os.Binder;
2525
import android.os.IBinder;
26-
import android.widget.RemoteViews;
2726

2827
import com.google.common.base.Preconditions;
2928
import com.googlecode.android_scripting.BaseApplication;
@@ -33,9 +32,9 @@
3332
import com.googlecode.android_scripting.R;
3433
import com.googlecode.android_scripting.event.Event;
3534
import com.googlecode.android_scripting.facade.EventFacade;
35+
import com.googlecode.android_scripting.facade.EventFacade.EventObserver;
3636
import com.googlecode.android_scripting.facade.FacadeConfiguration;
3737
import com.googlecode.android_scripting.facade.FacadeManager;
38-
import com.googlecode.android_scripting.facade.EventFacade.EventObserver;
3938
import com.googlecode.android_scripting.trigger.EventGenerationControllingObserver;
4039
import com.googlecode.android_scripting.trigger.Trigger;
4140
import com.googlecode.android_scripting.trigger.TriggerRepository;
@@ -85,8 +84,8 @@ public void onCreate() {
8584
super.onCreate();
8685

8786
mFacadeManager =
88-
new FacadeManager(FacadeConfiguration.getSdkLevel(), this, null, FacadeConfiguration
89-
.getFacadeClasses());
87+
new FacadeManager(FacadeConfiguration.getSdkLevel(), this, null,
88+
FacadeConfiguration.getFacadeClasses());
9089
mEventFacade = mFacadeManager.getReceiver(EventFacade.class);
9190

9291
mTriggerRepository = ((BaseApplication) getApplication()).getTriggerRepository();
@@ -107,13 +106,11 @@ public void onStart(Intent intent, int startId) {
107106
@Override
108107
protected Notification createNotification() {
109108
Notification notification =
110-
new Notification(R.drawable.sl4a_logo_48, "SL4A Trigger Service started.", System
111-
.currentTimeMillis());
112-
notification.contentView = new RemoteViews(getPackageName(), R.layout.notification);
113-
notification.contentView.setTextViewText(R.id.notification_title, "SL4A Trigger Service");
114-
notification.contentView.setTextViewText(R.id.notification_action, "Tap to view triggers.");
109+
new Notification(R.drawable.sl4a_logo_48, "SL4A Trigger Service started.",
110+
System.currentTimeMillis());
115111
Intent notificationIntent = new Intent(this, TriggerManager.class);
116-
notification.contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
112+
notification.setLatestEventInfo(this, "SL4A Trigger Service", "Tap to view triggers",
113+
PendingIntent.getActivity(this, 0, notificationIntent, 0));
117114
notification.flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
118115
return notification;
119116
}

android/ScriptingLayerForAndroidTest/.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
<classpathentry kind="src" path="gen"/>
55
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
66
<classpathentry combineaccessrules="false" kind="src" path="/ScriptingLayerForAndroid"/>
7+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
78
<classpathentry kind="output" path="bin/classes"/>
89
</classpath>

android/TclForAndroid/.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
66
<classpathentry combineaccessrules="false" kind="src" path="/InterpreterForAndroid"/>
77
<classpathentry combineaccessrules="false" kind="src" path="/Utils"/>
8+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
89
<classpathentry kind="output" path="bin/classes"/>
910
</classpath>

0 commit comments

Comments
 (0)