Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding samples

  • Loading branch information...
commit f4a2771f656d6778393a7a70f627e42052d5c04c 1 parent 69d923a
@jamesward authored
Showing with 446 additions and 0 deletions.
  1. +16 −0 samples/notifications/AndroidManifest.xml
  2. +41 −0 samples/notifications/flex-src/Notifier.mxml
  3. +25 −0 samples/notifications/java-src/com/jamesward/MainApp.java
  4. +137 −0 samples/notifications/java-src/com/jamesward/TestService.java
  5. +23 −0 samples/widgets/AndroidManifest.xml
  6. +30 −0 samples/widgets/java-src/com/jamesward/AndroidWidget.java
  7. +15 −0 samples/widgets/java-src/com/jamesward/MainApp.java
  8. BIN  samples/widgets/res/drawable-hdpi/icon.png
  9. BIN  samples/widgets/res/drawable-ldpi/icon.png
  10. BIN  samples/widgets/res/drawable-mdpi/icon.png
  11. BIN  samples/widgets/res/drawable/mp_warning_32x32_n.png
  12. +14 −0 samples/widgets/res/layout/main.xml
  13. 0  samples/widgets/res/raw/debuginfo
  14. +7 −0 samples/widgets/res/values-cs/strings.xml
  15. +7 −0 samples/widgets/res/values-de/strings.xml
  16. +7 −0 samples/widgets/res/values-es/strings.xml
  17. +7 −0 samples/widgets/res/values-fr/strings.xml
  18. +7 −0 samples/widgets/res/values-it/strings.xml
  19. +7 −0 samples/widgets/res/values-ja/strings.xml
  20. +7 −0 samples/widgets/res/values-ko/strings.xml
  21. +7 −0 samples/widgets/res/values-nl/strings.xml
  22. +7 −0 samples/widgets/res/values-pl/strings.xml
  23. +7 −0 samples/widgets/res/values-pt/strings.xml
  24. +7 −0 samples/widgets/res/values-ru/strings.xml
  25. +7 −0 samples/widgets/res/values-sv/strings.xml
  26. +7 −0 samples/widgets/res/values-tr/strings.xml
  27. +7 −0 samples/widgets/res/values-zh-rCN/strings.xml
  28. +7 −0 samples/widgets/res/values-zh-rTW/strings.xml
  29. +4 −0 samples/widgets/res/values/drawables.xml
  30. +12 −0 samples/widgets/res/values/public.xml
  31. +4 −0 samples/widgets/res/values/raws.xml
  32. +7 −0 samples/widgets/res/values/strings.xml
  33. +6 −0 samples/widgets/res/values/styles.xml
  34. +7 −0 samples/widgets/res/xml/airandroidwidget.xml
View
16 samples/notifications/AndroidManifest.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest package="com.jamesward" android:versionCode="1000000" android:versionName="1.0.0"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+ <application android:label="app" android:icon="@drawable/icon">
+ <activity android:theme="@style/Theme.NoShadow" android:label="app" android:name=".MainApp" android:launchMode="singleTask" android:screenOrientation="nosensor" android:configChanges="keyboardHidden|orientation" android:windowSoftInputMode="stateHidden|adjustResize">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <service android:enabled="true" android:name="TestService" />
+ </application>
+ <uses-permission android:name="android.permission.INTERNET"/>
+ <uses-permission android:name="android.permission.VIBRATE"/>
+ <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" />
+</manifest>
View
41 samples/notifications/flex-src/Notifier.mxml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
+ xmlns:s="library://ns.adobe.com/flex/spark">
+
+ <fx:Style>
+ @namespace s "library://ns.adobe.com/flex/spark";
+
+ global {
+ fontSize: 32;
+ }
+ </fx:Style>
+
+ <s:layout>
+ <s:VerticalLayout horizontalAlign="center" paddingTop="20"/>
+ </s:layout>
+
+ <s:TextInput id="t" text="test test"/>
+
+ <s:Button label="create notification">
+ <s:click>
+ <![CDATA[
+ var s:Socket = new Socket();
+ s.connect("localhost", 12345);
+ s.addEventListener(Event.CONNECT, function(event:Event):void {
+ trace('connected!');
+ (event.currentTarget as Socket).writeInt(1);
+ (event.currentTarget as Socket).writeUTF(t.text);
+ (event.currentTarget as Socket).flush();
+ (event.currentTarget as Socket).close();
+ });
+ s.addEventListener(IOErrorEvent.IO_ERROR, function(event:IOErrorEvent):void {
+ trace('error! ' + event.errorID);
+ });
+ s.addEventListener(ProgressEvent.SOCKET_DATA, function(event:ProgressEvent):void {
+ trace('progress ');
+ });
+ ]]>
+ </s:click>
+ </s:Button>
+
+</s:Application>
View
25 samples/notifications/java-src/com/jamesward/MainApp.java
@@ -0,0 +1,25 @@
+package com.jamesward;
+
+import air.app.AppEntry;
+import android.content.Intent;
+import android.os.Bundle;
+
+public class MainApp extends AppEntry {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ try
+ {
+ Intent srv = new Intent(this, TestService.class);
+ startService(srv);
+ }
+ catch (Exception e)
+ {
+ // service could not be started
+ }
+
+ super.onCreate(savedInstanceState);
+ }
+
+}
View
137 samples/notifications/java-src/com/jamesward/TestService.java
@@ -0,0 +1,137 @@
+package com.jamesward;
+
+import java.io.BufferedInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.app.Service;
+import android.content.Context;
+import android.content.Intent;
+import android.os.IBinder;
+import android.os.Looper;
+import android.util.Log;
+
+
+public class TestService extends Service
+{
+ private boolean stopped=false;
+ private Thread serverThread;
+ private ServerSocket ss;
+
+ @Override
+ public IBinder onBind(Intent intent)
+ {
+ return null;
+ }
+
+ @Override
+ public void onCreate()
+ {
+ super.onCreate();
+
+ Log.d(getClass().getSimpleName(), "onCreate");
+
+ serverThread = new Thread(new Runnable() {
+
+ public void run()
+ {
+ try
+ {
+ Looper.prepare();
+ ss = new ServerSocket(12345);
+ ss.setReuseAddress(true);
+ ss.setPerformancePreferences(100, 100, 1);
+ while (!stopped)
+ {
+ Socket accept = ss.accept();
+ accept.setPerformancePreferences(10, 100, 1);
+ accept.setKeepAlive(true);
+
+ DataInputStream _in = null;
+ try
+ {
+ _in = new DataInputStream(new BufferedInputStream(accept.getInputStream(),1024));
+ }
+ catch (IOException e2)
+ {
+ e2.printStackTrace();
+ }
+
+ int method =_in.readInt();
+
+ switch (method)
+ {
+ // notification
+ case 1:
+ doNotification(_in);
+ break;
+ }
+ }
+ }
+ catch (Throwable e)
+ {
+ e.printStackTrace();
+ Log.e(getClass().getSimpleName(), "Error in Listener",e);
+ }
+
+ try
+ {
+ ss.close();
+ }
+ catch (IOException e)
+ {
+ Log.e(getClass().getSimpleName(), "keep it simple");
+ }
+ }
+
+ },"Server thread");
+ serverThread.start();
+
+ }
+
+ private void doNotification(DataInputStream in) throws IOException {
+ String id = in.readUTF();
+ displayNotification(id);
+ }
+
+ @Override
+ public void onDestroy() {
+ stopped=true;
+ try {
+ ss.close();
+ } catch (IOException e) {}
+ serverThread.interrupt();
+ try {
+ serverThread.join();
+ } catch (InterruptedException e) {}
+ }
+
+ public void displayNotification(String notificationString)
+ {
+ int icon = R.drawable.mp_warning_32x32_n;
+ CharSequence tickerText = notificationString;
+ long when = System.currentTimeMillis();
+ Context context = getApplicationContext();
+ CharSequence contentTitle = notificationString;
+ CharSequence contentText = "Hello World!";
+
+ Intent notificationIntent = new Intent(this, MainApp.class);
+ PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
+
+ Notification notification = new Notification(icon, tickerText, when);
+ notification.vibrate = new long[] {0,100,200,300};
+
+ notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
+
+ String ns = Context.NOTIFICATION_SERVICE;
+ NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
+
+ mNotificationManager.notify(1, notification);
+ }
+
+}
View
23 samples/widgets/AndroidManifest.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest package="com.jamesward" android:versionCode="1000000"
+ android:versionName="1.0.0" xmlns:android="http://schemas.android.com/apk/res/android">
+ <application android:label="app" android:icon="@drawable/icon">
+ <activity android:theme="@style/Theme.NoShadow"
+ android:label="app" android:name=".MainApp" android:launchMode="singleTask"
+ android:screenOrientation="nosensor" android:configChanges="keyboardHidden|orientation"
+ android:windowSoftInputMode="stateHidden|adjustResize">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <receiver android:name=".AndroidWidget" android:label="app">
+ <intent-filter>
+ <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
+ </intent-filter>
+ <meta-data android:name="android.appwidget.provider"
+ android:resource="@xml/airandroidwidget" />
+ </receiver>
+ </application>
+ <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" />
+</manifest>
View
30 samples/widgets/java-src/com/jamesward/AndroidWidget.java
@@ -0,0 +1,30 @@
+package com.jamesward;
+
+import android.app.PendingIntent;
+import android.appwidget.AppWidgetManager;
+import android.appwidget.AppWidgetProvider;
+import android.content.Context;
+import android.content.Intent;
+import android.widget.RemoteViews;
+import com.jamesward.MainApp;
+
+public class AndroidWidget extends AppWidgetProvider
+{
+
+ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
+ {
+ final int N = appWidgetIds.length;
+
+ // Perform this loop procedure for each App Widget that belongs to this provider
+ for (int i=0; i<N; i++)
+ {
+ int appWidgetId = appWidgetIds[i];
+ Intent intent = new Intent(context, MainApp.class);
+ intent.setAction(Intent.ACTION_MAIN);
+ PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
+ RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.main);
+ views.setOnClickPendingIntent(R.id.widget, pendingIntent);
+ appWidgetManager.updateAppWidget(appWidgetId, views);
+ }
+ }
+}
View
15 samples/widgets/java-src/com/jamesward/MainApp.java
@@ -0,0 +1,15 @@
+package com.jamesward;
+
+import air.app.AppEntry;
+import android.os.Bundle;
+
+public class MainApp extends AppEntry {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ System.out.println("test test");
+ super.onCreate(savedInstanceState);
+ }
+
+}
View
BIN  samples/widgets/res/drawable-hdpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  samples/widgets/res/drawable-ldpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  samples/widgets/res/drawable-mdpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  samples/widgets/res/drawable/mp_warning_32x32_n.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
14 samples/widgets/res/layout/main.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/widget"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:background="#ffffffff"
+ >
+<TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="hello"
+ />
+</LinearLayout>
View
0  samples/widgets/res/raw/debuginfo
No changes.
View
7 samples/widgets/res/values-cs/strings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="button_yes">Instalovat</string>
+ <string name="button_no">Storno</string>
+ <string name="dialog_title"><b>Adobe® AIR®</b></string>
+ <string name="dialog_text">Tato aplikace vyžaduje prostředí Adobe AIR.\n\nChcete nyní instalovat prostředí Adobe AIR?</string>
+</resources>
View
7 samples/widgets/res/values-de/strings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="button_yes">Installieren</string>
+ <string name="button_no">Abbrechen</string>
+ <string name="dialog_title"><b>Adobe® AIR®</b></string>
+ <string name="dialog_text">Für diese Anwendung ist Adobe AIR erforderlich.\n\nAdobe AIR jetzt installieren?</string>
+</resources>
View
7 samples/widgets/res/values-es/strings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="button_yes">Instalar</string>
+ <string name="button_no">Cancelar</string>
+ <string name="dialog_title"><b>Adobe® AIR®</b></string>
+ <string name="dialog_text">Esta aplicación requiere Adobe AIR.\n\n¿Instalar Adobe AIR ahora?</string>
+</resources>
View
7 samples/widgets/res/values-fr/strings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="button_yes">Installer</string>
+ <string name="button_no">Annuler</string>
+ <string name="dialog_title"><b>Adobe® AIR®</b></string>
+ <string name="dialog_text">Pour utiliser cette application, vous devez installer Adobe AIR.\n\nInstaller Adobe AIR maintenant ?</string>
+</resources>
View
7 samples/widgets/res/values-it/strings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="button_yes">Installa</string>
+ <string name="button_no">Annulla</string>
+ <string name="dialog_title"><b>Adobe® AIR®</b></string>
+ <string name="dialog_text">Questa applicazione richiede Adobe AIR.\n\nInstallare Adobe AIR ora?</string>
+</resources>
View
7 samples/widgets/res/values-ja/strings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="button_yes">インストール</string>
+ <string name="button_no">キャンセル</string>
+ <string name="dialog_title"><b>Adobe® AIR®</b></string>
+ <string name="dialog_text">このアプリケーションを使用するには Adobe AIR が必要です。\n\n今すぐ Adobe AIR をインストールしますか?</string>
+</resources>
View
7 samples/widgets/res/values-ko/strings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="button_yes">설치</string>
+ <string name="button_no">취소</string>
+ <string name="dialog_title"><b>Adobe® AIR®</b></string>
+ <string name="dialog_text">이 응용 프로그램을 사용하려면 Adobe AIR가 설치되어 있어야 합니다.\n\n지금 Adobe AIR를 설치하시겠습니까?</string>
+</resources>
View
7 samples/widgets/res/values-nl/strings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="button_yes">Installeren</string>
+ <string name="button_no">Annuleren</string>
+ <string name="dialog_title"><b>Adobe® AIR®</b></string>
+ <string name="dialog_text">Voor deze toepassing is Adobe AIR nodig.\n\nWilt u Adobe AIR nu installeren?</string>
+</resources>
View
7 samples/widgets/res/values-pl/strings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="button_yes">Zainstaluj</string>
+ <string name="button_no">Anuluj</string>
+ <string name="dialog_title"><b>Adobe® AIR®</b></string>
+ <string name="dialog_text">Ta aplikacja wymaga środowiska Adobe AIR.\n\nCzy zainstalować środowisko Adobe AIR?</string>
+</resources>
View
7 samples/widgets/res/values-pt/strings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="button_yes">Instalar</string>
+ <string name="button_no">Cancelar</string>
+ <string name="dialog_title"><b>Adobe® AIR®</b></string>
+ <string name="dialog_text">Este aplicativo requer o Adobe AIR.\n\nDeseja instalar o Adobe AIR agora?</string>
+</resources>
View
7 samples/widgets/res/values-ru/strings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="button_yes">Установить</string>
+ <string name="button_no">Отмена</string>
+ <string name="dialog_title"><b>Adobe® AIR®</b></string>
+ <string name="dialog_text">Для этого приложения требуется Adobe AIR.\n\nУстановить Adobe AIR?</string>
+</resources>
View
7 samples/widgets/res/values-sv/strings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="button_yes">Installera</string>
+ <string name="button_no">Avbryt</string>
+ <string name="dialog_title"><b>Adobe® AIR®</b></string>
+ <string name="dialog_text">Programmet kräver Adobe AIR.\n\nVill du installera Adobe AIR nu?</string>
+</resources>
View
7 samples/widgets/res/values-tr/strings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="button_yes">Yükle</string>
+ <string name="button_no">İptal</string>
+ <string name="dialog_title"><b>Adobe® AIR®</b></string>
+ <string name="dialog_text">Bu uygulama Adobe AIR gerektiriyor.\n\nAdobe AIR şimdi yüklensin mi?</string>
+</resources>
View
7 samples/widgets/res/values-zh-rCN/strings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="button_yes">安装</string>
+ <string name="button_no">取消</string>
+ <string name="dialog_title"><b>Adobe® AIR®</b></string>
+ <string name="dialog_text">此应用程序需要 Adobe AIR。\n\n是否立即安装 Adobe AIR?</string>
+</resources>
View
7 samples/widgets/res/values-zh-rTW/strings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="button_yes">安裝</string>
+ <string name="button_no">取消</string>
+ <string name="dialog_title"><b>Adobe® AIR®</b></string>
+ <string name="dialog_text">此應用程式需要 Adobe AIR。\n\n是否立即安裝 Adobe AIR?</string>
+</resources>
View
4 samples/widgets/res/values/drawables.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <item type="drawable" name="icon">false</item>
+</resources>
View
12 samples/widgets/res/values/public.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <public type="drawable" name="icon" id="0x7f020000" />
+ <public type="drawable" name="mp_warning_32x32_n" id="0x7f020001" />
+ <public type="raw" name="debugger" id="0x7f030000" />
+ <public type="raw" name="debuginfo" id="0x7f030001" />
+ <public type="string" name="button_yes" id="0x7f040000" />
+ <public type="string" name="button_no" id="0x7f040001" />
+ <public type="string" name="dialog_title" id="0x7f040002" />
+ <public type="string" name="dialog_text" id="0x7f040003" />
+ <public type="style" name="Theme.NoShadow" id="0x7f050000" />
+</resources>
View
4 samples/widgets/res/values/raws.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <item type="raw" name="debugger">false</item>
+</resources>
View
7 samples/widgets/res/values/strings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <string name="button_yes">Install</string>
+ <string name="button_no">Cancel</string>
+ <string name="dialog_title"><b>Adobe® AIR®</b></string>
+ <string name="dialog_text">This application requires Adobe AIR.\n\nInstall Adobe AIR now?</string>
+</resources>
View
6 samples/widgets/res/values/styles.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <style name="Theme.NoShadow" parent="@android:style/Theme.NoTitleBar">
+ <item name="android:windowContentOverlay">@null</item>
+ </style>
+</resources>
View
7 samples/widgets/res/xml/airandroidwidget.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
+ android:minWidth="294dp"
+ android:minHeight="72dp"
+ android:updatePeriodMillis="86400000"
+ android:initialLayout="@layout/main">
+</appwidget-provider>
Please sign in to comment.
Something went wrong with that request. Please try again.