[android-scripting] push by rjmatthews62 - 5x22 - setFullTitle, and fix to NPE in receive broadcast events. on 2012-07-06 00:42 GMT

5 views
Skip to first unread message

android-...@googlecode.com

unread,
Jul 5, 2012, 8:42:47 PM7/5/12
to android-scri...@googlegroups.com
Revision: c4e4e73702f1
Author: rjmatthews62
Date: Thu Jul 5 17:42:04 2012
Log: 5x22 - setFullTitle, and fix to NPE in receive broadcast events.
http://code.google.com/p/android-scripting/source/detail?r=c4e4e73702f1

Modified:

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

/android/Common/src/com/googlecode/android_scripting/facade/ui/FullScreenTask.java

/android/Common/src/com/googlecode/android_scripting/facade/ui/UiFacade.java
/android/ScriptingLayerForAndroid/AndroidManifest.xml
/android/ScriptingLayerForAndroid/assets/sl4adoc.zip

=======================================
---
/android/Common/src/com/googlecode/android_scripting/facade/EventFacade.java
Sun Apr 29 18:55:54 2012
+++
/android/Common/src/com/googlecode/android_scripting/facade/EventFacade.java
Thu Jul 5 17:42:04 2012
@@ -360,12 +360,16 @@

@Override
public void onReceive(Context context, Intent intent) {
- Bundle data = (Bundle) intent.getExtras().clone();
+ Bundle data;
+ if (intent.getExtras() != null) {
+ data = (Bundle) intent.getExtras().clone();
+ } else {
+ data = new Bundle();
+ }
data.putString("action", intent.getAction());
try {
mParent.eventPost("sl4a", JsonBuilder.build(data).toString(),
mEnQueue);
} catch (JSONException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
}
=======================================
---
/android/Common/src/com/googlecode/android_scripting/facade/ui/FullScreenTask.java
Sun Jun 3 20:45:39 2012
+++
/android/Common/src/com/googlecode/android_scripting/facade/ui/FullScreenTask.java
Thu Jul 5 17:42:04 2012
@@ -35,10 +35,16 @@
protected final CountDownLatch mShowLatch = new CountDownLatch(1);
protected Handler mHandler = null;
private List<Integer> mOverrideKeys;
-
- public FullScreenTask(String layout) {
+ protected String mTitle;
+
+ public FullScreenTask(String layout, String title) {
super();
mLayout = layout;
+ if (title != null) {
+ mTitle = title;
+ } else {
+ mTitle = "SL4a";
+ }
}

@Override
@@ -60,7 +66,7 @@
mInflater.setIdList(R.id.class);
}
getActivity().setContentView(mView);
- getActivity().setTitle("SL4A Title");
+ getActivity().setTitle(mTitle);
mInflater.setClickListener(mView, this, this);
mShowLatch.countDown();
}
@@ -239,6 +245,22 @@
mLatch.countDown();
}
}
+
+ private class SetTitle implements Runnable {
+ String mSetTitle;
+ CountDownLatch mLatch = new CountDownLatch(1);
+
+ SetTitle(String title) {
+ mSetTitle = title;
+ }
+
+ @Override
+ public void run() {
+ mTitle = mSetTitle;
+ getActivity().setTitle(mSetTitle);
+ mLatch.countDown();
+ }
+ }

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
@@ -278,5 +300,15 @@
mInflater.getErrors().add(e.toString());
}
}
+
+ public void setTitle(String title) {
+ SetTitle p = new SetTitle(title);
+ mHandler.post(p);
+ try {
+ p.mLatch.await();
+ } catch (InterruptedException e) {
+ mInflater.getErrors().add(e.toString());
+ }
+ }

}
=======================================
---
/android/Common/src/com/googlecode/android_scripting/facade/ui/UiFacade.java
Sat Jun 2 00:28:01 2012
+++
/android/Common/src/com/googlecode/android_scripting/facade/ui/UiFacade.java
Thu Jul 5 17:42:04 2012
@@ -549,13 +549,17 @@
*/
@Rpc(description = "Show Full Screen.")
public List<String> fullShow(
- @RpcParameter(name = "layout", description = "String containing View
layout") String layout)
+ @RpcParameter(name = "layout", description = "String containing View
layout") String layout,
+ @RpcParameter(name = "title", description = "Activity Title")
@RpcOptional String title)
throws InterruptedException {
if (mFullScreenTask != null) {
// fullDismiss();
mFullScreenTask.setLayout(layout);
+ if (title != null) {
+ mFullScreenTask.setTitle(title);
+ }
} else {
- mFullScreenTask = new FullScreenTask(layout);
+ mFullScreenTask = new FullScreenTask(layout, title);
mFullScreenTask.setEventFacade(mEventFacade);
mFullScreenTask.setUiFacade(this);
mFullScreenTask.setOverrideKeys(mOverrideKeys);
@@ -610,6 +614,15 @@
}
return mFullScreenTask.setList(id, items);
}
+
+ @Rpc(description = "Set the Full Screen Activity Title")
+ public void fullSetTitle(
+ @RpcParameter(name = "title", description = "Activity Title") String
title) {
+ if (mFullScreenTask == null) {
+ throw new RuntimeException("No screen displayed.");
+ }
+ mFullScreenTask.setTitle(title);
+ }

/**
* This will override the default behaviour of keys while in the
fullscreen mode. ie:
=======================================
--- /android/ScriptingLayerForAndroid/AndroidManifest.xml Mon Jun 4
15:11:50 2012
+++ /android/ScriptingLayerForAndroid/AndroidManifest.xml Thu Jul 5
17:42:04 2012
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.googlecode.android_scripting" android:installLocation="auto"
- android:versionCode="521" android:versionName="5x21">
+ android:versionCode="522" android:versionName="5x22">
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission
android:name="net.dinglisch.android.tasker.PERMISSION_RUN_TASKS" />
<uses-permission
android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
=======================================
--- /android/ScriptingLayerForAndroid/assets/sl4adoc.zip Sun Apr 29
19:26:02 2012
+++ /android/ScriptingLayerForAndroid/assets/sl4adoc.zip Thu Jul 5
17:42:04 2012
Binary file, no diff available.
Reply all
Reply to author
Forward
0 new messages