diff options
Diffstat (limited to 'client/Piztor')
46 files changed, 545 insertions, 0 deletions
diff --git a/client/Piztor/.classpath b/client/Piztor/.classpath new file mode 100644 index 0000000..7bc01d9 --- /dev/null +++ b/client/Piztor/.classpath @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="gen"/> + <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> + <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> + <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> + <classpathentry kind="output" path="bin/classes"/> +</classpath> diff --git a/client/Piztor/.project b/client/Piztor/.project new file mode 100644 index 0000000..97100ec --- /dev/null +++ b/client/Piztor/.project @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>Piztor</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>com.android.ide.eclipse.adt.ApkBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>com.android.ide.eclipse.adt.AndroidNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/client/Piztor/.settings/org.eclipse.jdt.core.prefs b/client/Piztor/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..b080d2d --- /dev/null +++ b/client/Piztor/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/client/Piztor/AndroidManifest.xml b/client/Piztor/AndroidManifest.xml new file mode 100644 index 0000000..63cb8ff --- /dev/null +++ b/client/Piztor/AndroidManifest.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.macaroon.piztor" + android:versionCode="1" + android:versionName="1.0" > + + <uses-sdk + android:minSdkVersion="8" + android:targetSdkVersion="17" /> + + <application + android:allowBackup="true" + android:icon="@drawable/ic_launcher" + android:label="@string/app_name" + android:theme="@style/AppTheme" > + <activity + android:name="com.macaroon.piztor.Main" + android:label="@string/app_name" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + <activity + android:name="com.macaroon.piztor.InitAct" + android:label="@string/title_activity_init" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> + +</manifest> diff --git a/client/Piztor/bin/AndroidManifest.xml b/client/Piztor/bin/AndroidManifest.xml new file mode 100644 index 0000000..63cb8ff --- /dev/null +++ b/client/Piztor/bin/AndroidManifest.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.macaroon.piztor" + android:versionCode="1" + android:versionName="1.0" > + + <uses-sdk + android:minSdkVersion="8" + android:targetSdkVersion="17" /> + + <application + android:allowBackup="true" + android:icon="@drawable/ic_launcher" + android:label="@string/app_name" + android:theme="@style/AppTheme" > + <activity + android:name="com.macaroon.piztor.Main" + android:label="@string/app_name" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + <activity + android:name="com.macaroon.piztor.InitAct" + android:label="@string/title_activity_init" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> + +</manifest> diff --git a/client/Piztor/bin/classes/com/macaroon/piztor/ActMgr.class b/client/Piztor/bin/classes/com/macaroon/piztor/ActMgr.class Binary files differnew file mode 100644 index 0000000..1b1c693 --- /dev/null +++ b/client/Piztor/bin/classes/com/macaroon/piztor/ActMgr.class diff --git a/client/Piztor/bin/classes/com/macaroon/piztor/ActStatus.class b/client/Piztor/bin/classes/com/macaroon/piztor/ActStatus.class Binary files differnew file mode 100644 index 0000000..1f3df48 --- /dev/null +++ b/client/Piztor/bin/classes/com/macaroon/piztor/ActStatus.class diff --git a/client/Piztor/bin/classes/com/macaroon/piztor/AppMgr$ActivityStatus.class b/client/Piztor/bin/classes/com/macaroon/piztor/AppMgr$ActivityStatus.class Binary files differnew file mode 100644 index 0000000..496344b --- /dev/null +++ b/client/Piztor/bin/classes/com/macaroon/piztor/AppMgr$ActivityStatus.class diff --git a/client/Piztor/bin/classes/com/macaroon/piztor/AppMgr.class b/client/Piztor/bin/classes/com/macaroon/piztor/AppMgr.class Binary files differnew file mode 100644 index 0000000..107bcad --- /dev/null +++ b/client/Piztor/bin/classes/com/macaroon/piztor/AppMgr.class diff --git a/client/Piztor/bin/classes/com/macaroon/piztor/BuildConfig.class b/client/Piztor/bin/classes/com/macaroon/piztor/BuildConfig.class Binary files differnew file mode 100644 index 0000000..566eb01 --- /dev/null +++ b/client/Piztor/bin/classes/com/macaroon/piztor/BuildConfig.class diff --git a/client/Piztor/bin/classes/com/macaroon/piztor/EmptyStatus.class b/client/Piztor/bin/classes/com/macaroon/piztor/EmptyStatus.class Binary files differnew file mode 100644 index 0000000..c656689 --- /dev/null +++ b/client/Piztor/bin/classes/com/macaroon/piztor/EmptyStatus.class diff --git a/client/Piztor/bin/classes/com/macaroon/piztor/InitAct.class b/client/Piztor/bin/classes/com/macaroon/piztor/InitAct.class Binary files differnew file mode 100644 index 0000000..6a8e04d --- /dev/null +++ b/client/Piztor/bin/classes/com/macaroon/piztor/InitAct.class diff --git a/client/Piztor/bin/classes/com/macaroon/piztor/PiztorAct.class b/client/Piztor/bin/classes/com/macaroon/piztor/PiztorAct.class Binary files differnew file mode 100644 index 0000000..4a3fc81 --- /dev/null +++ b/client/Piztor/bin/classes/com/macaroon/piztor/PiztorAct.class diff --git a/client/Piztor/bin/classes/com/macaroon/piztor/R$attr.class b/client/Piztor/bin/classes/com/macaroon/piztor/R$attr.class Binary files differnew file mode 100644 index 0000000..a95e1ab --- /dev/null +++ b/client/Piztor/bin/classes/com/macaroon/piztor/R$attr.class diff --git a/client/Piztor/bin/classes/com/macaroon/piztor/R$dimen.class b/client/Piztor/bin/classes/com/macaroon/piztor/R$dimen.class Binary files differnew file mode 100644 index 0000000..4bc657f --- /dev/null +++ b/client/Piztor/bin/classes/com/macaroon/piztor/R$dimen.class diff --git a/client/Piztor/bin/classes/com/macaroon/piztor/R$drawable.class b/client/Piztor/bin/classes/com/macaroon/piztor/R$drawable.class Binary files differnew file mode 100644 index 0000000..5444d98 --- /dev/null +++ b/client/Piztor/bin/classes/com/macaroon/piztor/R$drawable.class diff --git a/client/Piztor/bin/classes/com/macaroon/piztor/R$id.class b/client/Piztor/bin/classes/com/macaroon/piztor/R$id.class Binary files differnew file mode 100644 index 0000000..8577179 --- /dev/null +++ b/client/Piztor/bin/classes/com/macaroon/piztor/R$id.class diff --git a/client/Piztor/bin/classes/com/macaroon/piztor/R$layout.class b/client/Piztor/bin/classes/com/macaroon/piztor/R$layout.class Binary files differnew file mode 100644 index 0000000..fab7556 --- /dev/null +++ b/client/Piztor/bin/classes/com/macaroon/piztor/R$layout.class diff --git a/client/Piztor/bin/classes/com/macaroon/piztor/R$menu.class b/client/Piztor/bin/classes/com/macaroon/piztor/R$menu.class Binary files differnew file mode 100644 index 0000000..cec6e5a --- /dev/null +++ b/client/Piztor/bin/classes/com/macaroon/piztor/R$menu.class diff --git a/client/Piztor/bin/classes/com/macaroon/piztor/R$string.class b/client/Piztor/bin/classes/com/macaroon/piztor/R$string.class Binary files differnew file mode 100644 index 0000000..a78c834 --- /dev/null +++ b/client/Piztor/bin/classes/com/macaroon/piztor/R$string.class diff --git a/client/Piztor/bin/classes/com/macaroon/piztor/R$style.class b/client/Piztor/bin/classes/com/macaroon/piztor/R$style.class Binary files differnew file mode 100644 index 0000000..42ddcce --- /dev/null +++ b/client/Piztor/bin/classes/com/macaroon/piztor/R$style.class diff --git a/client/Piztor/bin/classes/com/macaroon/piztor/R.class b/client/Piztor/bin/classes/com/macaroon/piztor/R.class Binary files differnew file mode 100644 index 0000000..d173856 --- /dev/null +++ b/client/Piztor/bin/classes/com/macaroon/piztor/R.class diff --git a/client/Piztor/gen/com/macaroon/piztor/BuildConfig.java b/client/Piztor/gen/com/macaroon/piztor/BuildConfig.java new file mode 100644 index 0000000..833e650 --- /dev/null +++ b/client/Piztor/gen/com/macaroon/piztor/BuildConfig.java @@ -0,0 +1,6 @@ +/** Automatically generated file. DO NOT MODIFY */ +package com.macaroon.piztor; + +public final class BuildConfig { + public final static boolean DEBUG = true; +}
\ No newline at end of file diff --git a/client/Piztor/gen/com/macaroon/piztor/R.java b/client/Piztor/gen/com/macaroon/piztor/R.java new file mode 100644 index 0000000..9821c7f --- /dev/null +++ b/client/Piztor/gen/com/macaroon/piztor/R.java @@ -0,0 +1,70 @@ +/* AUTO-GENERATED FILE. DO NOT MODIFY. + * + * This class was automatically generated by the + * aapt tool from the resource data it found. It + * should not be modified by hand. + */ + +package com.macaroon.piztor; + +public final class R { + public static final class attr { + } + public static final class dimen { + /** Default screen margins, per the Android Design guidelines. + + Customize dimensions originally defined in res/values/dimens.xml (such as + screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. + + */ + public static final int activity_horizontal_margin=0x7f040000; + public static final int activity_vertical_margin=0x7f040001; + } + public static final class drawable { + public static final int ic_launcher=0x7f020000; + } + public static final class id { + public static final int action_settings=0x7f080000; + } + public static final class layout { + public static final int activity_init=0x7f030000; + } + public static final class menu { + public static final int init=0x7f070000; + public static final int main=0x7f070001; + } + public static final class string { + public static final int action_settings=0x7f050001; + public static final int app_name=0x7f050000; + public static final int hello_world=0x7f050002; + public static final int title_activity_init=0x7f050003; + } + public static final class style { + /** + Base application theme, dependent on API level. This theme is replaced + by AppBaseTheme from res/values-vXX/styles.xml on newer devices. + + + Theme customizations available in newer API levels can go in + res/values-vXX/styles.xml, while customizations related to + backward-compatibility can go here. + + + Base application theme for API 11+. This theme completely replaces + AppBaseTheme from res/values/styles.xml on API 11+ devices. + + API 11 theme customizations can go here. + + Base application theme for API 14+. This theme completely replaces + AppBaseTheme from BOTH res/values/styles.xml and + res/values-v11/styles.xml on API 14+ devices. + + API 14 theme customizations can go here. + */ + public static final int AppBaseTheme=0x7f060000; + /** Application theme. + All customizations that are NOT specific to a particular API-level can go here. + */ + public static final int AppTheme=0x7f060001; + } +} diff --git a/client/Piztor/ic_launcher-web.png b/client/Piztor/ic_launcher-web.png Binary files differnew file mode 100644 index 0000000..a18cbb4 --- /dev/null +++ b/client/Piztor/ic_launcher-web.png diff --git a/client/Piztor/libs/android-support-v4.jar b/client/Piztor/libs/android-support-v4.jar Binary files differnew file mode 100644 index 0000000..cf12d28 --- /dev/null +++ b/client/Piztor/libs/android-support-v4.jar diff --git a/client/Piztor/proguard-project.txt b/client/Piztor/proguard-project.txt new file mode 100644 index 0000000..f2fe155 --- /dev/null +++ b/client/Piztor/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/client/Piztor/project.properties b/client/Piztor/project.properties new file mode 100644 index 0000000..ce39f2d --- /dev/null +++ b/client/Piztor/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-18 diff --git a/client/Piztor/res/drawable-hdpi/ic_launcher.png b/client/Piztor/res/drawable-hdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..288b665 --- /dev/null +++ b/client/Piztor/res/drawable-hdpi/ic_launcher.png diff --git a/client/Piztor/res/drawable-mdpi/ic_launcher.png b/client/Piztor/res/drawable-mdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..6ae570b --- /dev/null +++ b/client/Piztor/res/drawable-mdpi/ic_launcher.png diff --git a/client/Piztor/res/drawable-xhdpi/ic_launcher.png b/client/Piztor/res/drawable-xhdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..d4fb7cd --- /dev/null +++ b/client/Piztor/res/drawable-xhdpi/ic_launcher.png diff --git a/client/Piztor/res/drawable-xxhdpi/ic_launcher.png b/client/Piztor/res/drawable-xxhdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..85a6081 --- /dev/null +++ b/client/Piztor/res/drawable-xxhdpi/ic_launcher.png diff --git a/client/Piztor/res/layout/activity_init.xml b/client/Piztor/res/layout/activity_init.xml new file mode 100644 index 0000000..43e6253 --- /dev/null +++ b/client/Piztor/res/layout/activity_init.xml @@ -0,0 +1,16 @@ +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:paddingBottom="@dimen/activity_vertical_margin" + android:paddingLeft="@dimen/activity_horizontal_margin" + android:paddingRight="@dimen/activity_horizontal_margin" + android:paddingTop="@dimen/activity_vertical_margin" + tools:context=".InitAct" > + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/hello_world" /> + +</RelativeLayout> diff --git a/client/Piztor/res/menu/init.xml b/client/Piztor/res/menu/init.xml new file mode 100644 index 0000000..c002028 --- /dev/null +++ b/client/Piztor/res/menu/init.xml @@ -0,0 +1,9 @@ +<menu xmlns:android="http://schemas.android.com/apk/res/android" > + + <item + android:id="@+id/action_settings" + android:orderInCategory="100" + android:showAsAction="never" + android:title="@string/action_settings"/> + +</menu> diff --git a/client/Piztor/res/menu/main.xml b/client/Piztor/res/menu/main.xml new file mode 100644 index 0000000..c002028 --- /dev/null +++ b/client/Piztor/res/menu/main.xml @@ -0,0 +1,9 @@ +<menu xmlns:android="http://schemas.android.com/apk/res/android" > + + <item + android:id="@+id/action_settings" + android:orderInCategory="100" + android:showAsAction="never" + android:title="@string/action_settings"/> + +</menu> diff --git a/client/Piztor/res/values-sw600dp/dimens.xml b/client/Piztor/res/values-sw600dp/dimens.xml new file mode 100644 index 0000000..44f01db --- /dev/null +++ b/client/Piztor/res/values-sw600dp/dimens.xml @@ -0,0 +1,8 @@ +<resources> + + <!-- + Customize dimensions originally defined in res/values/dimens.xml (such as + screen margins) for sw600dp devices (e.g. 7" tablets) here. + --> + +</resources> diff --git a/client/Piztor/res/values-sw720dp-land/dimens.xml b/client/Piztor/res/values-sw720dp-land/dimens.xml new file mode 100644 index 0000000..61e3fa8 --- /dev/null +++ b/client/Piztor/res/values-sw720dp-land/dimens.xml @@ -0,0 +1,9 @@ +<resources> + + <!-- + Customize dimensions originally defined in res/values/dimens.xml (such as + screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. + --> + <dimen name="activity_horizontal_margin">128dp</dimen> + +</resources> diff --git a/client/Piztor/res/values-v11/styles.xml b/client/Piztor/res/values-v11/styles.xml new file mode 100644 index 0000000..3c02242 --- /dev/null +++ b/client/Piztor/res/values-v11/styles.xml @@ -0,0 +1,11 @@ +<resources> + + <!-- + Base application theme for API 11+. This theme completely replaces + AppBaseTheme from res/values/styles.xml on API 11+ devices. + --> + <style name="AppBaseTheme" parent="android:Theme.Holo.Light"> + <!-- API 11 theme customizations can go here. --> + </style> + +</resources> diff --git a/client/Piztor/res/values-v14/styles.xml b/client/Piztor/res/values-v14/styles.xml new file mode 100644 index 0000000..a91fd03 --- /dev/null +++ b/client/Piztor/res/values-v14/styles.xml @@ -0,0 +1,12 @@ +<resources> + + <!-- + Base application theme for API 14+. This theme completely replaces + AppBaseTheme from BOTH res/values/styles.xml and + res/values-v11/styles.xml on API 14+ devices. + --> + <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar"> + <!-- API 14 theme customizations can go here. --> + </style> + +</resources> diff --git a/client/Piztor/res/values/dimens.xml b/client/Piztor/res/values/dimens.xml new file mode 100644 index 0000000..55c1e59 --- /dev/null +++ b/client/Piztor/res/values/dimens.xml @@ -0,0 +1,7 @@ +<resources> + + <!-- Default screen margins, per the Android Design guidelines. --> + <dimen name="activity_horizontal_margin">16dp</dimen> + <dimen name="activity_vertical_margin">16dp</dimen> + +</resources> diff --git a/client/Piztor/res/values/strings.xml b/client/Piztor/res/values/strings.xml new file mode 100644 index 0000000..8e76dc0 --- /dev/null +++ b/client/Piztor/res/values/strings.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="app_name">Piztor</string> + <string name="action_settings">Settings</string> + <string name="hello_world">Hello world!</string> + <string name="title_activity_init">InitAct</string> + +</resources> diff --git a/client/Piztor/res/values/styles.xml b/client/Piztor/res/values/styles.xml new file mode 100644 index 0000000..6ce89c7 --- /dev/null +++ b/client/Piztor/res/values/styles.xml @@ -0,0 +1,20 @@ +<resources> + + <!-- + Base application theme, dependent on API level. This theme is replaced + by AppBaseTheme from res/values-vXX/styles.xml on newer devices. + --> + <style name="AppBaseTheme" parent="android:Theme.Light"> + <!-- + Theme customizations available in newer API levels can go in + res/values-vXX/styles.xml, while customizations related to + backward-compatibility can go here. + --> + </style> + + <!-- Application theme. --> + <style name="AppTheme" parent="AppBaseTheme"> + <!-- All customizations that are NOT specific to a particular API-level can go here. --> + </style> + +</resources> diff --git a/client/Piztor/src/com/macaroon/piztor/ActMgr.java b/client/Piztor/src/com/macaroon/piztor/ActMgr.java new file mode 100644 index 0000000..81fa6f2 --- /dev/null +++ b/client/Piztor/src/com/macaroon/piztor/ActMgr.java @@ -0,0 +1,63 @@ +package com.macaroon.piztor; + +import java.util.*; + +import android.annotation.SuppressLint; + +@SuppressLint("UseSparseArrays") +public class ActMgr { + // event + PiztorAct act; + ActStatus nowStatus; + HashMap<ActStatus, HashMap<Integer, ActStatus>> mp; + + ActMgr(PiztorAct act, ActStatus nowStatus, ActStatus[] r) { + this.act = act; + this.nowStatus = nowStatus; + mp = new HashMap<ActStatus, HashMap<Integer, ActStatus>>(); + for (int i = 0; i < r.length; i++) { + mp.put(r[i], new HashMap<Integer, ActStatus>()); + } + } + + void trigger(int event) { + for (Integer i : mp.get(nowStatus).keySet()) + System.out.println(i); + if (mp.get(nowStatus).containsKey(event)) { + nowStatus.leave(event); + nowStatus = mp.get(nowStatus).get(event); + nowStatus.enter(event); + } else if (AppMgr.mp.get(act.getClass()).containsKey(event)) { + AppMgr.trigger(event); + } + } + + void add(ActStatus a, int event, ActStatus b) { + if (mp.containsKey(a)) { + HashMap<Integer, ActStatus> h = mp.get(a); + h.put(event, b); + mp.put(a, h); + } else { + HashMap<Integer, ActStatus> h = new HashMap<Integer, ActStatus>(); + h.put(event, b); + mp.put(a, h); + } + } +} + +abstract class ActStatus { + abstract void enter(int e); + + abstract void leave(int e); +} + +class EmptyStatus extends ActStatus { + @Override + void enter(int e) { + } + + @Override + void leave(int e) { + } + +} diff --git a/client/Piztor/src/com/macaroon/piztor/AppMgr.java b/client/Piztor/src/com/macaroon/piztor/AppMgr.java new file mode 100644 index 0000000..9259786 --- /dev/null +++ b/client/Piztor/src/com/macaroon/piztor/AppMgr.java @@ -0,0 +1,62 @@ +package com.macaroon.piztor; + +import java.util.HashMap; + +import android.annotation.SuppressLint; +import android.content.Intent; + +@SuppressLint("UseSparseArrays") +public class AppMgr { + // Status + public enum ActivityStatus{ + create, start, resume, restart, stop, pause, destroy + } + static ActivityStatus status; + static PiztorAct nowAct; + + static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp; + + static void setStatus(ActivityStatus st) { + status = st; + } + + static void trigger(int event) { + + Intent i = new Intent(); + i.setClass(nowAct, mp.get(nowAct.getClass()).get(event)); + nowAct.startActivity(i); + } + + static void add(Class<?> a, Integer event, Class<?> b) { + if (mp.containsKey(a)) + mp.get(a).put(event, b); + else { + HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>(); + h.put(event, b); + mp.put(a, h); + } + } + + static void addTransition(Class<?> a, int i, Class<?> b) { + if (mp.containsKey(a)) { + HashMap<Integer, Class<?>> h = mp.get(a); + h.put(i, b); + mp.put(a, h); + } else { + HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>(); + h.put(i, b); + mp.put(a, h); + } + } + + static void addStatus(Class<?> a) { + mp.put(a, new HashMap<Integer, Class<?>>()); + } + + static void init() { + mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>(); + addStatus(InitAct.class); + + } + +} diff --git a/client/Piztor/src/com/macaroon/piztor/InitAct.java b/client/Piztor/src/com/macaroon/piztor/InitAct.java new file mode 100644 index 0000000..1ce492c --- /dev/null +++ b/client/Piztor/src/com/macaroon/piztor/InitAct.java @@ -0,0 +1,22 @@ +package com.macaroon.piztor; + +import android.os.Bundle; +import android.app.Activity; +import android.view.Menu; + +public class InitAct extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_init); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.init, menu); + return true; + } + +} diff --git a/client/Piztor/src/com/macaroon/piztor/PiztorAct.java b/client/Piztor/src/com/macaroon/piztor/PiztorAct.java new file mode 100644 index 0000000..ad12b17 --- /dev/null +++ b/client/Piztor/src/com/macaroon/piztor/PiztorAct.java @@ -0,0 +1,60 @@ +package com.macaroon.piztor; + +import android.app.Activity; +import android.os.Bundle; + +public class PiztorAct extends Activity { + String id; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + System.out.println(id + " on create"); + AppMgr.setStatus(AppMgr.ActivityStatus.create); + AppMgr.nowAct = this; + } + + @Override + protected void onStart() { + super.onStart(); + System.out.println(id + " on start"); + AppMgr.setStatus(AppMgr.ActivityStatus.start); + AppMgr.nowAct = this; + } + + @Override + protected void onStop() { + super.onStop(); + System.out.println(id + " on stop"); + AppMgr.setStatus(AppMgr.ActivityStatus.stop); + } + + @Override + protected void onResume() { + super.onResume(); + System.out.println(id + " on resume"); + AppMgr.setStatus(AppMgr.ActivityStatus.resume); + AppMgr.nowAct = this; + } + + @Override + protected void onPause() { + super.onPause(); + System.out.println(id + " on pause"); + AppMgr.setStatus(AppMgr.ActivityStatus.pause); + } + + @Override + protected void onRestart() { + super.onRestart(); + System.out.println(id + " on restart"); + AppMgr.setStatus(AppMgr.ActivityStatus.restart); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + System.out.println(id + " on destroy"); + AppMgr.setStatus(AppMgr.ActivityStatus.destroy); + } + +} |