Commits

Micha Kops committed a722a99

Added dream animation.

Comments (0)

Files changed (7)

AndroidManifest.xml

 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.hascode.dream_app"
+    package="com.hascode.android.dream_app"
     android:versionCode="1"
     android:versionName="1.0" >
 
         android:label="@string/app_name"
         android:theme="@style/AppTheme" >
         <service
-            android:name=".SampleDream"
+            android:name="com.hascode.android.dream_app.SampleDream"
             android:exported="true"
             android:icon="@drawable/ic_launcher"
             android:label="@string/custom_dream_label" >
 
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-
-            <!-- Point to additional information for this dream (optional) -->
-            <meta-data
-                android:name="android.service.dream"
-                android:resource="@xml/sample_dream" />
         </service>
     </application>
 
 # Android Dream Tutorial
 
-tbd ...
+A short tutorial how to use the new Dream API for Android 4.2.
+
+For the full tutorial, please feel free to take a look at my blog at [www.hascode.com].
 
 ---
 
 **2012 / Micha Kops**
+
+   [www.hascode.com]:http://www.hascode.com/

res/anim/dream_animation.xml

+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <scale android:fromXScale="1.0" android:toXScale="3.0"
+ android:fromYScale="1.0" android:toYScale="3.0" android:pivotX="50%"
+ android:pivotY="50%" android:fillAfter="false" android:duration="5000" />
+ <set>
+ <alpha xmlns:android="http://schemas.android.com/apk/res/android"
+ android:fromAlpha="0.2" android:toAlpha="1.0" android:duration="3000" />
+ <rotate android:fromDegrees="0" android:toDegrees="-360"
+ android:toYScale="0.0" android:pivotX="50%" android:pivotY="50%"
+ android:startOffset="700" android:duration="4000" />
+ <translate android:fromXDelta="100%" android:toXDelta="-20%"
+ android:fromYDelta="60%" android:toYDelta="-30%" android:duration="3000"
+ android:zAdjustment="bottom" />
+ </set>
+</set>

res/layout/dream.xml

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
+    android:gravity="center"
     android:orientation="vertical" >
-    
+
+    <TextView
+        android:id="@+id/animatedText"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/demo_text"
+        android:typeface="monospace"
+        android:shadowColor="#000000"
+        android:shadowRadius="2."
+        android:shadowDx="4"
+        android:shadowDy="4"
+        android:textAppearance="?android:attr/textAppearanceMedium" />
 
 </LinearLayout>

res/values/dimens.xml

+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+</resources>

res/values/strings.xml

 <resources>
 
     <string name="app_name">hasCode Dream App</string>
-    <string name="custom_dream_label">Custom Dream</string>
+    <string name="custom_dream_label">hasCode Dream</string>
+    <string name="demo_text">Dreaming of hasCode.com..</string>
 
 </resources>

src/com/hascode/android/dream_app/SampleDream.java

+package com.hascode.android.dream_app;
+
+import android.service.dreams.DreamService;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.TextView;
+
+public class SampleDream extends DreamService {
+
+	@Override
+	public void onAttachedToWindow() {
+		super.onAttachedToWindow();
+		setInteractive(false);
+		setFullscreen(true);
+		setContentView(R.layout.dream);
+		TextView animatedText = (TextView) findViewById(R.id.animatedText);
+		Animation animation = AnimationUtils.loadAnimation(this,
+				R.anim.dream_animation);
+		animation.reset();
+		animatedText.startAnimation(animation);
+	}
+}